std/ tree, use (import) and class syntax
- std/ layout: std/lang/{lexer,parser,checker,compiler}.cat moved from src/catscript
- std/io/io.cat, std/fs/fs.cat, std/math/math.cat modules
- use "path.cat": import another unit (compile+run in the same VM)
- class NAME [extends BASE] ... end: methods, inheritance via __index,
default new constructor (runs optional init), tables are callable
- examples/classes.cat, tests/std.cat; 48/48 tests
This commit is contained in:
1 parent
3c20496c78
commit
ef305e7824
19 files changed
+370
-9
No files matched your search
@@ -90,6 +90,22 @@ check "slot-path" "path: /tmp/catscript_slots_demo.txt" "`echo "$out" | sed -n 1
|
||||
check "slot-mode" "mode: 2" "`echo "$out" | sed -n 2p`"
|
||||
check "slot-closed" "closed: false" "`echo "$out" | sed -n 3p`"
|
||||
check "slot-closed-2" "closed: true" "`echo "$out" | sed -n 4p`"
|
||||
|
||||
# ---- class / extends / use (import) ---------------------------------
|
||||
|
||||
out=`$BIN examples/classes.cat`
|
||||
check "class-method" "cat makes a sound" "`echo "$out" | sed -n 1p`"
|
||||
check "class-attr" "cat" "`echo "$out" | sed -n 2p`"
|
||||
check "class-override" "Rex barks" "`echo "$out" | sed -n 3p`"
|
||||
check "class-inherit" "Rex" "`echo "$out" | sed -n 4p`"
|
||||
check "class-use" "double 21 = 42" "`echo "$out" | sed -n 5p`"
|
||||
|
||||
# ---- std/ tree modules (use "std/...") -------------------------------
|
||||
|
||||
out=`$BIN tests/std.cat`
|
||||
check "std-math" "math double: 42" "`echo "$out" | sed -n 1p`"
|
||||
check "std-io" "io join: a-b-c" "`echo "$out" | sed -n 4p`"
|
||||
check "std-fs" "fs copy: true" "`echo "$out" | sed -n 6p`"
|
||||
# ---- bytecode dump ---------------------------------------------------
|
||||
|
||||
out=`$BIN --dump examples/hello.cat`
|
||||
|
||||
Reference in new issue
Block a user