| ... | @@ -487,20 +487,20 @@ fn MakeType(comptime T: type) type { | ... | @@ -487,20 +487,20 @@ fn MakeType(comptime T: type) type { |
| 487 | } | 487 | } |
| 488 | | 488 | |
| 489 | test "implicit cast from *[N]T to ?[*]T" { | 489 | test "implicit cast from *[N]T to ?[*]T" { |
| 490 | var x: ?[*]u16 = null; | 490 | var x: ?[*]u16 = null; |
| 491 | var y: [4]u16 = [4]u16 {0, 1, 2, 3}; | 491 | var y: [4]u16 = [4]u16{ 0, 1, 2, 3 }; |
| 492 | | 492 | |
| 493 | x = &y; | 493 | x = &y; |
| 494 | assert(std.mem.eql(u16, x.?[0..4], y[0..4])); | 494 | assert(std.mem.eql(u16, x.?[0..4], y[0..4])); |
| 495 | x.?[0] = 8; | 495 | x.?[0] = 8; |
| 496 | y[3] = 6; | 496 | y[3] = 6; |
| 497 | assert(std.mem.eql(u16, x.?[0..4], y[0..4])); | 497 | assert(std.mem.eql(u16, x.?[0..4], y[0..4])); |
| 498 | } | 498 | } |
| 499 | | 499 | |
| 500 | test "implicit cast from *T to ?*c_void" { | 500 | test "implicit cast from *T to ?*c_void" { |
| 501 | var a: u8 = 1; | 501 | var a: u8 = 1; |
| 502 | incrementVoidPtrValue(&a); | 502 | incrementVoidPtrValue(&a); |
| 503 | std.debug.assert(a == 2); | 503 | std.debug.assert(a == 2); |
| 504 | } | 504 | } |
| 505 | | 505 | |
| 506 | fn incrementVoidPtrValue(value: ?*c_void) void { | 506 | fn incrementVoidPtrValue(value: ?*c_void) void { |
| ... | @@ -508,15 +508,14 @@ fn incrementVoidPtrValue(value: ?*c_void) void { | ... | @@ -508,15 +508,14 @@ fn incrementVoidPtrValue(value: ?*c_void) void { |
| 508 | } | 508 | } |
| 509 | | 509 | |
| 510 | test "implicit cast from [*]T to ?*c_void" { | 510 | test "implicit cast from [*]T to ?*c_void" { |
| 511 | var a = []u8{3, 2, 1}; | 511 | var a = []u8{ 3, 2, 1 }; |
| 512 | incrementVoidPtrArray(a[0..].ptr, 3); | 512 | incrementVoidPtrArray(a[0..].ptr, 3); |
| 513 | std.debug.assert(std.mem.eql(u8, a, []u8{4, 3, 2})); | 513 | assert(std.mem.eql(u8, a, []u8{ 4, 3, 2 })); |
| 514 | } | 514 | } |
| 515 | | 515 | |
| 516 | fn incrementVoidPtrArray(array: ?*c_void, len: usize) void { | 516 | fn incrementVoidPtrArray(array: ?*c_void, len: usize) void { |
| 517 | var n: usize = 0; | 517 | var n: usize = 0; |
| 518 | while(n < len) : (n += 1) { | 518 | while (n < len) : (n += 1) { |
| 519 | std.debug.warn("{}", n); | | |
| 520 | @ptrCast([*]u8, array.?)[n] += 1; | 519 | @ptrCast([*]u8, array.?)[n] += 1; |
| 521 | } | 520 | } |
| 522 | } | | |
| \ No newline at end of file |
| | 521 | } |