zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

test_TypeOf_builtin.zig (308B) - Raw


      1 const std = @import("std");
      2 const expect = std.testing.expect;
      3 
      4 test "no runtime side effects" {
      5     var data: i32 = 0;
      6     const T = @TypeOf(foo(i32, &data));
      7     try comptime expect(T == i32);
      8     try expect(data == 0);
      9 }
     10 
     11 fn foo(comptime T: type, ptr: *T) T {
     12     ptr.* += 1;
     13     return ptr.*;
     14 }
     15 
     16 // test