From f17dac3e0970de191d253cdf7931ad628d0d284e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= Date: Mon, 11 Mar 2019 13:41:26 +0100 Subject: [PATCH] Implement ['] --- src/waforth.wat | 6 ++++++ tests/tests.js | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/src/waforth.wat b/src/waforth.wat index 1d4382c..57defce 100644 --- a/src/waforth.wat +++ b/src/waforth.wat @@ -1195,6 +1195,12 @@ (i32.store (i32.const !stateBase) (i32.const 0))) (!def_word "[" "$left-bracket" !fImmediate) + ;; 6.1.2510 + (func $bracket-tick + (call $tick) + (call $compilePushConst (call $pop))) + (!def_word "[']" "$bracket-tick" !fImmediate) + ;; 6.1.2540 (func $right-bracket (i32.store (i32.const !stateBase) (i32.const 1))) diff --git a/tests/tests.js b/tests/tests.js index 46686e6..b7ad973 100644 --- a/tests/tests.js +++ b/tests/tests.js @@ -1264,6 +1264,23 @@ function loadTests(wasmModule, arrayToBase64) { }); }); + describe("[']", () => { + beforeEach(() => { + core.loadPrelude(); + }); + + it("should work", () => { + run(': HELLO ." Hello " ;'); + run(': GOODBYE ." Goodbye " ;'); + run("VARIABLE 'aloha ' HELLO 'aloha !"); + run(": ALOHA 'aloha @ EXECUTE ;"); + run(": GOING ['] GOODBYE 'aloha ! ;"); + run("GOING"); + run("ALOHA"); + expect(output.trim()).to.eql("Goodbye"); + }); + }); + describe("system", () => { beforeEach(() => { core.loadPrelude();