aboutsummaryrefslogtreecommitdiff
path: root/doc/langref/test_static_local_variable.zig
blob: 4531a96a370e40bd8d2ba9a8064e32e9bc527fd8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
const std = @import("std");
const expect = std.testing.expect;

test "static local variable" {
    try expect(foo() == 1235);
    try expect(foo() == 1236);
}

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

// test