aboutsummaryrefslogtreecommitdiff
path: root/test/run_tests.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-01-04 19:10:52 -0700
committerAndrew Kelley <superjoe30@gmail.com>2016-01-04 19:11:36 -0700
commite0aa0736be47e5e1383d8fb25f744f95c5a830ba (patch)
tree0ae86d7782de9e73d21449fd70a9fc3383cdad0a /test/run_tests.cpp
parent22c52f1eb67a46e60be876fda332ad7d2f338ee7 (diff)
downloadzig-e0aa0736be47e5e1383d8fb25f744f95c5a830ba.tar.gz
zig-e0aa0736be47e5e1383d8fb25f744f95c5a830ba.zip
add pointer dereferencing operator
Diffstat (limited to 'test/run_tests.cpp')
-rw-r--r--test/run_tests.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/test/run_tests.cpp b/test/run_tests.cpp
index 18f0f3902d..cb536ac631 100644
--- a/test/run_tests.cpp
+++ b/test/run_tests.cpp
@@ -757,6 +757,26 @@ pub fn main(argc : isize, argv : &&u8, env : &&u8) -> i32 {
return 0;
}
)SOURCE", "OK\n");
+
+ add_simple_case("pointer dereferencing", R"SOURCE(
+use "std.zig";
+
+pub fn main(argc: isize, argv: &&u8, env: &&u8) -> i32 {
+ var x = 3 as i32;
+ const y = &x;
+
+ *y += 1;
+
+ if (x != 4) {
+ print_str("BAD\n");
+ }
+ if (*y != 4) {
+ print_str("BAD\n");
+ }
+ print_str("OK\n");
+ return 0;
+}
+ )SOURCE", "OK\n");
}
////////////////////////////////////////////////////////////////////////////////////
@@ -904,7 +924,7 @@ a_label:
fn f() {
3 = 3;
}
- )SOURCE", 1, ".tmp_source.zig:3:5: error: assignment target must be variable, field, or array element");
+ )SOURCE", 1, ".tmp_source.zig:3:5: error: invalid assignment target");
add_compile_fail_case("assign to constant variable", R"SOURCE(
fn f() {