Initial Commit
This commit is contained in:
706 files changed
+135430
No files matched your search
@@ -0,0 +1,4 @@
|
||||
|
||||
--- exit 1
|
||||
sakura: runtime error: Index or slice is out of bounds.
|
||||
at main (tests/checked/an_index_outside_a_view_is_a_fault_1.sakura:5:15)
|
||||
@@ -0,0 +1,6 @@
|
||||
import std::io;
|
||||
def main(): void {
|
||||
var a: i64[2] = [1, 2];
|
||||
val s := span::<i64>::over(&a as *i64, 2);
|
||||
println($"{s[5]}");
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
before
|
||||
|
||||
--- exit 1
|
||||
sakura: runtime error: Value is not a member of its enum.
|
||||
at main (tests/checked/enums_and_match_values_3.sakura:6:14)
|
||||
@@ -0,0 +1,8 @@
|
||||
import std::io;
|
||||
enum color: u8 { red, green = 4, blue }
|
||||
def main(): void {
|
||||
val n := 260;
|
||||
println("before");
|
||||
val c := n as color;
|
||||
println($"{c}");
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
lowest low middle high higher
|
||||
|
||||
--- exit 1
|
||||
sakura: runtime error: Value is not a member of its enum.
|
||||
at convert (tests/checked/enums_declared_out_of_order_check_their_members_1.sakura:7:39)
|
||||
at main (tests/checked/enums_declared_out_of_order_check_their_members_1.sakura:15:21)
|
||||
@@ -0,0 +1,16 @@
|
||||
import std::io;
|
||||
|
||||
# Members declared out of the order of their values, which the check of a
|
||||
# conversion sorts into runs.
|
||||
enum level: u32 { high = 9, low = 1, middle = 5, lowest = 0, higher = 10 }
|
||||
|
||||
def convert(n: u32): level { return n as level; }
|
||||
|
||||
def main(): void {
|
||||
val members: u32[5] = [0, 1, 5, 9, 10];
|
||||
for n in members {
|
||||
print($"{convert(n)} ");
|
||||
}
|
||||
println("");
|
||||
println($"{convert(4)}");
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
99
|
||||
|
||||
--- exit 1
|
||||
sakura: runtime error: Index or slice is out of bounds.
|
||||
at main (tests/checked/faults_1.sakura:5:18)
|
||||
@@ -0,0 +1,6 @@
|
||||
import std::io;
|
||||
def main(): void {
|
||||
val text: span<u8> = "abc";
|
||||
println($"{text[2]}");
|
||||
println($"{text[3]}");
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
--- exit 1
|
||||
sakura: runtime error: Index or slice is out of bounds.
|
||||
at main (tests/checked/fixed_arrays_are_bounded_1.sakura:5:4)
|
||||
@@ -0,0 +1,6 @@
|
||||
import std::io;
|
||||
def main(): void {
|
||||
var a: int[3] = [1, 2, 3];
|
||||
var i: uint = 3;
|
||||
a[i] = 0;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
4
|
||||
|
||||
--- exit 1
|
||||
sakura: runtime error: Index or slice is out of bounds.
|
||||
at <lambda> (tests/checked/functions_as_values_2.sakura:5:67)
|
||||
at main (tests/checked/functions_as_values_2.sakura:7:18)
|
||||
@@ -0,0 +1,8 @@
|
||||
import std::io;
|
||||
def main(): void {
|
||||
var held: int[4] = [1, 2, 3, 4];
|
||||
val view := ((&mut held) as *mut int)[0:4];
|
||||
val pick := def(values: span<int>, at: u64): int { return values[at]; };
|
||||
println($"{pick(view, 3)}");
|
||||
println($"{pick(view, 9)}");
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
|
||||
--- exit 1
|
||||
sakura: runtime error: Value is not a member of its enum.
|
||||
at back<color> (tests/checked/ordinal_parameters_convert_to_and_from_integers_2.sakura:3:52)
|
||||
at main (tests/checked/ordinal_parameters_convert_to_and_from_integers_2.sakura:4:42)
|
||||
@@ -0,0 +1,4 @@
|
||||
import std::io;
|
||||
enum color: u8 { red, green = 4 }
|
||||
def back<T>(n: u64): T where T: ordinal { return n as T; }
|
||||
def main(): void { val c := back::<color>(3); }
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
--- exit 1
|
||||
sakura: runtime error: Union does not hold the field that was read.
|
||||
at main (tests/checked/refined_functions_as_values_2.sakura:6:8)
|
||||
@@ -0,0 +1,7 @@
|
||||
import std::io;
|
||||
struct failure { val message: span<u8>; }
|
||||
union callable { var failure: failure; var call: def(): void; }
|
||||
def main(): void {
|
||||
val held := callable{ failure = failure{ message = "no" } };
|
||||
held.call();
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
66
|
||||
--- exit 1
|
||||
sakura: runtime error: Index or slice is out of bounds.
|
||||
at pick (tests/checked/text_constants_are_indexed_as_views_2.sakura:2:35)
|
||||
at main (tests/checked/text_constants_are_indexed_as_views_2.sakura:3:57)
|
||||
@@ -0,0 +1,3 @@
|
||||
import std::io;
|
||||
def pick(i: u64): u8 { return "AB"[i]; }
|
||||
def main(): void { print($"{pick(1)} "); println($"{pick(5)}"); }
|
||||
@@ -0,0 +1,6 @@
|
||||
before
|
||||
|
||||
--- exit 1
|
||||
sakura: runtime error: Index or slice is out of bounds.
|
||||
at holder::at (tests/checked/types_implementing_indexable_are_indexed_3.sakura:4:71)
|
||||
at main (tests/checked/types_implementing_indexable_are_indexed_3.sakura:8:15)
|
||||
@@ -0,0 +1,9 @@
|
||||
import std::io;
|
||||
struct holder : indexable<u64, int> { var items: int[4]; }
|
||||
def holder::at(&this, key: u64): &int { return &this.items[key]; }
|
||||
def holder::at(&mut this, key: u64): &mut int { return &mut this.items[key]; }
|
||||
def main(): void {
|
||||
var d := holder { items = [1, 2, 3, 4] };
|
||||
println("before");
|
||||
println($"{d[9]}");
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
before
|
||||
|
||||
--- exit 1
|
||||
sakura: runtime error: Union does not hold the field that was read.
|
||||
at main (tests/checked/unions_2.sakura:6:14)
|
||||
@@ -0,0 +1,7 @@
|
||||
import std::io;
|
||||
union number { var whole: int; var real: f64; }
|
||||
def main(): void {
|
||||
val n := number{ real = 1.5 };
|
||||
println("before");
|
||||
val i := n.whole;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
before
|
||||
|
||||
--- exit 1
|
||||
sakura: runtime error: Index or slice is out of bounds.
|
||||
at main (tests/checked/views_of_fixed_arrays_write_where_the_array_can_2.sakura:6:13)
|
||||
@@ -0,0 +1,8 @@
|
||||
import std::io;
|
||||
def main(): void {
|
||||
var a: int[4] = [1, 2, 3, 4];
|
||||
var n := 3;
|
||||
println("before");
|
||||
val s := a[n:2];
|
||||
println($"{s}");
|
||||
}
|
||||
Reference in new issue
Block a user