| ... | ... | @@ -13,15 +13,6 @@ test "return string from function" { |
| 13 | 13 | try expect(mem.eql(u8, first4KeysOfHomeRow(), "aoeu")); |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | | const g1: i32 = 1233 + 1; |
| 17 | | var g2: i32 = 0; |
| 18 | | |
| 19 | | test "global variables" { |
| 20 | | try expect(g2 == 0); |
| 21 | | g2 = g1; |
| 22 | | try expect(g2 == 1234); |
| 23 | | } |
| 24 | | |
| 25 | 16 | test "memcpy and memset intrinsics" { |
| 26 | 17 | var foo: [20]u8 = undefined; |
| 27 | 18 | var bar: [20]u8 = undefined; |
| ... | ... | @@ -32,13 +23,6 @@ test "memcpy and memset intrinsics" { |
| 32 | 23 | if (bar[11] != 'A') unreachable; |
| 33 | 24 | } |
| 34 | 25 | |
| 35 | | test "builtin static eval" { |
| 36 | | const x: i32 = comptime x: { |
| 37 | | break :x 1 + 2 + 3; |
| 38 | | }; |
| 39 | | try expect(x == comptime 6); |
| 40 | | } |
| 41 | | |
| 42 | 26 | test "slicing" { |
| 43 | 27 | var array: [20]i32 = undefined; |
| 44 | 28 | |
| ... | ... | @@ -148,10 +132,6 @@ test "multiline C string" { |
| 148 | 132 | try expect(std.cstr.cmp(s1, s2) == 0); |
| 149 | 133 | } |
| 150 | 134 | |
| 151 | | test "type equality" { |
| 152 | | try expect(*const u8 != *u8); |
| 153 | | } |
| 154 | | |
| 155 | 135 | const global_a: i32 = 1234; |
| 156 | 136 | const global_b: *const i32 = &global_a; |
| 157 | 137 | const global_c: *const f32 = @ptrCast(*const f32, global_b); |
| ... | ... | @@ -187,17 +167,6 @@ fn testCastUndefined(x: []const u8) void { |
| 187 | 167 | _ = x; |
| 188 | 168 | } |
| 189 | 169 | |
| 190 | | test "cast small unsigned to larger signed" { |
| 191 | | try expect(castSmallUnsignedToLargerSigned1(200) == @as(i16, 200)); |
| 192 | | try expect(castSmallUnsignedToLargerSigned2(9999) == @as(i64, 9999)); |
| 193 | | } |
| 194 | | fn castSmallUnsignedToLargerSigned1(x: u8) i16 { |
| 195 | | return x; |
| 196 | | } |
| 197 | | fn castSmallUnsignedToLargerSigned2(x: u16) i64 { |
| 198 | | return x; |
| 199 | | } |
| 200 | | |
| 201 | 170 | test "implicit cast after unreachable" { |
| 202 | 171 | try expect(outer() == 1234); |
| 203 | 172 | } |
| ... | ... | @@ -208,16 +177,6 @@ fn outer() i64 { |
| 208 | 177 | return inner(); |
| 209 | 178 | } |
| 210 | 179 | |
| 211 | | test "pointer dereferencing" { |
| 212 | | var x = @as(i32, 3); |
| 213 | | const y = &x; |
| 214 | | |
| 215 | | y.* += 1; |
| 216 | | |
| 217 | | try expect(x == 4); |
| 218 | | try expect(y.* == 4); |
| 219 | | } |
| 220 | | |
| 221 | 180 | test "call result of if else expression" { |
| 222 | 181 | try expect(mem.eql(u8, f2(true), "a")); |
| 223 | 182 | try expect(mem.eql(u8, f2(false), "b")); |
| ... | ... | @@ -232,13 +191,6 @@ fn fB() []const u8 { |
| 232 | 191 | return "b"; |
| 233 | 192 | } |
| 234 | 193 | |
| 235 | | test "const expression eval handling of variables" { |
| 236 | | var x = true; |
| 237 | | while (x) { |
| 238 | | x = false; |
| 239 | | } |
| 240 | | } |
| 241 | | |
| 242 | 194 | test "constant enum initialization with differing sizes" { |
| 243 | 195 | try test3_1(test3_foo); |
| 244 | 196 | try test3_2(test3_bar); |
| ... | ... | @@ -277,11 +229,6 @@ fn test3_2(f: Test3Foo) !void { |
| 277 | 229 | } |
| 278 | 230 | } |
| 279 | 231 | |
| 280 | | test "character literals" { |
| 281 | | try expect('\'' == single_quote); |
| 282 | | } |
| 283 | | const single_quote = '\''; |
| 284 | | |
| 285 | 232 | test "take address of parameter" { |
| 286 | 233 | try testTakeAddressOfParameter(12.34); |
| 287 | 234 | } |
| ... | ... | @@ -330,11 +277,6 @@ fn testPointerToVoidReturnType2() *const void { |
| 330 | 277 | return &test_pointer_to_void_return_type_x; |
| 331 | 278 | } |
| 332 | 279 | |
| 333 | | test "non const ptr to aliased type" { |
| 334 | | const int = i32; |
| 335 | | try expect(?*int == ?*i32); |
| 336 | | } |
| 337 | | |
| 338 | 280 | test "array 2D const double ptr" { |
| 339 | 281 | const rect_2d_vertexes = [_][1]f32{ |
| 340 | 282 | [_]f32{1.0}, |
| ... | ... | @@ -349,22 +291,6 @@ fn testArray2DConstDoublePtr(ptr: *const f32) !void { |
| 349 | 291 | try expect(ptr2[1] == 2.0); |
| 350 | 292 | } |
| 351 | 293 | |
| 352 | | const AStruct = struct { |
| 353 | | x: i32, |
| 354 | | }; |
| 355 | | const AnEnum = enum { |
| 356 | | One, |
| 357 | | Two, |
| 358 | | }; |
| 359 | | const AUnionEnum = union(enum) { |
| 360 | | One: i32, |
| 361 | | Two: void, |
| 362 | | }; |
| 363 | | const AUnion = union { |
| 364 | | One: void, |
| 365 | | Two: void, |
| 366 | | }; |
| 367 | | |
| 368 | 294 | test "double implicit cast in same expression" { |
| 369 | 295 | var x = @as(i32, @as(u16, nine())); |
| 370 | 296 | try expect(x == 9); |
| ... | ... | @@ -440,15 +366,6 @@ test "function closes over local const" { |
| 440 | 366 | try expect(x == 1); |
| 441 | 367 | } |
| 442 | 368 | |
| 443 | | test "cold function" { |
| 444 | | thisIsAColdFn(); |
| 445 | | comptime thisIsAColdFn(); |
| 446 | | } |
| 447 | | |
| 448 | | fn thisIsAColdFn() void { |
| 449 | | @setCold(true); |
| 450 | | } |
| 451 | | |
| 452 | 369 | const PackedStruct = packed struct { |
| 453 | 370 | a: u8, |
| 454 | 371 | b: u8, |
| ... | ... | @@ -562,15 +479,6 @@ test "thread local variable" { |
| 562 | 479 | try expect(S.t == 1235); |
| 563 | 480 | } |
| 564 | 481 | |
| 565 | | test "unicode escape in character literal" { |
| 566 | | var a: u24 = '\u{01f4a9}'; |
| 567 | | try expect(a == 128169); |
| 568 | | } |
| 569 | | |
| 570 | | test "unicode character in character literal" { |
| 571 | | try expect('💩' == 128169); |
| 572 | | } |
| 573 | | |
| 574 | 482 | test "result location zero sized array inside struct field implicit cast to slice" { |
| 575 | 483 | const E = struct { |
| 576 | 484 | entries: []u32, |