From 537f2b2b9887ea04ebd955d09f4cf2daa4fb2d5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Remko=20Tron=C3=A7on?= Date: Sun, 3 Jun 2018 21:49:59 +0200 Subject: [PATCH] Enable sieve tests --- tests/index.js | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/tests/index.js b/tests/index.js index b73480d..3c4c1c6 100644 --- a/tests/index.js +++ b/tests/index.js @@ -1,6 +1,7 @@ import WAForth from "../src/shell/WAForth"; import { mocha } from "mocha"; import { expect } from "chai"; +import sieve from "../src/shell/sieve"; mocha.setup("bdd"); describe("WAForth", () => { @@ -1227,29 +1228,20 @@ describe("WAForth", () => { }); describe("system", () => { - it.skip("should run sieve", () => { - run(` -: prime? HERE + C@ 0= ; -: composite! HERE + 1 SWAP C! ; + beforeEach(() => { + core.loadPrelude(); + }); -: sieve - HERE OVER ERASE - 2 - BEGIN - 2DUP DUP * > - WHILE - DUP prime? IF - 2DUP DUP * DO - I composite! - DUP +LOOP - THEN - 1+ - REPEAT - DROP - ." Primes: " 2 DO I prime? IF I . THEN LOOP -;`); - run("10 sieve"); - expect(output).to.eql(""); + it("should run sieve", () => { + run(sieve); + run("100 sieve"); + expect(output.trim()).to.eql("97"); + }); + + it("should run direct sieve", () => { + run(sieve); + run("100 sieve_direct"); + expect(stack[0]).to.eql(97); }); }); });