aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/cases/misc.zig22
-rw-r--r--test/self_hosted.zig42
2 files changed, 22 insertions, 42 deletions
diff --git a/test/cases/misc.zig b/test/cases/misc.zig
index 5ae312c0dc..826f1551a9 100644
--- a/test/cases/misc.zig
+++ b/test/cases/misc.zig
@@ -451,6 +451,28 @@ fn cStringConcatenation() {
assert(b[len] == 0);
}
+fn castSliceToU8Slice() {
+ @setFnTest(this);
+
+ assert(@sizeOf(i32) == 4);
+ var big_thing_array = []i32{1, 2, 3, 4};
+ const big_thing_slice: []i32 = big_thing_array;
+ const bytes = ([]u8)(big_thing_slice);
+ assert(bytes.len == 4 * 4);
+ bytes[4] = 0;
+ bytes[5] = 0;
+ bytes[6] = 0;
+ bytes[7] = 0;
+ assert(big_thing_slice[1] == 0);
+ const big_thing_again = ([]i32)(bytes);
+ assert(big_thing_again[2] == 3);
+ big_thing_again[2] = -1;
+ assert(bytes[8] == @maxValue(u8));
+ assert(bytes[9] == @maxValue(u8));
+ assert(bytes[10] == @maxValue(u8));
+ assert(bytes[11] == @maxValue(u8));
+}
+
// TODO import from std.cstr
pub fn cstrlen(ptr: &const u8) -> usize {
var count: usize = 0;
diff --git a/test/self_hosted.zig b/test/self_hosted.zig
index 54219270d8..4b04ba4d5a 100644
--- a/test/self_hosted.zig
+++ b/test/self_hosted.zig
@@ -38,45 +38,3 @@ fn testPassSliceOfEmptyStructToFn(slice: []EmptyStruct2) -> usize {
}
-// TODO change this test to an issue
-// we're going to change how this works
-fn switchOnErrorUnion() {
- @setFnTest(this, true);
-
- const x = switch (returnsTen()) {
- Ok => |val| val + 1,
- ItBroke, NoMem => 1,
- CrappedOut => 2,
- };
- assert(x == 11);
-}
-error ItBroke;
-error NoMem;
-error CrappedOut;
-fn returnsTen() -> %i32 {
- @setFnStaticEval(this, false);
- 10
-}
-
-// TODO not passing
-fn castSliceToU8Slice() {
- @setFnTest(this);
-
- assert(@sizeOf(i32) == 4);
- var big_thing_array = []i32{1, 2, 3, 4};
- const big_thing_slice: []i32 = big_thing_array;
- const bytes = ([]u8)(big_thing_slice);
- assert(bytes.len == 4 * 4);
- bytes[4] = 0;
- bytes[5] = 0;
- bytes[6] = 0;
- bytes[7] = 0;
- assert(big_thing_slice[1] == 0);
- const big_thing_again = ([]i32)(bytes);
- assert(big_thing_again[2] == 3);
- big_thing_again[2] = -1;
- assert(bytes[8] == @maxValue(u8));
- assert(bytes[9] == @maxValue(u8));
- assert(bytes[10] == @maxValue(u8));
- assert(bytes[11] == @maxValue(u8));
-}