Closed
Description
Don't work on this issue until #895 is merged, or use that PR as a base branch.
The exercise forth has two new test cases that are not implemented. Your mission, should you accept it, is to change the example.js
implementation so that these two tests would pass. The current example.js
implementation has lazy evaluation but no special handling for "rebinding" words.
Instructions
Flip the following test from false
to true
:
# can use different words with the same name
"ac12aaaf-26c6-4a10-8b3c-1c958fa2914c" = false
Add the following test to the .spec.js
xtest('can use different words with the same name', () => {
forth.evaluate(': foo 5 ;');
forth.evaluate(': bar foo ;');
forth.evaluate(': foo 6 ;');
forth.evaluate('bar foo');
expect(forth.stack).toEqual([5, 6]);
});
Flip the following test from false
to true
:
# can define word that uses word with the same name
"53f82ef0-2750-4ccb-ac04-5d8c1aefabb1" = false
Add the following test to the .spec.js
xtest('can define word that uses word with the same name', () => {
forth.evaluate(': foo 10 ;');
forth.evaluate(': foo foo 1 + ;');
forth.evaluate('foo');
expect(forth.stack).toEqual([11]);
});
Make sure the PR CI passes:
npx babel-node scripts/pr exercises/forth
# Or alternatively
ASSIGNMENT=forth npx babel-node scripts/test