Skip to content

Sync and reformat wordy tests #382

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

Merged
merged 1 commit into from
Jul 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions exercises/practice/wordy/.meta/tests.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,21 @@
[88bf4b28-0de3-4883-93c7-db1b14aa806e]
description = "just a number"

[18983214-1dfc-4ebd-ac77-c110dde699ce]
description = "just a zero"

[607c08ee-2241-4288-916d-dae5455c87e6]
description = "just a negative number"

[bb8c655c-cf42-4dfc-90e0-152fcfd8d4e0]
description = "addition"

[bb9f2082-171c-46ad-ad4e-c3f72087c1b5]
description = "addition with a left hand zero"

[6fa05f17-405a-4742-80ae-5d1a8edb0d5d]
description = "addition with a right hand zero"

[79e49e06-c5ae-40aa-a352-7a3a01f70015]
description = "more addition"

Expand Down
85 changes: 50 additions & 35 deletions exercises/practice/wordy/wordy.spec.coffee
Original file line number Diff line number Diff line change
@@ -1,95 +1,110 @@
WordProblem = require './wordy'

describe 'Word Problem', ->

describe 'Wordy', ->
it 'just a number', ->
problem = new WordProblem('What is 5?')
problem = new WordProblem 'What is 5?'
expect(problem.answer()).toEqual 5

xit 'just a zero', ->
problem = new WordProblem 'What is 0?'
expect(problem.answer()).toEqual 0

xit 'just a negative number', ->
problem = new WordProblem 'What is -123?'
expect(problem.answer()).toEqual -123

xit 'addition', ->
problem = new WordProblem('What is 1 plus 1?')
problem = new WordProblem 'What is 1 plus 1?'
expect(problem.answer()).toEqual 2

xit 'addition with a left hand zero', ->
problem = new WordProblem 'What is 0 plus 2?'
expect(problem.answer()).toEqual 2

xit 'addition with a right hand zero', ->
problem = new WordProblem 'What is 3 plus 0?'
expect(problem.answer()).toEqual 3

xit 'more addition', ->
problem = new WordProblem('What is 53 plus 2?')
problem = new WordProblem 'What is 53 plus 2?'
expect(problem.answer()).toEqual 55

xit 'addition with negative numbers', ->
problem = new WordProblem('What is -1 plus -10?')
problem = new WordProblem 'What is -1 plus -10?'
expect(problem.answer()).toEqual -11

xit 'large addition', ->
problem = new WordProblem('What is 123 plus 45678?')
problem = new WordProblem 'What is 123 plus 45678?'
expect(problem.answer()).toEqual 45801

xit 'subtraction', ->
problem = new WordProblem('What is 4 minus -12?')
problem = new WordProblem 'What is 4 minus -12?'
expect(problem.answer()).toEqual 16

xit 'multiplication', ->
problem = new WordProblem('What is -3 multiplied by 25?')
problem = new WordProblem 'What is -3 multiplied by 25?'
expect(problem.answer()).toEqual -75

xit 'division', ->
problem = new WordProblem('What is 33 divided by -3?')
problem = new WordProblem 'What is 33 divided by -3?'
expect(problem.answer()).toEqual -11

xit 'multiple additions', ->
problem = new WordProblem('What is 1 plus 1 plus 1?')
problem = new WordProblem 'What is 1 plus 1 plus 1?'
expect(problem.answer()).toEqual 3

xit 'addition and subtraction', ->
problem = new WordProblem('What is 1 plus 5 minus -2?')
problem = new WordProblem 'What is 1 plus 5 minus -2?'
expect(problem.answer()).toEqual 8

xit 'multiple subtraction', ->
problem = new WordProblem('What is 20 minus 4 minus 13?')
problem = new WordProblem 'What is 20 minus 4 minus 13?'
expect(problem.answer()).toEqual 3

xit 'subtraction then addition', ->
problem = new WordProblem('What is 17 minus 6 plus 3?')
problem = new WordProblem 'What is 17 minus 6 plus 3?'
expect(problem.answer()).toEqual 14

xit 'multiple multiplication', ->
problem = new WordProblem('What is 2 multiplied by -2 multiplied by 3?')
problem = new WordProblem 'What is 2 multiplied by -2 multiplied by 3?'
expect(problem.answer()).toEqual -12

xit 'addition and multiplication', ->
problem = new WordProblem('What is -3 plus 7 multiplied by -2?')
problem = new WordProblem 'What is -3 plus 7 multiplied by -2?'
expect(problem.answer()).toEqual -8

xit 'multiple division', ->
problem = new WordProblem('What is -12 divided by 2 divided by -3?')
problem = new WordProblem 'What is -12 divided by 2 divided by -3?'
expect(problem.answer()).toEqual 2

xit 'unknown operation', ->
problem = new WordProblem('What is 52 cubed?')
expect(-> problem.answer()).toThrow(problem.ERROR.unknownOperation)
problem = new WordProblem 'What is 52 cubed?'
expect(-> problem.answer()).toThrow problem.ERROR.unknownOperation

xit 'Non math question', ->
problem = new WordProblem('Who is the president of the United States?')
expect(-> problem.answer()).toThrow(problem.ERROR.unknownOperation)
xit 'non-math question', ->
problem = new WordProblem 'Who is the president of the Unxited States?'
expect(-> problem.answer()).toThrow problem.ERROR.unknownOperation

xit 'reject problem missing an operand', ->
problem = new WordProblem('What is 1 plus?')
expect(-> problem.answer()).toThrow(problem.ERROR.syntaxError)
problem = new WordProblem 'What is 1 plus?'
expect(-> problem.answer()).toThrow problem.ERROR.syntaxError

xit 'reject problem with no operands or operators', ->
problem = new WordProblem('What is?')
expect(-> problem.answer()).toThrow(problem.ERROR.syntaxError)
xit 'reject problem wxith no operands or operators', ->
problem = new WordProblem 'What is?'
expect(-> problem.answer()).toThrow problem.ERROR.syntaxError

xit 'reject two operations in a row', ->
problem = new WordProblem('What is 1 plus plus 2?')
expect(-> problem.answer()).toThrow(problem.ERROR.syntaxError)
problem = new WordProblem 'What is 1 plus plus 2?'
expect(-> problem.answer()).toThrow problem.ERROR.syntaxError

xit 'reject two numbers in a row', ->
problem = new WordProblem('What is 1 plus 2 1?')
expect(-> problem.answer()).toThrow(problem.ERROR.syntaxError)
problem = new WordProblem 'What is 1 plus 2 1?'
expect(-> problem.answer()).toThrow problem.ERROR.syntaxError

xit 'reject postfix notation', ->
problem = new WordProblem('What is 1 2 plus?')
expect(-> problem.answer()).toThrow(problem.ERROR.syntaxError)
problem = new WordProblem 'What is 1 2 plus?'
expect(-> problem.answer()).toThrow problem.ERROR.syntaxError

xit 'reject prefix notation', ->
problem = new WordProblem('What is plus 1 2?')
expect(-> problem.answer()).toThrow(problem.ERROR.syntaxError)
problem = new WordProblem 'What is plus 1 2?'
expect(-> problem.answer()).toThrow problem.ERROR.syntaxError