1
1
(ns wordy-test
2
- (:require [clojure.test :refer [deftest is]]
2
+ (:require [clojure.test :refer [deftest testing is]]
3
3
wordy))
4
4
5
- (deftest addition
6
- (is (= (wordy/evaluate " What is 1 plus 1?" ) 2 )))
7
-
8
- (deftest more-addition
9
- (is (= (wordy/evaluate " What is 53 plus 2?" ) 55 )))
10
-
11
- (deftest addition-with-negative-numbers
12
- (is (= (wordy/evaluate " What is -1 plus -10?" ) -11 )))
13
-
14
- (deftest large-addition
15
- (is (= (wordy/evaluate " What is 123 plus 45678?" ) 45801 )))
16
-
17
- (deftest subtraction
18
- (is (= (wordy/evaluate " What is 4 minus -12?" ) 16 )))
19
-
20
- (deftest multiplication
21
- (is (= (wordy/evaluate " What is -3 multiplied by 25?" ) -75 )))
22
-
23
- (deftest division
24
- (is (= (wordy/evaluate " What is 33 divided by -3?" ) -11 )))
25
-
26
- (deftest multiple-additions
27
- (is (= (wordy/evaluate " What is 1 plus 1 plus 1?" ) 3 )))
28
-
29
- (deftest addition-and-subtraction
30
- (is (= (wordy/evaluate " What is 1 plus 5 minus -2?" ) 8 )))
31
-
32
- (deftest multiple-subtraction
33
- (is (= (wordy/evaluate " What is 20 minus 4 minus 13?" ) 3 )))
34
-
35
- (deftest subtraction-then-addition
36
- (is (= (wordy/evaluate " What is 17 minus 6 plus 3?" ) 14 )))
37
-
38
- (deftest multiple-multiplication
39
- (is (= (wordy/evaluate " What is 2 multiplied by -2 multiplied by 3?" ) -12 )))
40
-
41
- (deftest addition-and-multiplication
42
- (is (= (wordy/evaluate " What is -3 plus 7 multiplied by -2?" ) -8 )))
43
-
44
- (deftest multiple-division
45
- (is (= (wordy/evaluate " What is -12 divided by 2 divided by -3?" ) 2 )))
46
-
47
- (deftest unknown-operation
48
- (is (thrown?
49
- IllegalArgumentException
50
- (wordy/evaluate " What is 52 cubed?" ))))
51
-
52
- (deftest Non-math-question
53
- (is (thrown?
54
- IllegalArgumentException
55
- (wordy/evaluate " Who is the President of the United States?" ))))
56
-
5
+ (deftest evaluate_test_1
6
+ (testing " just a number"
7
+ (is (= 5 (wordy/evaluate " What is 5?" )))))
8
+
9
+ (deftest evaluate_test_2
10
+ (testing " addition"
11
+ (is (= 2 (wordy/evaluate " What is 1 plus 1?" )))))
12
+
13
+ (deftest evaluate_test_3
14
+ (testing " more addition"
15
+ (is (= 55 (wordy/evaluate " What is 53 plus 2?" )))))
16
+
17
+ (deftest evaluate_test_4
18
+ (testing " addition with negative numbers"
19
+ (is (= -11 (wordy/evaluate " What is -1 plus -10?" )))))
20
+
21
+ (deftest evaluate_test_5
22
+ (testing " large addition"
23
+ (is (= 45801 (wordy/evaluate " What is 123 plus 45678?" )))))
24
+
25
+ (deftest evaluate_test_6
26
+ (testing " subtraction"
27
+ (is (= 16 (wordy/evaluate " What is 4 minus -12?" )))))
28
+
29
+ (deftest evaluate_test_7
30
+ (testing " multiplication"
31
+ (is (= -75 (wordy/evaluate " What is -3 multiplied by 25?" )))))
32
+
33
+ (deftest evaluate_test_8
34
+ (testing " division"
35
+ (is (= -11 (wordy/evaluate " What is 33 divided by -3?" )))))
36
+
37
+ (deftest evaluate_test_9
38
+ (testing " multiple additions"
39
+ (is (= 3 (wordy/evaluate " What is 1 plus 1 plus 1?" )))))
40
+
41
+ (deftest evaluate_test_10
42
+ (testing " addition and subtraction"
43
+ (is (= 8 (wordy/evaluate " What is 1 plus 5 minus -2?" )))))
44
+
45
+ (deftest evaluate_test_11
46
+ (testing " multiple subtraction"
47
+ (is (= 3 (wordy/evaluate " What is 20 minus 4 minus 13?" )))))
48
+
49
+ (deftest evaluate_test_12
50
+ (testing " subtraction then addition"
51
+ (is (= 14 (wordy/evaluate " What is 17 minus 6 plus 3?" )))))
52
+
53
+ (deftest evaluate_test_13
54
+ (testing " multiple multiplication"
55
+ (is (= -12 (wordy/evaluate " What is 2 multiplied by -2 multiplied by 3?" )))))
56
+
57
+ (deftest evaluate_test_14
58
+ (testing " addition and multiplication"
59
+ (is (= -8 (wordy/evaluate " What is -3 plus 7 multiplied by -2?" )))))
60
+
61
+ (deftest evaluate_test_15
62
+ (testing " multiple division"
63
+ (is (= 2 (wordy/evaluate " What is -12 divided by 2 divided by -3?" )))))
64
+
65
+ (deftest evaluate_test_16
66
+ (testing " unknown operation"
67
+ (is (thrown-with-msg? IllegalArgumentException #"unknown operation" (wordy/evaluate " What is 52 cubed?" )))))
68
+
69
+ (deftest evaluate_test_17
70
+ (testing " Non math question"
71
+ (is (thrown-with-msg? IllegalArgumentException #"syntax error" (wordy/evaluate " Who is the President of the United States?" )))))
72
+
73
+ (deftest evaluate_test_18
74
+ (testing " reject problem missing an operand"
75
+ (is (thrown-with-msg? IllegalArgumentException #"syntax error" (wordy/evaluate " What is 1 plus?" )))))
76
+
77
+ (deftest evaluate_test_19
78
+ (testing " reject problem with no operands or operators"
79
+ (is (thrown-with-msg? IllegalArgumentException #"syntax error" (wordy/evaluate " What is?" )))))
80
+
81
+ (deftest evaluate_test_20
82
+ (testing " reject two operations in a row"
83
+ (is (thrown-with-msg? IllegalArgumentException #"syntax error" (wordy/evaluate " What is 1 plus plus 2?" )))))
84
+
85
+ (deftest evaluate_test_21
86
+ (testing " reject two numbers in a row"
87
+ (is (thrown-with-msg? IllegalArgumentException #"syntax error" (wordy/evaluate " What is 1 plus 2 1?" )))))
88
+
89
+ (deftest evaluate_test_22
90
+ (testing " reject postfix notation"
91
+ (is (thrown-with-msg? IllegalArgumentException #"syntax error" (wordy/evaluate " What is 1 2 plus?" )))))
92
+
93
+ (deftest evaluate_test_23
94
+ (testing " reject prefix notation"
95
+ (is (thrown-with-msg? IllegalArgumentException #"syntax error" (wordy/evaluate " What is plus 1 2?" )))))
96
+
0 commit comments