-
-
Notifications
You must be signed in to change notification settings - Fork 159
wordy: update to latest #745
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
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| (ns wordy-generator) | ||
|
|
||
| (defn transform-test-case [test-case] | ||
| (if (= "Non math question" (:description test-case)) | ||
| (assoc-in test-case [:expected :error] "syntax error") | ||
| test-case)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| (ns wordy-test | ||
| (:require [clojure.test :refer [deftest testing is]] | ||
| wordy)) | ||
| {{#test_cases.answer}} | ||
| (deftest evaluate_test_{{idx}} | ||
| (testing {{description}} | ||
| {{~#if error}} | ||
| (is (thrown-with-msg? IllegalArgumentException #{{error}} (wordy/evaluate {{input.question}}))))) | ||
| {{else}} | ||
| (is (= {{expected}} (wordy/evaluate {{input.question}}))))) | ||
| {{/if~}} | ||
| {{/test_cases.answer~}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,7 @@ | ||
| (ns wordy) | ||
|
|
||
| (defn evaluate [] ;; <- arglist goes here | ||
| ;; your code goes here | ||
| ) | ||
| (defn evaluate | ||
| "Evaluate a simple math problem" | ||
| [question] | ||
| ;; function body | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,56 +1,96 @@ | ||
| (ns wordy-test | ||
| (:require [clojure.test :refer [deftest is]] | ||
| (:require [clojure.test :refer [deftest testing is]] | ||
| wordy)) | ||
|
|
||
| (deftest addition | ||
| (is (= (wordy/evaluate "What is 1 plus 1?") 2))) | ||
|
|
||
| (deftest more-addition | ||
| (is (= (wordy/evaluate "What is 53 plus 2?") 55))) | ||
|
|
||
| (deftest addition-with-negative-numbers | ||
| (is (= (wordy/evaluate "What is -1 plus -10?") -11))) | ||
|
|
||
| (deftest large-addition | ||
| (is (= (wordy/evaluate "What is 123 plus 45678?") 45801))) | ||
|
|
||
| (deftest subtraction | ||
| (is (= (wordy/evaluate "What is 4 minus -12?") 16))) | ||
|
|
||
| (deftest multiplication | ||
| (is (= (wordy/evaluate "What is -3 multiplied by 25?") -75))) | ||
|
|
||
| (deftest division | ||
| (is (= (wordy/evaluate "What is 33 divided by -3?") -11))) | ||
|
|
||
| (deftest multiple-additions | ||
| (is (= (wordy/evaluate "What is 1 plus 1 plus 1?") 3))) | ||
|
|
||
| (deftest addition-and-subtraction | ||
| (is (= (wordy/evaluate "What is 1 plus 5 minus -2?") 8))) | ||
|
|
||
| (deftest multiple-subtraction | ||
| (is (= (wordy/evaluate "What is 20 minus 4 minus 13?") 3))) | ||
|
|
||
| (deftest subtraction-then-addition | ||
| (is (= (wordy/evaluate "What is 17 minus 6 plus 3?") 14))) | ||
|
|
||
| (deftest multiple-multiplication | ||
| (is (= (wordy/evaluate "What is 2 multiplied by -2 multiplied by 3?") -12))) | ||
|
|
||
| (deftest addition-and-multiplication | ||
| (is (= (wordy/evaluate "What is -3 plus 7 multiplied by -2?") -8))) | ||
|
|
||
| (deftest multiple-division | ||
| (is (= (wordy/evaluate "What is -12 divided by 2 divided by -3?") 2))) | ||
|
|
||
| (deftest unknown-operation | ||
| (is (thrown? | ||
| IllegalArgumentException | ||
| (wordy/evaluate "What is 52 cubed?")))) | ||
|
|
||
| (deftest Non-math-question | ||
| (is (thrown? | ||
| IllegalArgumentException | ||
| (wordy/evaluate "Who is the President of the United States?")))) | ||
|
|
||
| (deftest evaluate_test_1 | ||
| (testing "just a number" | ||
| (is (= 5 (wordy/evaluate "What is 5?"))))) | ||
|
|
||
| (deftest evaluate_test_2 | ||
| (testing "addition" | ||
| (is (= 2 (wordy/evaluate "What is 1 plus 1?"))))) | ||
|
|
||
| (deftest evaluate_test_3 | ||
| (testing "more addition" | ||
| (is (= 55 (wordy/evaluate "What is 53 plus 2?"))))) | ||
|
|
||
| (deftest evaluate_test_4 | ||
| (testing "addition with negative numbers" | ||
| (is (= -11 (wordy/evaluate "What is -1 plus -10?"))))) | ||
|
|
||
| (deftest evaluate_test_5 | ||
| (testing "large addition" | ||
| (is (= 45801 (wordy/evaluate "What is 123 plus 45678?"))))) | ||
|
|
||
| (deftest evaluate_test_6 | ||
| (testing "subtraction" | ||
| (is (= 16 (wordy/evaluate "What is 4 minus -12?"))))) | ||
|
|
||
| (deftest evaluate_test_7 | ||
| (testing "multiplication" | ||
| (is (= -75 (wordy/evaluate "What is -3 multiplied by 25?"))))) | ||
|
|
||
| (deftest evaluate_test_8 | ||
| (testing "division" | ||
| (is (= -11 (wordy/evaluate "What is 33 divided by -3?"))))) | ||
|
|
||
| (deftest evaluate_test_9 | ||
| (testing "multiple additions" | ||
| (is (= 3 (wordy/evaluate "What is 1 plus 1 plus 1?"))))) | ||
|
|
||
| (deftest evaluate_test_10 | ||
| (testing "addition and subtraction" | ||
| (is (= 8 (wordy/evaluate "What is 1 plus 5 minus -2?"))))) | ||
|
|
||
| (deftest evaluate_test_11 | ||
| (testing "multiple subtraction" | ||
| (is (= 3 (wordy/evaluate "What is 20 minus 4 minus 13?"))))) | ||
|
|
||
| (deftest evaluate_test_12 | ||
| (testing "subtraction then addition" | ||
| (is (= 14 (wordy/evaluate "What is 17 minus 6 plus 3?"))))) | ||
|
|
||
| (deftest evaluate_test_13 | ||
| (testing "multiple multiplication" | ||
| (is (= -12 (wordy/evaluate "What is 2 multiplied by -2 multiplied by 3?"))))) | ||
|
|
||
| (deftest evaluate_test_14 | ||
| (testing "addition and multiplication" | ||
| (is (= -8 (wordy/evaluate "What is -3 plus 7 multiplied by -2?"))))) | ||
|
|
||
| (deftest evaluate_test_15 | ||
| (testing "multiple division" | ||
| (is (= 2 (wordy/evaluate "What is -12 divided by 2 divided by -3?"))))) | ||
|
|
||
| (deftest evaluate_test_16 | ||
| (testing "unknown operation" | ||
| (is (thrown-with-msg? IllegalArgumentException #"unknown operation" (wordy/evaluate "What is 52 cubed?"))))) | ||
|
|
||
| (deftest evaluate_test_17 | ||
| (testing "Non math question" | ||
| (is (thrown-with-msg? IllegalArgumentException #"syntax error" (wordy/evaluate "Who is the President of the United States?"))))) | ||
|
|
||
| (deftest evaluate_test_18 | ||
| (testing "reject problem missing an operand" | ||
| (is (thrown-with-msg? IllegalArgumentException #"syntax error" (wordy/evaluate "What is 1 plus?"))))) | ||
|
|
||
| (deftest evaluate_test_19 | ||
| (testing "reject problem with no operands or operators" | ||
| (is (thrown-with-msg? IllegalArgumentException #"syntax error" (wordy/evaluate "What is?"))))) | ||
|
|
||
| (deftest evaluate_test_20 | ||
| (testing "reject two operations in a row" | ||
| (is (thrown-with-msg? IllegalArgumentException #"syntax error" (wordy/evaluate "What is 1 plus plus 2?"))))) | ||
|
|
||
| (deftest evaluate_test_21 | ||
| (testing "reject two numbers in a row" | ||
| (is (thrown-with-msg? IllegalArgumentException #"syntax error" (wordy/evaluate "What is 1 plus 2 1?"))))) | ||
|
|
||
| (deftest evaluate_test_22 | ||
| (testing "reject postfix notation" | ||
| (is (thrown-with-msg? IllegalArgumentException #"syntax error" (wordy/evaluate "What is 1 2 plus?"))))) | ||
|
|
||
| (deftest evaluate_test_23 | ||
| (testing "reject prefix notation" | ||
| (is (thrown-with-msg? IllegalArgumentException #"syntax error" (wordy/evaluate "What is plus 1 2?"))))) | ||
|
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.