2017-05-10 10:23:38 +08:00
|
|
|
const assert = @import("std").debug.assert;
|
|
|
|
|
2017-05-19 22:39:59 +08:00
|
|
|
const x = @intToPtr(&i32, 0x1000)[0..0x500];
|
|
|
|
const y = x[0x100..];
|
2017-05-10 10:23:38 +08:00
|
|
|
test "compile time slice of pointer to hard coded address" {
|
2017-08-09 05:38:25 +08:00
|
|
|
assert(@ptrToInt(x.ptr) == 0x1000);
|
2017-05-10 10:23:38 +08:00
|
|
|
assert(x.len == 0x500);
|
|
|
|
|
2017-08-09 05:38:25 +08:00
|
|
|
assert(@ptrToInt(y.ptr) == 0x1100);
|
2017-05-10 10:23:38 +08:00
|
|
|
assert(y.len == 0x400);
|
|
|
|
}
|
2017-09-14 02:30:57 +08:00
|
|
|
|
|
|
|
test "slice child property" {
|
|
|
|
var array: [5]i32 = undefined;
|
|
|
|
var slice = array[0..];
|
|
|
|
assert(@typeOf(slice).Child == i32);
|
|
|
|
}
|