chore: import upstream snapshot with attribution
CI / Deep Native Runtime Cases (1/6) (push) Has been skipped
CI / Native Preflight (push) Failing after 1s
CI / Native Runtime Cases (1/2) (push) Failing after 0s
CI / Native Runtime Cases (2/2) (push) Failing after 1s
CI / Native Metadata Reports (push) Failing after 0s
CI / Native Direct Backend Artifacts (push) Failing after 0s
CI / Native Sanitizer Smoke (push) Failing after 1s
CI / Command Contract Snapshots (push) Failing after 1s
CI / Deep Conformance Suite (push) Has been skipped
CI / Graph Build Perf (push) Failing after 1s
CI / Deep Native Preflight (push) Has been skipped
CI / Deep Native Runtime Cases (2/6) (push) Has been skipped
CI / Deep Native Runtime Cases (3/6) (push) Has been skipped
CI / Conformance Suite (push) Failing after 1s
CI / Workspace Checks (push) Failing after 0s
CI / Deep Native Runtime Cases (5/6) (push) Has been skipped
CI / Deep Native Runtime Cases (6/6) (push) Has been skipped
CI / Deep Native Runtime Cases (4/6) (push) Has been skipped
CI / Deep Graph Build Perf (push) Has been skipped
CI / Deep Native Runtime Cases (1/6) (push) Has been skipped
CI / Native Preflight (push) Failing after 1s
CI / Native Runtime Cases (1/2) (push) Failing after 0s
CI / Native Runtime Cases (2/2) (push) Failing after 1s
CI / Native Metadata Reports (push) Failing after 0s
CI / Native Direct Backend Artifacts (push) Failing after 0s
CI / Native Sanitizer Smoke (push) Failing after 1s
CI / Command Contract Snapshots (push) Failing after 1s
CI / Deep Conformance Suite (push) Has been skipped
CI / Graph Build Perf (push) Failing after 1s
CI / Deep Native Preflight (push) Has been skipped
CI / Deep Native Runtime Cases (2/6) (push) Has been skipped
CI / Deep Native Runtime Cases (3/6) (push) Has been skipped
CI / Conformance Suite (push) Failing after 1s
CI / Workspace Checks (push) Failing after 0s
CI / Deep Native Runtime Cases (5/6) (push) Has been skipped
CI / Deep Native Runtime Cases (6/6) (push) Has been skipped
CI / Deep Native Runtime Cases (4/6) (push) Has been skipped
CI / Deep Graph Build Perf (push) Has been skipped
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
pub fn main(net: Net) -> Void {
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,21 @@
|
||||
pub fn main(world: World) -> Void raises {
|
||||
let values: [5]i32 = [7, 2, 10, 4, 1]
|
||||
var index: usize = 0
|
||||
var sum: i32 = 0
|
||||
var min: i32 = values[0]
|
||||
var max: i32 = values[0]
|
||||
while index < 5 {
|
||||
let value: i32 = values[index]
|
||||
sum = sum + value
|
||||
if value < min {
|
||||
min = value
|
||||
}
|
||||
if value > max {
|
||||
max = value
|
||||
}
|
||||
index = index + 1
|
||||
}
|
||||
if sum == 24 && min == 1 && max == 10 {
|
||||
check world.out.write("array sum min max ok\n")
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,15 @@
|
||||
pub fn main(world: World) -> Void raises {
|
||||
var bytes: [5]u8 = [97, 98, 99, 100, 101]
|
||||
var left: usize = 0
|
||||
var right: usize = 4
|
||||
while left < right {
|
||||
let saved: u8 = bytes[left]
|
||||
bytes[left] = bytes[right]
|
||||
bytes[right] = saved
|
||||
left = left + 1
|
||||
right = right - 1
|
||||
}
|
||||
if bytes[0] == 101 && bytes[1] == 100 && bytes[2] == 99 && bytes[3] == 98 && bytes[4] == 97 {
|
||||
check world.out.write("bytes reverse ok\n")
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,9 @@
|
||||
pub fn main(world: World) -> Void raises {
|
||||
let count: usize = std.args.len()
|
||||
let first: Maybe<String> = std.args.get(1)
|
||||
let missing: Maybe<String> = std.args.get(99)
|
||||
if count == 3 && first.has && !missing.has {
|
||||
check world.out.write(first.value)
|
||||
check world.out.write("\n")
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,23 @@
|
||||
pub fn main(world: World) -> Void raises {
|
||||
let text: String = "zero lang\ncommon test"
|
||||
var words: i32 = 0
|
||||
var lines: i32 = 1
|
||||
var inWord: Bool = false
|
||||
var index: usize = 0
|
||||
while index < 21 {
|
||||
let ch: u8 = text[index]
|
||||
if ch == 10 as u8 {
|
||||
lines = lines + 1
|
||||
}
|
||||
if ch == 32 as u8 || ch == 10 as u8 || ch == 9 as u8 {
|
||||
inWord = false
|
||||
} else if !inWord {
|
||||
words = words + 1
|
||||
inWord = true
|
||||
}
|
||||
index = index + 1
|
||||
}
|
||||
if words == 4 && lines == 2 {
|
||||
check world.out.write("count words lines ok\n")
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,15 @@
|
||||
fn factorial(n: u32) -> u32 {
|
||||
var value: u32 = 1
|
||||
var index: u32 = 2
|
||||
while index <= n {
|
||||
value = value * index
|
||||
index = index + 1
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
pub fn main(world: World) -> Void raises {
|
||||
if factorial(6) == 720 {
|
||||
check world.out.write("factorial ok\n")
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,18 @@
|
||||
fn fib(n: u32) -> u32 {
|
||||
var index: u32 = 0
|
||||
var a: u32 = 0
|
||||
var b: u32 = 1
|
||||
while index < n {
|
||||
let next: u32 = a + b
|
||||
a = b
|
||||
b = next
|
||||
index = index + 1
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
pub fn main(world: World) -> Void raises {
|
||||
if fib(10) == 55 {
|
||||
check world.out.write("fib iterative ok\n")
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,12 @@
|
||||
fn fib(n: u32) -> u32 {
|
||||
if n < 2 {
|
||||
return n
|
||||
}
|
||||
return fib(n - 1) + fib(n - 2)
|
||||
}
|
||||
|
||||
pub fn main(world: World) -> Void raises {
|
||||
if fib(10) == 55 {
|
||||
check world.out.write("fib recursive ok\n")
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,25 @@
|
||||
fn seedInput(fs: Fs) -> Bool {
|
||||
let created: Maybe<owned<File>> = std.fs.create(fs, ".zero/conformance/common-file-copy-input.txt")
|
||||
if created.has {
|
||||
var file: owned<File> = created.value
|
||||
return std.fs.writeAll(&mut file, std.mem.span("zero file copy\n"))
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
pub fn main(world: World) -> Void raises {
|
||||
let fs: Fs = std.fs.host()
|
||||
if seedInput(fs) {
|
||||
let input: Maybe<owned<File>> = std.fs.open(fs, ".zero/conformance/common-file-copy-input.txt")
|
||||
let output: Maybe<owned<File>> = std.fs.create(fs, ".zero/conformance/common-file-copy-output.txt")
|
||||
if input.has && output.has {
|
||||
var src: owned<File> = input.value
|
||||
var dst: owned<File> = output.value
|
||||
var buf: [15]u8 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||
let read: Maybe<usize> = std.fs.read(&mut src, buf)
|
||||
if read.has && read.value == 15 && std.fs.writeAll(&mut dst, buf) {
|
||||
check world.out.write("file copy ok\n")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,16 @@
|
||||
fn gcd(a: u32, b: u32) -> u32 {
|
||||
var left: u32 = a
|
||||
var right: u32 = b
|
||||
while right != 0 {
|
||||
let next: u32 = left % right
|
||||
left = right
|
||||
right = next
|
||||
}
|
||||
return left
|
||||
}
|
||||
|
||||
pub fn main(world: World) -> Void raises {
|
||||
if gcd(84, 30) == 6 {
|
||||
check world.out.write("gcd ok\n")
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,10 @@
|
||||
pub fn main(world: World) -> Void raises {
|
||||
var arenaBytes: [16]u8 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||
var arena: FixedBufAlloc = std.mem.fixedBufAlloc(arenaBytes)
|
||||
let parsed: Maybe<JsonDoc> = std.json.parse(arena, "{\"ok\":true}")
|
||||
var out: [16]u8 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
|
||||
let encoded: Maybe<String> = std.json.writeString(out, "zero")
|
||||
if std.json.validate("{\"ok\":true}") && parsed.has && encoded.has && std.mem.eql(encoded.value, "\"zero\"") {
|
||||
check world.out.write("json roundtrip ok\n")
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,9 @@
|
||||
pub fn main(world: World) -> Void raises {
|
||||
let yes: String = "level"
|
||||
let no: String = "zero"
|
||||
let yesOk: Bool = yes[0] == yes[4] && yes[1] == yes[3]
|
||||
let noOk: Bool = no[0] != no[3]
|
||||
if yesOk && noOk {
|
||||
check world.out.write("palindrome ok\n")
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,19 @@
|
||||
fn isPrime(n: u32) -> Bool {
|
||||
if n < 2 {
|
||||
return false
|
||||
}
|
||||
var divisor: u32 = 2
|
||||
while divisor * divisor <= n {
|
||||
if n % divisor == 0 {
|
||||
return false
|
||||
}
|
||||
divisor = divisor + 1
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
pub fn main(world: World) -> Void raises {
|
||||
if isPrime(2) && isPrime(29) && !isPrime(30) {
|
||||
check world.out.write("prime ok\n")
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,29 @@
|
||||
fn countPrimesThroughTen() -> i32 {
|
||||
var prime: [11]u8 = [0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1]
|
||||
var value: usize = 2
|
||||
while value < 11 {
|
||||
if prime[value] == 1 {
|
||||
var multiple: usize = value + value
|
||||
while multiple < 11 {
|
||||
prime[multiple] = 0
|
||||
multiple = multiple + value
|
||||
}
|
||||
}
|
||||
value = value + 1
|
||||
}
|
||||
var count: i32 = 0
|
||||
var index: usize = 0
|
||||
while index < 11 {
|
||||
if prime[index] == 1 {
|
||||
count = count + 1
|
||||
}
|
||||
index = index + 1
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
pub fn main(world: World) -> Void raises {
|
||||
if countPrimesThroughTen() == 4 {
|
||||
check world.out.write("sieve small ok\n")
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,23 @@
|
||||
pub fn main(world: World) -> Void raises {
|
||||
var values: [5]i32 = [5, 1, 4, 2, 3]
|
||||
var i: usize = 0
|
||||
while i < 5 {
|
||||
var min: usize = i
|
||||
var j: usize = i + 1
|
||||
while j < 5 {
|
||||
if values[j] < values[min] {
|
||||
min = j
|
||||
}
|
||||
j = j + 1
|
||||
}
|
||||
if min != i {
|
||||
let saved: i32 = values[i]
|
||||
values[i] = values[min]
|
||||
values[min] = saved
|
||||
}
|
||||
i = i + 1
|
||||
}
|
||||
if values[0] == 1 && values[1] == 2 && values[2] == 3 && values[3] == 4 && values[4] == 5 {
|
||||
check world.out.write("sort small ok\n")
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,14 @@
|
||||
pub fn main(world: World) -> Void raises {
|
||||
let text: String = "zero language"
|
||||
var index: usize = 0
|
||||
var found: i32 = -1
|
||||
while index < 13 {
|
||||
if text[index] == 108 as u8 && found == -1 {
|
||||
found = index as i32
|
||||
}
|
||||
index = index + 1
|
||||
}
|
||||
if found == 5 {
|
||||
check world.out.write("string search ok\n")
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,13 @@
|
||||
pub fn main(world: World) -> Void raises {
|
||||
var bytes: [9]u8 = [122, 101, 114, 111, 32, 108, 97, 110, 103]
|
||||
var index: usize = 0
|
||||
while index < 4 {
|
||||
let saved: u8 = bytes[index]
|
||||
bytes[index] = bytes[index + 5]
|
||||
bytes[index + 5] = saved
|
||||
index = index + 1
|
||||
}
|
||||
if bytes[0] == 108 as u8 && bytes[1] == 97 as u8 && bytes[2] == 110 as u8 && bytes[3] == 103 as u8 && bytes[4] == 32 as u8 && bytes[5] == 122 as u8 && bytes[6] == 101 as u8 && bytes[7] == 114 as u8 && bytes[8] == 111 as u8 {
|
||||
check world.out.write("word reverse ok\n")
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Reference in New Issue
Block a user