aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/basic.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-08-01 23:27:38 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-08-01 23:27:38 -0700
commitb465037a65dd6a31c5865086ec4392a1d3a372bc (patch)
tree1c95f588e43e777e2dc77038cc29ff6ab3fde26c /test/behavior/basic.zig
parenteba153f88f0bdb36a654bd2cb794d2ead9d4e398 (diff)
downloadzig-b465037a65dd6a31c5865086ec4392a1d3a372bc.tar.gz
zig-b465037a65dd6a31c5865086ec4392a1d3a372bc.zip
move some behavior tests to the "passing for stage2" section
Diffstat (limited to 'test/behavior/basic.zig')
-rw-r--r--test/behavior/basic.zig65
1 files changed, 65 insertions, 0 deletions
diff --git a/test/behavior/basic.zig b/test/behavior/basic.zig
index 87de1c9fe5..c5c2972ffc 100644
--- a/test/behavior/basic.zig
+++ b/test/behavior/basic.zig
@@ -18,3 +18,68 @@ test "truncate" {
fn testTruncate(x: u32) u8 {
return @truncate(u8, x);
}
+
+const g1: i32 = 1233 + 1;
+var g2: i32 = 0;
+
+test "global variables" {
+ try expect(g2 == 0);
+ g2 = g1;
+ try expect(g2 == 1234);
+}
+
+test "comptime keyword on expressions" {
+ const x: i32 = comptime x: {
+ break :x 1 + 2 + 3;
+ };
+ try expect(x == comptime 6);
+}
+
+test "type equality" {
+ try expect(*const u8 != *u8);
+}
+
+test "pointer dereferencing" {
+ var x = @as(i32, 3);
+ const y = &x;
+
+ y.* += 1;
+
+ try expect(x == 4);
+ try expect(y.* == 4);
+}
+
+test "const expression eval handling of variables" {
+ var x = true;
+ while (x) {
+ x = false;
+ }
+}
+
+test "character literals" {
+ try expect('\'' == single_quote);
+}
+const single_quote = '\'';
+
+test "non const ptr to aliased type" {
+ const int = i32;
+ try expect(?*int == ?*i32);
+}
+
+test "cold function" {
+ thisIsAColdFn();
+ comptime thisIsAColdFn();
+}
+
+fn thisIsAColdFn() void {
+ @setCold(true);
+}
+
+test "unicode escape in character literal" {
+ var a: u24 = '\u{01f4a9}';
+ try expect(a == 128169);
+}
+
+test "unicode character in character literal" {
+ try expect('💩' == 128169);
+}