mirror of
https://github.com/remko/waforth
synced 2025-02-05 20:46:22 +01:00
Implement [CHAR]
This commit is contained in:
parent
f17dac3e09
commit
779945c306
2 changed files with 26 additions and 0 deletions
|
@ -1201,6 +1201,12 @@
|
|||
(call $compilePushConst (call $pop)))
|
||||
(!def_word "[']" "$bracket-tick" !fImmediate)
|
||||
|
||||
;; 6.1.2520
|
||||
(func $bracket-char
|
||||
(call $CHAR)
|
||||
(call $compilePushConst (call $pop)))
|
||||
(!def_word "[CHAR]" "$bracket-char" !fImmediate)
|
||||
|
||||
;; 6.1.2540
|
||||
(func $right-bracket
|
||||
(i32.store (i32.const !stateBase) (i32.const 1)))
|
||||
|
|
|
@ -778,6 +778,26 @@ function loadTests(wasmModule, arrayToBase64) {
|
|||
});
|
||||
});
|
||||
|
||||
describe("[CHAR]", () => {
|
||||
it("should work with a single character", () => {
|
||||
run(": FOO [CHAR] A 5 ;");
|
||||
run("4 FOO 6");
|
||||
expect(stack[0]).to.eql(4);
|
||||
expect(stack[1]).to.eql(65);
|
||||
expect(stack[2]).to.eql(5);
|
||||
expect(stack[3]).to.eql(6);
|
||||
});
|
||||
|
||||
it("should work with multiple characters", () => {
|
||||
run(": FOO [CHAR] ABC 5 ;");
|
||||
run("4 FOO 6");
|
||||
expect(stack[0]).to.eql(4);
|
||||
expect(stack[1]).to.eql(65);
|
||||
expect(stack[2]).to.eql(5);
|
||||
expect(stack[3]).to.eql(6);
|
||||
});
|
||||
});
|
||||
|
||||
// describe("word", () => {
|
||||
// it("should read a word", () => {
|
||||
// forth.read(" FOO BAR BAZ ");
|
||||
|
|
Loading…
Add table
Reference in a new issue