authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-01-08 10:41:36-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-01-08 10:41:36-05:00
loge4bc8d22c2f518353d31d8c99de8d35e5ead0c67
treeedf0b974211cd0c65000e5e39f771c7d6b9f7694
parent3ef447fa20f54f75ad3b9be59768b4ef284cb941

fix some tests


1 files changed, 11 insertions(+), 21 deletions(-)

test/run_tests.cpp+11-21
......@@ -1022,16 +1022,15 @@ const x = foo();
10221022 )SOURCE", 1, ".tmp_source.zig:3:11: error: unable to evaluate constant expression");
10231023
10241024 add_compile_fail_case("array concatenation with wrong type", R"SOURCE(
1025fn f(s: []u8) -> []u8 {
1026 s ++ "foo"
1027}
1028 )SOURCE", 1, ".tmp_source.zig:3:5: error: expected array or C string literal, found '[]u8'");
1025const src = "aoeu";
1026const a = src[0...] ++ "foo";
1027 )SOURCE", 1, ".tmp_source.zig:3:14: error: expected array or C string literal, found '[]u8'");
10291028
10301029 add_compile_fail_case("non compile time array concatenation", R"SOURCE(
10311030fn f(s: [10]u8) -> []u8 {
10321031 s ++ "foo"
10331032}
1034 )SOURCE", 1, ".tmp_source.zig:3:5: error: array concatenation requires constant expression");
1033 )SOURCE", 1, ".tmp_source.zig:3:5: error: unable to evaluate constant expression");
10351034
10361035 add_compile_fail_case("@cImport with bogus include", R"SOURCE(
10371036const c = @cImport(@cInclude("bogus.h"));
......@@ -1041,14 +1040,8 @@ const c = @cImport(@cInclude("bogus.h"));
10411040 add_compile_fail_case("address of number literal", R"SOURCE(
10421041const x = 3;
10431042const y = &x;
1044 )SOURCE", 1, ".tmp_source.zig:3:12: error: unable to get address of type '(integer literal)'");
1045
1046 add_compile_fail_case("@typeOf number literal", R"SOURCE(
1047const x = 3;
1048const Foo = struct {
1049 index: @typeOf(x),
1050};
1051 )SOURCE", 1, ".tmp_source.zig:4:20: error: type '(integer literal)' not eligible for @typeOf");
1043fn foo() -> &const i32 { y }
1044 )SOURCE", 1, ".tmp_source.zig:4:26: error: expected type '&const i32', found '&const (integer literal)'");
10521045
10531046 add_compile_fail_case("integer overflow error", R"SOURCE(
10541047const x : u8 = 300;
......@@ -1077,7 +1070,7 @@ const members = []member_fn_type {
10771070 Foo.member_b,
10781071};
10791072
1080fn f(foo: Foo, index: i32) {
1073fn f(foo: Foo, index: usize) {
10811074 const result = members[index]();
10821075}
10831076 )SOURCE", 1, ".tmp_source.zig:21:34: error: expected 1 arguments, found 0");
......@@ -1094,10 +1087,7 @@ const fns = []fn(){ a, b, c };
10941087fn a() -> i32 {0}
10951088fn b() -> i32 {1}
10961089fn c() -> i32 {2}
1097 )SOURCE", 3,
1098 ".tmp_source.zig:2:21: error: expected type 'fn()', found 'fn() -> i32'",
1099 ".tmp_source.zig:2:24: error: expected type 'fn()', found 'fn() -> i32'",
1100 ".tmp_source.zig:2:27: error: expected type 'fn()', found 'fn() -> i32'");
1090 )SOURCE", 1, ".tmp_source.zig:2:21: error: expected type 'fn()', found 'fn() -> i32'");
11011091
11021092 add_compile_fail_case("extern function pointer mismatch", R"SOURCE(
11031093const fns = [](fn(i32)->i32){ a, b, c };
......@@ -1126,11 +1116,11 @@ const x = @compileVar("bogus");
11261116 )SOURCE", 1, ".tmp_source.zig:2:23: error: unrecognized compile variable: 'bogus'");
11271117
11281118
1129 add_compile_fail_case("@constEval", R"SOURCE(
1119 add_compile_fail_case("@staticEval", R"SOURCE(
11301120fn a(x: i32) {
1131 const y = @constEval(x);
1121 const y = @staticEval(x);
11321122}
1133 )SOURCE", 1, ".tmp_source.zig:3:26: error: unable to evaluate constant expression");
1123 )SOURCE", 1, ".tmp_source.zig:3:27: error: unable to evaluate constant expression");
11341124
11351125 add_compile_fail_case("non constant expression in array size outside function", R"SOURCE(
11361126const Foo = struct {