@@ -3,16 +3,16 @@ import count_words from require 'word_count'
33describe ' word-count' , ->
44 -- ----------------------------------------------------------
55 same_kv = ( state, arguments) ->
6- expected = arguments[ 1 ]
7- actual = arguments[ 2 ]
6+ actual = arguments[ 1 ]
7+ expected = arguments[ 2 ]
88 return false if # expected != # actual
99 for k, v in pairs expected
1010 return false if actual[ k] != v
1111 true
1212
1313 say = require ' say'
14- say\ set ' assertion.same_kv.positive' , ' Expected \n %s\n to have the same keys and values as\n %s'
15- say\ set ' assertion.same_kv.negative' , ' Expected \n %s\n to not have the same keys and values as \n %s '
14+ say\ set ' assertion.same_kv.positive' , ' Actual result \n %s\n does not have the same keys and values as expected \n %s'
15+ say\ set ' assertion.same_kv.negative' , ' Actual result \n %s\n was not supposed to be the same as the expected value. '
1616 assert \ register ' assertion' , ' same_kv' , same_kv, ' assertion.same_kv.positive' , ' assertion.same_kv.negative'
1717 -- ----------------------------------------------------------
1818
@@ -21,135 +21,135 @@ describe 'word-count', ->
2121 expected = {
2222 word : 1 ,
2323 }
24- assert . has. same_kv expected , result
24+ assert . has. same_kv result , expected
2525
2626 pending ' count one of each word' , ->
2727 result = count_words " one of each"
2828 expected = {
29- each : 1 ,
3029 one : 1 ,
30+ each : 1 ,
3131 of : 1 ,
3232 }
33- assert . has. same_kv expected , result
33+ assert . has. same_kv result , expected
3434
3535 pending ' multiple occurrences of a word' , ->
3636 result = count_words " one fish two fish red fish blue fish"
3737 expected = {
38+ one : 1 ,
3839 fish : 4 ,
3940 blue : 1 ,
40- one : 1 ,
41- two : 1 ,
4241 red : 1 ,
42+ two : 1 ,
4343 }
44- assert . has. same_kv expected , result
44+ assert . has. same_kv result , expected
4545
4646 pending ' handles cramped lists' , ->
4747 result = count_words " one,two,three"
4848 expected = {
49- two : 1 ,
5049 one : 1 ,
50+ two : 1 ,
5151 three : 1 ,
5252 }
53- assert . has. same_kv expected , result
53+ assert . has. same_kv result , expected
5454
5555 pending ' handles expanded lists' , ->
5656 result = count_words " one,\n two,\n three"
5757 expected = {
58- two : 1 ,
5958 one : 1 ,
59+ two : 1 ,
6060 three : 1 ,
6161 }
62- assert . has. same_kv expected , result
62+ assert . has. same_kv result , expected
6363
6464 pending ' ignore punctuation' , ->
6565 result = count_words " car: carpet as java: javascript!!&@$%^&"
6666 expected = {
67+ carpet : 1 ,
6768 car : 1 ,
69+ javascript : 1 ,
6870 as : 1 ,
6971 java : 1 ,
70- javascript : 1 ,
71- carpet : 1 ,
7272 }
73- assert . has. same_kv expected , result
73+ assert . has. same_kv result , expected
7474
7575 pending ' include numbers' , ->
7676 result = count_words " testing, 1, 2 testing"
7777 expected = {
78- testing : 2 ,
79- ' 2' : 1 ,
8078 ' 1' : 1 ,
79+ ' 2' : 1 ,
80+ testing : 2 ,
8181 }
82- assert . has. same_kv expected , result
82+ assert . has. same_kv result , expected
8383
8484 pending ' normalize case' , ->
8585 result = count_words " go Go GO Stop stop"
8686 expected = {
87- go : 3 ,
8887 stop : 2 ,
88+ go : 3 ,
8989 }
90- assert . has. same_kv expected , result
90+ assert . has. same_kv result , expected
9191
9292 pending ' with apostrophes' , ->
9393 result = count_words " 'First: don't laugh. Then: don't cry. You're getting it.'"
9494 expected = {
9595 then : 1 ,
96- laugh : 1 ,
96+ cry : 1 ,
97+ " you're" : 1 ,
98+ getting : 1 ,
9799 " don't" : 2 ,
98- it : 1 ,
99100 first : 1 ,
100- getting : 1 ,
101- " you're" : 1 ,
102- cry : 1 ,
101+ laugh : 1 ,
102+ it : 1 ,
103103 }
104- assert . has. same_kv expected , result
104+ assert . has. same_kv result , expected
105105
106106 pending ' with quotations' , ->
107107 result = count_words " Joe can't tell between 'large' and large."
108108 expected = {
109- joe : 1 ,
109+ between : 1 ,
110110 tell : 1 ,
111+ joe : 1 ,
111112 large : 2 ,
112- and: 1 ,
113- between : 1 ,
114113 " can't" : 1 ,
114+ and: 1 ,
115115 }
116- assert . has. same_kv expected , result
116+ assert . has. same_kv result , expected
117117
118118 pending ' substrings from the beginning' , ->
119119 result = count_words " Joe can't tell between app, apple and a."
120120 expected = {
121+ between : 1 ,
121122 a : 1 ,
122- and: 1 ,
123- joe : 1 ,
124- apple : 1 ,
125123 tell : 1 ,
126124 app : 1 ,
127- between : 1 ,
125+ joe : 1 ,
126+ apple : 1 ,
128127 " can't" : 1 ,
128+ and: 1 ,
129129 }
130- assert . has. same_kv expected , result
130+ assert . has. same_kv result , expected
131131
132132 pending ' multiple spaces not detected as a word' , ->
133133 result = count_words " multiple whitespaces"
134134 expected = {
135135 multiple : 1 ,
136136 whitespaces : 1 ,
137137 }
138- assert . has. same_kv expected , result
138+ assert . has. same_kv result , expected
139139
140140 pending ' alternating word separators not detected as a word' , ->
141141 result = count_words " ,\n ,one,\n ,two \n 'three'"
142142 expected = {
143- two : 1 ,
144143 one : 1 ,
144+ two : 1 ,
145145 three : 1 ,
146146 }
147- assert . has. same_kv expected , result
147+ assert . has. same_kv result , expected
148148
149149 pending ' quotation for word with apostrophe' , ->
150150 result = count_words " can, can't, 'can't'"
151151 expected = {
152152 " can't" : 2 ,
153153 can : 1 ,
154154 }
155- assert . has. same_kv expected , result
155+ assert . has. same_kv result , expected
0 commit comments