diff --git a/core/math.ktt b/core/math.ktt index 3de2f7d..a3d88d4 100644 --- a/core/math.ktt +++ b/core/math.ktt @@ -89,6 +89,7 @@ Object extend: Fixnum With: { sqrt = { (self _FixnumToFloat) sqrt }. sin = { MathFFI sin: (self _FixnumToFloat) }. cos = { MathFFI cos: (self _FixnumToFloat) }. + asComplex = { Complex clone setRe: self Im: 0 }. toString = { self _FixnumToString }. toStringRadix: r = { self _FixnumToStringRadix: r }. @@ -164,6 +165,7 @@ Object extend: Bignum With: { neg = { self _BignumNeg }. sqrt = { (self _BignumToFloat) sqrt }. + asComplex = { Complex clone setRe: self Im: 0 }. eqFixnum: lhs = { (lhs _FixnumToBignum) _BignumEq: self }. neFixnum: lhs = { (lhs _FixnumToBignum) _BignumNe: self }. @@ -234,6 +236,7 @@ Object extend: Ratio With: { neg = { self _RatioNeg }. sqrt = { (self _RatioToFloat) sqrt }. + asComplex = { Complex clone setRe: self Im: 0 }. eqFixnum: lhs = { (lhs _FixnumToRatio) _RatioEq: self }. neFixnum: lhs = { (lhs _FixnumToRatio) _RatioNe: self }. @@ -339,6 +342,7 @@ Object extend: Float With: { geFloat: lhs = { lhs _FloatGe: self }. neg = { self _FloatNeg }. + asComplex = { Complex clone setRe: self Im: 0 }. sin = { MathFFI sin: self }. cos = { MathFFI cos: self }. toString = { self _FloatToString }. diff --git a/run_tests.py b/run_tests.py index 08cdc3d..ac90937 100644 --- a/run_tests.py +++ b/run_tests.py @@ -16,13 +16,13 @@ SYSTEM_INIT = "core/system.ktt" OS_INIT = "core/os.ktt" def build_command(debug: bool) -> list[str]: - cmd = ["cargo", "build", "--bin", "kette"] + cmd = ["cargo", "build", "--bin", "vm"] if not debug: cmd.append("--release") return cmd def run_command(debug: bool) -> list[str]: - cmd = ["cargo", "run", "--bin", "kette"] + cmd = ["cargo", "run", "--bin", "vm"] if not debug: cmd.append("--release") cmd.extend([ diff --git a/tests/disposable_using.ktt b/tests/disposable_using.ktt index 8c0f1df..1f8ec1f 100644 --- a/tests/disposable_using.ktt +++ b/tests/disposable_using.ktt @@ -1,3 +1,6 @@ +// expect: +// disposable-using: ok + Module open: 'Test::DisposableUsing. Module use: 'OS. diff --git a/tests/file_disposable.ktt b/tests/file_disposable.ktt index e3c0ac1..fa92e55 100644 --- a/tests/file_disposable.ktt +++ b/tests/file_disposable.ktt @@ -1,3 +1,9 @@ +// expect: +// 9326 +// 9326 +// 56 +// file-disposable: ok + Module open: 'Test::FileDisposable. Module use: 'System & 'OS. diff --git a/tests/init_runtime_demo.ktt b/tests/init_runtime_demo.ktt index a33690a..b882659 100644 --- a/tests/init_runtime_demo.ktt +++ b/tests/init_runtime_demo.ktt @@ -1,3 +1,17 @@ +// expect: +// Reading: core/init.ktt (Size: 9326): +// VM _ModuleOpen: 'Core. +// +// 54 +// incredible +// Module demo start +// 45 +// 42 +// 3 +// 42 +// Module demo end +// App + Module open: 'Test::RuntimeDemo. Module use: 'System. Module use: 'OS. @@ -8,7 +22,7 @@ Module use: 'OS. eachLine: [ | line | line println ] - First: 3 + First: 2 ]. NewGlobal := None. diff --git a/tests/linked_list_chasing.ktt b/tests/linked_list_chasing.ktt index 646fa67..4e39559 100644 --- a/tests/linked_list_chasing.ktt +++ b/tests/linked_list_chasing.ktt @@ -1,3 +1,5 @@ +// expect: + Module open: 'LinkedListChasing. Module use: 'Collections. diff --git a/tests/mitternacht.ktt b/tests/mitternacht.ktt index 0dceb47..b66d3ba 100644 --- a/tests/mitternacht.ktt +++ b/tests/mitternacht.ktt @@ -1,14 +1,19 @@ +// expect: +// -1 + 1i +// -1 - 1i + Module open: 'Test::Mitternacht. +Module use: 'Math. -Math = { - rootsOfA: a B: b C: c = { +Quadratic = { + printRootsOfA: a B: b C: c = { disc = (b * b) - (4 * a * c). sqrtDisc = disc sqrt. denom = 2 * a. - root1 = ((0 - b) + sqrtDisc) / denom. - root2 = ((0 - b) - sqrtDisc) / denom. - { root1. root2 } + negB = 0 - b. + ((negB + sqrtDisc) / denom) toString println. + ((negB - sqrtDisc) / denom) toString println. }. }. -res = Math rootsOfA: 1 B: 2 C: 2 +Quadratic printRootsOfA: 1 B: 2 C: 2. diff --git a/tests/proxy_ctype_accessors.ktt b/tests/proxy_ctype_accessors.ktt index d0e730f..7e4b999 100644 --- a/tests/proxy_ctype_accessors.ktt +++ b/tests/proxy_ctype_accessors.ktt @@ -1,3 +1,6 @@ +// expect: +// proxy-ctype-accessors: ok + Module open: 'Test::ProxyCTypeAccessors. Module use: 'Alien & 'System. diff --git a/tests/proxy_ctype_nested_struct.ktt b/tests/proxy_ctype_nested_struct.ktt index 9acff0a..9273cdc 100644 --- a/tests/proxy_ctype_nested_struct.ktt +++ b/tests/proxy_ctype_nested_struct.ktt @@ -1,3 +1,6 @@ +// expect: +// proxy-ctype-nested-struct: ok + Module open: 'Test::ProxyCTypeNestedStruct. Module use: 'Alien.