aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/cases/enum_with_members.zig2
-rw-r--r--test/cases/misc.zig7
-rw-r--r--test/cases/struct.zig4
-rw-r--r--test/run_tests.cpp10
4 files changed, 15 insertions, 8 deletions
diff --git a/test/cases/enum_with_members.zig b/test/cases/enum_with_members.zig
index 9be2d0f749..7bcc2ac01f 100644
--- a/test/cases/enum_with_members.zig
+++ b/test/cases/enum_with_members.zig
@@ -6,7 +6,7 @@ const ET = enum {
SINT: i32,
UINT: u32,
- pub fn print(a: &ET, buf: []u8) -> %usize {
+ pub fn print(a: &const ET, buf: []u8) -> %usize {
return switch (*a) {
ET.SINT => |x| { io.bufPrintInt(i32, buf, x) },
ET.UINT => |x| { io.bufPrintInt(u32, buf, x) },
diff --git a/test/cases/misc.zig b/test/cases/misc.zig
index 4f25cb90d5..45966f1d20 100644
--- a/test/cases/misc.zig
+++ b/test/cases/misc.zig
@@ -490,3 +490,10 @@ const test_pointer_to_void_return_type_x = void{};
fn testPointerToVoidReturnType2() -> &const void {
return &test_pointer_to_void_return_type_x;
}
+
+
+fn nonConstPtrToAliasedType() {
+ @setFnTest(this);
+ const int = i32;
+ assert(?&int == ?&i32);
+}
diff --git a/test/cases/struct.zig b/test/cases/struct.zig
index efe476d808..930aa79db1 100644
--- a/test/cases/struct.zig
+++ b/test/cases/struct.zig
@@ -155,7 +155,7 @@ fn memberFunctions() {
}
const MemberFnRand = struct {
seed: u32,
- pub fn getSeed(r: MemberFnRand) -> u32 {
+ pub fn getSeed(r: &const MemberFnRand) -> u32 {
r.seed
}
};
@@ -184,7 +184,7 @@ fn emptyStructMethodCall() {
assert(es.method() == 1234);
}
const EmptyStruct = struct {
- fn method(es: EmptyStruct) -> i32 {
+ fn method(es: &const EmptyStruct) -> i32 {
1234
}
};
diff --git a/test/run_tests.cpp b/test/run_tests.cpp
index 5d05245888..4d1f5ed60d 100644
--- a/test/run_tests.cpp
+++ b/test/run_tests.cpp
@@ -548,7 +548,7 @@ const B = struct {
const C = struct {
x: i32,
- fn d(c: C) {
+ fn d(c: &const C) {
%%io.stdout.printf("OK\n");
}
};
@@ -577,13 +577,13 @@ const io = @import("std").io;
const Foo = struct {
field1: Bar,
- fn method(a: &Foo) -> bool { true }
+ fn method(a: &const Foo) -> bool { true }
};
const Bar = struct {
field2: i32,
- fn method(b: &Bar) -> bool { true }
+ fn method(b: &const Bar) -> bool { true }
};
pub fn main(args: [][]u8) -> %void {
@@ -787,14 +787,14 @@ fn f(a : unreachable) {}
fn f() {
3 = 3;
}
- )SOURCE", 1, ".tmp_source.zig:3:5: error: invalid assignment target");
+ )SOURCE", 1, ".tmp_source.zig:3:7: error: cannot assign to constant");
add_compile_fail_case("assign to constant variable", R"SOURCE(
fn f() {
const a = 3;
a = 4;
}
- )SOURCE", 1, ".tmp_source.zig:4:5: error: cannot assign to constant");
+ )SOURCE", 1, ".tmp_source.zig:4:7: error: cannot assign to constant");
add_compile_fail_case("use of undeclared identifier", R"SOURCE(
fn f() {