1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

freestanding improvements (exit, function checks)

Fixed exit for freestanding (as assert now uses it).
Running each function check now in a forked process so they can be killed or return other exit codes (and so each function runs, even if others crash)
This commit is contained in:
bogen85
2019-12-07 13:25:19 -06:00
committed by Alexander Medvednikov
parent d73586743b
commit 751ba48bf5
8 changed files with 127 additions and 85 deletions

View File

@@ -1,16 +1,17 @@
module main
__global buffer [128]byte
import forkedtest
fn check_string_eq () {
println ("checking string_eq")
assert "monkey" != "rat"
some_animal := "a bird"
assert some_animal == "a bird"
println ("string_eq passed")
}
fn check_i64_tos() {
buffer, e := mm_alloc(128)
assert e == .enoerror
assert !isnil(buffer)
s0 := i64_tos(buffer, 70, 140, 10)
assert s0 == "140"
@@ -22,11 +23,15 @@ fn check_i64_tos() {
s3 := i64_tos(buffer, 70, -160000, 10)
assert s3 == "-160000"
assert mm_free(buffer) == .enoerror
}
fn main () {
check_string_eq ()
check_i64_tos()
mut fails := 0
fails += forkedtest.normal_run(check_string_eq, "check_string_eq")
fails += forkedtest.normal_run(check_i64_tos, "check_i64_tos")
assert fails == 0
sys_exit(0)
}