zig

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

test_namespaced_container_level_variable.zig (276B) - Raw


      1 const std = @import("std");
      2 const expect = std.testing.expect;
      3 
      4 test "namespaced container level variable" {
      5     try expect(foo() == 1235);
      6     try expect(foo() == 1236);
      7 }
      8 
      9 const S = struct {
     10     var x: i32 = 1234;
     11 };
     12 
     13 fn foo() i32 {
     14     S.x += 1;
     15     return S.x;
     16 }
     17 
     18 // test