Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

forth: implement two new tests #896

Closed
SleeplessByte opened this issue Dec 17, 2020 · 2 comments
Closed

forth: implement two new tests #896

SleeplessByte opened this issue Dec 17, 2020 · 2 comments

Comments

@SleeplessByte
Copy link
Member

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
@slaymance
Copy link
Contributor

Addressed in PR 934.

@SleeplessByte
Copy link
Member Author

Closed by #934

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants