aboutsummaryrefslogtreecommitdiff
path: root/test/cases
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2018-05-13 13:38:03 -0400
committerAndrew Kelley <superjoe30@gmail.com>2018-05-13 13:38:03 -0400
commit86a352c45bb654951529660b2e6cbbfa72773170 (patch)
treee7a4f5760918ec54bf247e9c23dc7e29d1d7c459 /test/cases
parent4787127cf6418f7a819c9d6f07a9046d76e0de65 (diff)
parent05ecb49bac30041459ae08764edd2aced23d10eb (diff)
downloadzig-86a352c45bb654951529660b2e6cbbfa72773170.tar.gz
zig-86a352c45bb654951529660b2e6cbbfa72773170.zip
Merge branch 'master' into pointer-reform
Diffstat (limited to 'test/cases')
-rw-r--r--test/cases/eval.zig17
-rw-r--r--test/cases/math.zig8
-rw-r--r--test/cases/new_stack_call.zig26
3 files changed, 51 insertions, 0 deletions
diff --git a/test/cases/eval.zig b/test/cases/eval.zig
index 2571686b0b..d7ad68b74e 100644
--- a/test/cases/eval.zig
+++ b/test/cases/eval.zig
@@ -569,3 +569,20 @@ test "runtime 128 bit integer division" {
var c = a / b;
assert(c == 15231399999);
}
+
+pub const Info = struct {
+ version: u8,
+};
+
+pub const diamond_info = Info {
+ .version = 0,
+};
+
+test "comptime modification of const struct field" {
+ comptime {
+ var res = diamond_info;
+ res.version = 1;
+ assert(diamond_info.version == 0);
+ assert(res.version == 1);
+ }
+}
diff --git a/test/cases/math.zig b/test/cases/math.zig
index 406ffec8d4..3c6156a3ea 100644
--- a/test/cases/math.zig
+++ b/test/cases/math.zig
@@ -352,6 +352,14 @@ test "big number multi-limb shift and mask" {
}
}
+test "big number multi-limb partial shift right" {
+ comptime {
+ var a = 0x1ffffffffeeeeeeee;
+ a >>= 16;
+ assert(a == 0x1ffffffffeeee);
+ }
+}
+
test "xor" {
test_xor();
comptime test_xor();
diff --git a/test/cases/new_stack_call.zig b/test/cases/new_stack_call.zig
new file mode 100644
index 0000000000..5912550d54
--- /dev/null
+++ b/test/cases/new_stack_call.zig
@@ -0,0 +1,26 @@
+const std = @import("std");
+const assert = std.debug.assert;
+
+var new_stack_bytes: [1024]u8 = undefined;
+
+test "calling a function with a new stack" {
+ const arg = 1234;
+
+ const a = @newStackCall(new_stack_bytes[0..512], targetFunction, arg);
+ const b = @newStackCall(new_stack_bytes[512..], targetFunction, arg);
+ _ = targetFunction(arg);
+
+ assert(arg == 1234);
+ assert(a < b);
+}
+
+fn targetFunction(x: i32) usize {
+ assert(x == 1234);
+
+ var local_variable: i32 = 42;
+ const ptr = &local_variable;
+ ptr.* += 1;
+
+ assert(local_variable == 43);
+ return @ptrToInt(ptr);
+}