ocaml: phase 6 String/Char/Int/Float/Printf modules (+13 tests, 278 total)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 53s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 53s
Host primitives _string_length / _string_sub / _char_code / etc. exposed in the base env (underscore-prefixed to avoid user clash). lib/ocaml/ runtime.sx wraps them into OCaml-syntax modules: String (length, get, sub, concat, uppercase/lowercase_ascii, starts_with), Char (code, chr, lowercase/uppercase_ascii), Int (to_string, of_string, abs, max, min), Float.to_string, Printf stubs. Also added print_string / print_endline / print_int IO builtins.
This commit is contained in:
@@ -672,6 +672,36 @@ cat > "$TMPFILE" << 'EPOCHS'
|
||||
(epoch 913)
|
||||
(eval "(ocaml-type-of \"not true\")")
|
||||
|
||||
;; ── Phase 6 expanded: String / Char / Int / Float modules ─────
|
||||
(epoch 950)
|
||||
(eval "(ocaml-run \"String.length \\\"hello\\\"\")")
|
||||
(epoch 951)
|
||||
(eval "(ocaml-run \"String.uppercase_ascii \\\"hi\\\"\")")
|
||||
(epoch 952)
|
||||
(eval "(ocaml-run \"String.lowercase_ascii \\\"HI\\\"\")")
|
||||
(epoch 953)
|
||||
(eval "(ocaml-run \"String.sub \\\"hello\\\" 1 3\")")
|
||||
(epoch 954)
|
||||
(eval "(ocaml-run \"String.starts_with \\\"he\\\" \\\"hello\\\"\")")
|
||||
(epoch 955)
|
||||
(eval "(ocaml-run \"String.concat \\\",\\\" [\\\"a\\\"; \\\"b\\\"; \\\"c\\\"]\")")
|
||||
|
||||
(epoch 960)
|
||||
(eval "(ocaml-run \"Char.code \\\"A\\\"\")")
|
||||
(epoch 961)
|
||||
(eval "(ocaml-run \"Char.chr 65\")")
|
||||
|
||||
(epoch 970)
|
||||
(eval "(ocaml-run \"Int.to_string 42\")")
|
||||
(epoch 971)
|
||||
(eval "(ocaml-run \"Int.of_string \\\"123\\\"\")")
|
||||
(epoch 972)
|
||||
(eval "(ocaml-run \"Int.abs (-5)\")")
|
||||
(epoch 973)
|
||||
(eval "(ocaml-run \"Int.max 7 3\")")
|
||||
(epoch 974)
|
||||
(eval "(ocaml-run \"Int.min 7 3\")")
|
||||
|
||||
EPOCHS
|
||||
|
||||
OUTPUT=$(timeout 60 "$SX_SERVER" < "$TMPFILE" 2>/dev/null)
|
||||
@@ -1065,6 +1095,23 @@ check 911 "type twice" ' -> '
|
||||
check 912 "type bool branch" '"Bool -> Int"'
|
||||
check 913 "type not true" '"Bool"'
|
||||
|
||||
# ── Phase 6 String / Char / Int ─────────────────────────────────
|
||||
check 950 "String.length" '5'
|
||||
check 951 "String.uppercase_ascii" '"HI"'
|
||||
check 952 "String.lowercase_ascii" '"hi"'
|
||||
check 953 "String.sub" '"ell"'
|
||||
check 954 "String.starts_with" 'true'
|
||||
check 955 "String.concat" '"a,b,c"'
|
||||
|
||||
check 960 "Char.code A" '65'
|
||||
check 961 "Char.chr 65" '"A"'
|
||||
|
||||
check 970 "Int.to_string" '"42"'
|
||||
check 971 "Int.of_string" '123'
|
||||
check 972 "Int.abs -5" '5'
|
||||
check 973 "Int.max" '7'
|
||||
check 974 "Int.min" '3'
|
||||
|
||||
TOTAL=$((PASS + FAIL))
|
||||
if [ $FAIL -eq 0 ]; then
|
||||
echo "ok $PASS/$TOTAL OCaml-on-SX tests passed"
|
||||
|
||||
Reference in New Issue
Block a user