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