about summary refs log tree commit diff
path: root/lang/zig/namespaced-global.zig
blob: 2d06ced0096f72d2883fa6892afea779267fbf7f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
const std = @import("std");
const expect = std.testing.expect;

test "namespaced global variable" {
    expect(foo() == 1235);
    expect(foo() == 1236);
}

fn foo() i32 {
    const S = struct {
        var x: i32 = 1234;
    };
    S.x += 1;
    return S.x;
}