fancy 0.3.3 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (182) hide show
  1. data/README.md +14 -14
  2. data/Rakefile +16 -4
  3. data/bin/fancy +3 -0
  4. data/bin/fspec +20 -0
  5. data/bin/fyi +27 -11
  6. data/bin/ifancy +1 -1
  7. data/boot/fancy_ext.rb +1 -0
  8. data/boot/fancy_ext/block_env.rb +1 -9
  9. data/boot/fancy_ext/delegator.rb +64 -0
  10. data/boot/fancy_ext/object.rb +4 -0
  11. data/boot/fancy_ext/thread.rb +4 -0
  12. data/boot/load.rb +5 -1
  13. data/boot/rbx-compiler/compiler/ast.rb +0 -1
  14. data/boot/rbx-compiler/compiler/ast/class_def.rb +2 -0
  15. data/boot/rbx-compiler/compiler/ast/method_def.rb +2 -0
  16. data/boot/rbx-compiler/compiler/ast/node.rb +10 -0
  17. data/boot/rbx-compiler/compiler/ast/ruby_args.rb +12 -0
  18. data/boot/rbx-compiler/compiler/ast/singleton_method_def.rb +2 -0
  19. data/boot/rbx-compiler/parser/fancy_parser.bundle +0 -0
  20. data/boot/rbx-compiler/parser/lexer.lex +5 -11
  21. data/boot/rbx-compiler/parser/parser.rb +16 -5
  22. data/boot/rbx-compiler/parser/parser.y +39 -24
  23. data/doc/api/fancy.css +1 -1
  24. data/doc/api/fancy.jsonp +1 -1
  25. data/doc/api/fdoc.js +22 -4
  26. data/doc/api/index.html +5 -6
  27. data/doc/api/jquery-ui.min.js +401 -0
  28. data/doc/api/jquery.tools.min.js +192 -0
  29. data/doc/api/themeswitchertool.js +250 -0
  30. data/doc/features.md +17 -0
  31. data/examples/actor_bunnies.fy +32 -0
  32. data/examples/actors.fy +26 -0
  33. data/examples/actors_primitive.fy +27 -0
  34. data/examples/actors_ring.fy +37 -0
  35. data/examples/armstrong_numbers.fy +1 -1
  36. data/examples/array.fy +7 -9
  37. data/examples/async_send.fy +1 -2
  38. data/examples/blocks.fy +4 -4
  39. data/examples/call_with_receiver.fy +1 -1
  40. data/examples/class.fy +1 -1
  41. data/examples/default_args.fy +4 -1
  42. data/examples/define_methods.fy +2 -2
  43. data/examples/echo.fy +1 -1
  44. data/examples/factorial.fy +1 -1
  45. data/examples/future_composition.fy +2 -2
  46. data/examples/futures.fy +0 -5
  47. data/examples/game_of_life.fy +1 -1
  48. data/examples/person.fy +1 -1
  49. data/lib/argv.fy +7 -2
  50. data/lib/array.fy +109 -42
  51. data/lib/block.fy +39 -14
  52. data/lib/boot.fy +2 -0
  53. data/lib/class.fy +2 -0
  54. data/lib/compiler/ast.fy +2 -1
  55. data/lib/compiler/ast/assign.fy +2 -3
  56. data/lib/compiler/ast/async_send.fy +1 -15
  57. data/lib/compiler/ast/class_def.fy +2 -1
  58. data/lib/compiler/ast/expression_list.fy +4 -5
  59. data/lib/compiler/ast/future_send.fy +1 -10
  60. data/lib/compiler/ast/goto.fy +46 -0
  61. data/lib/compiler/ast/identifier.fy +9 -7
  62. data/lib/compiler/ast/literals.fy +8 -1
  63. data/lib/compiler/ast/match.fy +14 -4
  64. data/lib/compiler/ast/message_send.fy +34 -6
  65. data/lib/compiler/ast/method_def.fy +6 -6
  66. data/lib/compiler/ast/node.fy +3 -3
  67. data/lib/compiler/ast/range.fy +1 -0
  68. data/lib/compiler/ast/script.fy +0 -2
  69. data/lib/compiler/ast/singleton_method_def.fy +2 -4
  70. data/lib/compiler/ast/string_interpolation.fy +17 -0
  71. data/lib/compiler/ast/super.fy +5 -4
  72. data/lib/compiler/ast/try_catch.fy +8 -6
  73. data/lib/compiler/ast/tuple_literal.fy +3 -2
  74. data/lib/compiler/command.fy +0 -1
  75. data/lib/compiler/compiler.fy +1 -5
  76. data/lib/compiler/stages.fy +6 -14
  77. data/lib/documentation.fy +57 -46
  78. data/lib/enumerable.fy +257 -23
  79. data/lib/enumerator.fy +122 -15
  80. data/lib/false_class.fy +10 -1
  81. data/lib/fancy_spec.fy +263 -61
  82. data/lib/fdoc.fy +11 -25
  83. data/lib/fiber.fy +11 -0
  84. data/lib/file.fy +8 -11
  85. data/lib/future.fy +84 -5
  86. data/lib/hash.fy +65 -14
  87. data/lib/integer.fy +35 -0
  88. data/lib/iteration.fy +54 -29
  89. data/lib/message.fy +6 -0
  90. data/lib/method.fy +0 -16
  91. data/lib/nil_class.fy +58 -8
  92. data/lib/number.fy +49 -22
  93. data/lib/object.fy +371 -65
  94. data/lib/package.fy +24 -1
  95. data/lib/package/installer.fy +5 -9
  96. data/lib/package/specification.fy +2 -2
  97. data/lib/parser/ext/lexer.lex +15 -11
  98. data/lib/parser/ext/parser.y +70 -23
  99. data/lib/parser/methods.fy +33 -14
  100. data/lib/proxy.fy +33 -3
  101. data/lib/range.fy +28 -0
  102. data/lib/rbx.fy +3 -1
  103. data/lib/rbx/actor.fy +53 -0
  104. data/lib/rbx/alpha.fy +31 -0
  105. data/lib/rbx/array.fy +21 -12
  106. data/lib/rbx/bignum.fy +6 -2
  107. data/lib/rbx/block.fy +23 -26
  108. data/lib/rbx/class.fy +54 -2
  109. data/lib/rbx/code_loader.fy +8 -4
  110. data/lib/rbx/date.fy +9 -0
  111. data/lib/rbx/directory.fy +18 -0
  112. data/lib/rbx/environment_variables.fy +1 -0
  113. data/lib/rbx/exception.fy +9 -2
  114. data/lib/rbx/fiber.fy +22 -4
  115. data/lib/rbx/file.fy +5 -5
  116. data/lib/rbx/fixnum.fy +5 -0
  117. data/lib/rbx/float.fy +11 -3
  118. data/lib/rbx/hash.fy +31 -16
  119. data/lib/rbx/integer.fy +1 -0
  120. data/lib/rbx/io.fy +17 -7
  121. data/lib/rbx/match_data.fy +15 -4
  122. data/lib/rbx/method.fy +40 -7
  123. data/lib/rbx/name_error.fy +4 -0
  124. data/lib/rbx/object.fy +92 -24
  125. data/lib/rbx/range.fy +20 -6
  126. data/lib/rbx/regexp.fy +11 -3
  127. data/lib/rbx/string.fy +51 -1
  128. data/lib/rbx/stringio.fy +17 -0
  129. data/lib/rbx/symbol.fy +15 -1
  130. data/lib/rbx/system.fy +20 -2
  131. data/lib/rbx/tcp_server.fy +4 -1
  132. data/lib/rbx/tcp_socket.fy +11 -0
  133. data/lib/rbx/time.fy +6 -0
  134. data/lib/rbx/tuple.fy +14 -5
  135. data/lib/set.fy +144 -29
  136. data/lib/stack.fy +42 -11
  137. data/lib/string.fy +118 -8
  138. data/lib/struct.fy +13 -3
  139. data/lib/symbol.fy +21 -2
  140. data/lib/thread_pool.fy +2 -1
  141. data/lib/true_class.fy +45 -7
  142. data/lib/tuple.fy +27 -9
  143. data/lib/version.fy +2 -2
  144. data/ruby_lib/fancy +43 -0
  145. data/ruby_lib/fdoc +23 -0
  146. data/ruby_lib/fspec +3 -0
  147. data/ruby_lib/fyi +3 -0
  148. data/ruby_lib/ifancy +3 -0
  149. data/tests/argv.fy +5 -9
  150. data/tests/array.fy +323 -196
  151. data/tests/assignment.fy +29 -29
  152. data/tests/block.fy +72 -59
  153. data/tests/class.fy +227 -138
  154. data/tests/control_flow.fy +83 -51
  155. data/tests/documentation.fy +8 -8
  156. data/tests/enumerable.fy +8 -0
  157. data/tests/enumerator.fy +47 -29
  158. data/tests/exception.fy +49 -32
  159. data/tests/file.fy +28 -28
  160. data/tests/fixnum.fy +170 -0
  161. data/tests/future.fy +24 -7
  162. data/tests/hash.fy +55 -38
  163. data/tests/method.fy +50 -43
  164. data/tests/nil_class.fy +37 -37
  165. data/tests/object.fy +152 -70
  166. data/tests/pattern_matching.fy +67 -31
  167. data/tests/range.fy +6 -6
  168. data/tests/set.fy +101 -4
  169. data/tests/stack.fy +14 -5
  170. data/tests/string.fy +115 -61
  171. data/tests/stringio.fy +18 -0
  172. data/tests/struct.fy +27 -0
  173. data/tests/symbol.fy +19 -6
  174. data/tests/true_class.fy +34 -34
  175. data/tests/tuple.fy +30 -12
  176. metadata +103 -81
  177. data/boot/rbx-compiler/compiler/ast/require.rb +0 -20
  178. data/examples/actor.fy +0 -37
  179. data/examples/curl_async.fy +0 -37
  180. data/lib/compiler/ast/require.fy +0 -15
  181. data/tests/number.fy +0 -135
  182. data/tests/parsing/sexp.fy +0 -50
@@ -1,202 +1,234 @@
1
1
  FancySpec describe: "Control Flow" with: {
2
2
 
3
- it: "should NOT call the block if not nil" for: 'if_nil: when: {
4
- 'foo if_nil: { 'is_nil } . should == nil
5
- "hello, world" if_nil: { 'is_nil } . should == nil
3
+ it: "does NOT call the block if not nil" with: 'if_nil: when: {
4
+ 'foo if_nil: { 'is_nil } . is: nil
5
+ "hello, world" if_nil: { 'is_nil } . is: nil
6
6
  }
7
7
 
8
- it: "should work like if_true:" for: 'if:then: when: {
8
+ it: "works like if_true:" with: 'if:then: when: {
9
9
  if: (4 < 5) then: {
10
- 4 < 5 should == true
10
+ 4 < 5 is: true
11
11
  }
12
12
  }
13
13
 
14
- it: "should work like if_true:else: " for: 'if:then:else: when: {
14
+ it: "works like if_true:else: " with: 'if:then:else: when: {
15
15
  if: (4 < 5) then: {
16
- 4 < 5 should == true
16
+ 4 < 5 is: true
17
17
  } else: {
18
- 4 < 5 should == nil
18
+ 4 < 5 is: nil
19
19
  }
20
20
  }
21
21
 
22
- it: "should work like while_true:" for: 'while:do: when: {
22
+ it: "works like while_true:" with: 'while:do: when: {
23
23
  x = 0
24
24
  while: { x < 10 } do: {
25
- x < 10 should == true
25
+ x < 10 is: true
26
26
  x = x + 1
27
27
  }
28
- x == 10 should == true
28
+ x == 10 is: true
29
29
  }
30
30
 
31
- it: "should work like while_false: " for: 'until:do: when: {
31
+ it: "works like while_false: " with: 'until:do: when: {
32
32
  x = 0
33
33
  until: { x == 10 } do: {
34
- x < 10 should == true
34
+ x < 10 is: true
35
35
  x = x + 1
36
36
  }
37
- x == 10 should == true
37
+ x == 10 is: true
38
38
  }
39
39
 
40
- it: "should work like if_false:: " for: 'unless:do: when: {
40
+ it: "calls a block while another one is true, but call it at least once" with: 'do:while: when: {
41
+ x = 0
42
+ arr = []
43
+ do: {
44
+ x < 10 is: true
45
+ arr << x
46
+ x = x + 1
47
+ } while: { x < 10 }
48
+ arr is: [0,1,2,3,4,5,6,7,8,9]
49
+
50
+ times_called = 0
51
+ do: {
52
+ times_called = times_called + 1
53
+ } while: { false }
54
+ times_called is: 1
55
+ }
56
+
57
+ it: "calls a block until another one is true, but call it at least once" with: 'do:until: when: {
58
+ x = 0
59
+ do: {
60
+ x < 10 is: true
61
+ x = x + 1
62
+ } until: { x == 10 }
63
+ x is: 10
64
+
65
+ times_called = 0
66
+ do: {
67
+ times_called = times_called + 1
68
+ } until: { true }
69
+ times_called is: 1
70
+ }
71
+
72
+ it: "works like if_false:: " with: 'unless:do: when: {
41
73
  unless: (4 > 5) do: {
42
- 5 > 4 should == true
74
+ 5 > 4 is: true
43
75
  }
44
76
  }
45
77
 
46
- it: "should only call the block if it's a true-ish value" for: 'if_true: when: {
78
+ it: "only calls the block if it's a true-ish value" with: 'if_true: when: {
47
79
  1 if_true: |num| {
48
80
  num * 10
49
- } . should == 10
81
+ } . is: 10
50
82
 
51
83
  nil if_true: {
52
84
  "nope"
53
- } . should == nil
85
+ } . is: nil
54
86
 
55
87
  false if_true: {
56
88
  "nope again"
57
- } . should == nil
89
+ } . is: nil
58
90
  }
59
91
 
60
- it: "should call the then_block if it's a true-ish value and call the else_block otherwise" for: 'if_true:else: when: {
92
+ it: "calls the then_block if it's a true-ish value and call the else_block otherwise" with: 'if_true:else: when: {
61
93
  1 if_true: |num| {
62
94
  num * 10
63
95
  } else: {
64
96
  nil
65
- } . should == 10
97
+ } . is: 10
66
98
 
67
99
  nil if_true: {
68
100
  "nope"
69
101
  } else: {
70
102
  "yup"
71
- } . should == "yup"
103
+ } . is: "yup"
72
104
 
73
105
  false if_true: {
74
106
  "nope again"
75
107
  } else: {
76
108
  "yup again"
77
- } . should == "yup again"
109
+ } . is: "yup again"
78
110
  }
79
111
 
80
- it: "should be possible to override the if_true:else: method and work accordingly in conditionals" when: {
81
- class AClasThatIsLikeFalse {
112
+ it: "is possible to override the if_true:else: method and work accordingly in conditionals" when: {
113
+ class AClassThatIsLikeFalse {
82
114
  def if_true: block else: another_block {
83
115
  another_block call
84
116
  }
85
117
  }
86
118
 
87
- obj = AClasThatIsLikeFalse new
119
+ obj = AClassThatIsLikeFalse new
88
120
  if: obj then: {
89
121
  'fail
90
122
  } else: {
91
123
  'success
92
- } . should == 'success
124
+ } . is: 'success
93
125
 
94
126
  # let's get rid of this custom if_true:else: method
95
- AClasThatIsLikeFalse undefine_method: 'if_true:else:
127
+ AClassThatIsLikeFalse undefine_method: 'if_true:else:
96
128
 
97
129
  if: obj then: {
98
130
  'now_this_is_success
99
131
  } else: {
100
132
  'fail
101
- } . should == 'now_this_is_success
133
+ } . is: 'now_this_is_success
102
134
  }
103
135
 
104
- it: "should break from an iteration" for: 'break when: {
136
+ it: "breaks from an iteration" with: 'break when: {
105
137
  x = 0
106
138
  until: { x == 10 } do: {
107
139
  x = x + 1
108
140
  { break } if: (x == 5)
109
141
  }
110
- x == 5 should == true
142
+ x == 5 is: true
111
143
  }
112
144
 
113
- it: "should break from an iteration with return value" for: 'break: when: {
145
+ it: "breaks from an iteration with return value" with: 'break: when: {
114
146
  x = 0
115
147
  y = until: { x == 10 } do: {
116
148
  x = x + 1
117
149
  { break: 42 } if: (x == 5)
118
150
  }
119
151
 
120
- x should == 5
121
- y should == 42
152
+ x is: 5
153
+ y is: 42
122
154
  }
123
155
 
124
- it: "should skip an iteration over a Range" for: 'next when: {
156
+ it: "skips an iteration over a Range" with: 'next when: {
125
157
  total = 0
126
158
  (1..10) each: |i| {
127
159
  { next } if: (i == 5)
128
160
  total = total + i
129
161
  }
130
- total should == 50
162
+ total is: 50
131
163
  }
132
164
 
133
- it: "should skip an iteration over an Array" for: 'next when: {
165
+ it: "skips an iteration over an Array" with: 'next when: {
134
166
  total = 0
135
167
  [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] each: |i| {
136
168
  { next } if: (i == 5)
137
169
  total = total + i
138
170
  }
139
- total should == 50
171
+ total is: 50
140
172
  }
141
173
 
142
- it: "should skip an iteration over an Hash" for: 'next when: {
174
+ it: "skips an iteration over an Hash" with: 'next when: {
143
175
  total = 0
144
176
  <['a => 1, 'b => 2, 'c => 3, 'd => 4, 'e => 5, 'f => 6]> each: |k v| {
145
177
  { next } if: (k == 'd)
146
178
  total = total + v
147
179
  }
148
- total should == 17
180
+ total is: 17
149
181
  }
150
182
 
151
- it: "stops any loop type at the correct spot" for: 'break when: {
183
+ it: "stops any loop type at the correct spot" with: 'break when: {
152
184
  i = 0
153
185
  loop: {
154
186
  { break } if: (i == 3)
155
187
  i = i + 1
156
188
  }
157
- i should == 3
189
+ i is: 3
158
190
 
159
191
  i = 0
160
192
  while: { i < 5 } do: {
161
193
  { break } if: (i == 3)
162
194
  i = i + 1
163
195
  }
164
- i should == 3
196
+ i is: 3
165
197
 
166
198
  i = 0
167
199
  0 upto: 5 do: |n| {
168
200
  i = n
169
201
  { break } if: (n == 3)
170
202
  }
171
- i should == 3
203
+ i is: 3
172
204
  }
173
205
 
174
- it: "stops any loop type at the correct spot" for: 'break: when: {
206
+ it: "stops any loop type at the correct spot" with: 'break: when: {
175
207
  i = 0
176
208
  loop: {
177
209
  { break: i } if: (i == 2)
178
210
  i = i + 1
179
- } . should == 2
211
+ } . is: 2
180
212
 
181
213
  i = 0
182
214
  while: { i < 5 } do: {
183
215
  { break: i } if: (i == 2)
184
216
  i = i + 1
185
- } . should == 2
217
+ } . is: 2
186
218
 
187
219
  i = 0
188
220
  0 upto: 5 do: |n| {
189
221
  i = n
190
222
  { break: n } if: (n == 2)
191
223
  }
192
- i should == 2
224
+ i is: 2
193
225
  }
194
226
 
195
- it: "should allow empty try blocks" when: {
227
+ it: "allows empty try blocks" when: {
196
228
  x = "foo"
197
229
  try {
198
230
  } finally {
199
- x should == "foo"
231
+ x is: "foo"
200
232
  }
201
233
  }
202
234
  }
@@ -1,11 +1,11 @@
1
1
  FancySpec describe: "Documentations" with: {
2
- it: "should display the documentation for a method" when: {
2
+ it: "displays the documentation for a method" when: {
3
3
  documentation = "Array#each: iterates over its elements, calling a given block with each element."
4
4
  Array new method: "each:" . documentation: documentation
5
- Array new method: "each:" . documentation . docs first should == documentation
5
+ Array new method: "each:" . documentation . docs first is: documentation
6
6
  }
7
7
 
8
- it: "should define a documenation string for a class and method" when: {
8
+ it: "defines a documenation string for a class and method" when: {
9
9
  class ClassWithDoc {
10
10
  "This class has a documentation! Yay!"
11
11
  def foo {
@@ -13,12 +13,12 @@ FancySpec describe: "Documentations" with: {
13
13
  nil
14
14
  }
15
15
  }
16
- ClassWithDoc documentation should_not == ""
17
- ClassWithDoc documentation should == "This class has a documentation! Yay!"
18
- ClassWithDoc new method: 'foo . documentation docs should == ["bar!"]
16
+ ClassWithDoc documentation to_s is_not: ""
17
+ ClassWithDoc documentation to_s is: "This class has a documentation! Yay!"
18
+ ClassWithDoc new method: 'foo . documentation docs is: ["bar!"]
19
19
  }
20
20
 
21
- it: "should have a documentation string for a method" when: {
22
- Array new method: "first" . documentation should_not be: 'nil?
21
+ it: "has a documentation string for a method" when: {
22
+ Array new method: "first" . documentation is_not be: 'nil?
23
23
  }
24
24
  }
@@ -0,0 +1,8 @@
1
+ FancySpec describe: FancyEnumerable with: {
2
+ it: "selects the right element based on a comparison Block and an optional selection Block" with: 'superior_by:taking: when: {
3
+ [1,2,3,4,5] superior_by: '> . is: 5
4
+ [1,2,3,4,5] superior_by: '< . is: 1
5
+ [[1,2], [2,3,4], [], [1]] superior_by: '> taking: 'size . is: [2,3,4]
6
+ [[1,2], [2,3,4], [-1]] superior_by: '< taking: 'first . is: [-1]
7
+ }
8
+ }
@@ -1,42 +1,42 @@
1
1
  FancySpec describe: FancyEnumerator with: {
2
- it: "iterates with 'next" for: 'new: when: {
2
+ it: "iterates with 'next" with: 'new: when: {
3
3
  enum = FancyEnumerator new: (42..50)
4
- enum next should == 42
5
- enum next should == 43
4
+ enum next is: 42
5
+ enum next is: 43
6
6
  }
7
7
 
8
- it: "peeks to find next element" for: 'peek when: {
8
+ it: "peeks to find next element" with: 'peek when: {
9
9
  enum = FancyEnumerator new: (42..50)
10
- enum peek should == 42
11
- enum peek should == 42
12
- enum next should == 42
10
+ enum peek is: 42
11
+ enum peek is: 42
12
+ enum next is: 42
13
13
 
14
- enum peek should == 43
15
- enum peek should == 43
16
- enum next should == 43
14
+ enum peek is: 43
15
+ enum peek is: 43
16
+ enum next is: 43
17
17
  }
18
18
 
19
- it: "turns an object with 'each: into an FancyEnumerator" for: 'to_enum when: {
19
+ it: "turns an object with 'each: into an FancyEnumerator" with: 'to_enum when: {
20
20
  enum = (42..45) to_enum
21
- enum next should == 42
21
+ enum next is: 42
22
22
  }
23
23
 
24
- it: "turns an object with given method into an FancyEnumerator" for: 'to_enum: when: {
24
+ it: "turns an object with given method into an FancyEnumerator" with: 'to_enum: when: {
25
25
  o = {}
26
26
  def o iter: block {
27
27
  1 upto: 10 do: block
28
28
  }
29
29
  enum = o to_enum: 'iter:
30
- enum next should == 1
30
+ enum next is: 1
31
31
  }
32
32
 
33
- it: "rewinds to the beginning of the iteration" for: 'rewind when: {
33
+ it: "rewinds to the beginning of the iteration" with: 'rewind when: {
34
34
  enum = (42..45) to_enum
35
35
  check = {
36
- enum peek should == 42
37
- enum next should == 42
38
- enum peek should == 43
39
- enum next should == 43
36
+ enum peek is: 42
37
+ enum next is: 42
38
+ enum peek is: 43
39
+ enum next is: 43
40
40
  }
41
41
 
42
42
  check call
@@ -44,21 +44,21 @@ FancySpec describe: FancyEnumerator with: {
44
44
  check call
45
45
  }
46
46
 
47
- it: "raises Fancy StopIteration when out of values" for: 'next when: {
47
+ it: "raises Fancy StopIteration when out of values" with: 'next when: {
48
48
  o = Object new
49
49
  def o each: block { block call: [1] }
50
50
  e = o to_enum
51
51
 
52
- e next should == 1
52
+ e next is: 1
53
53
  try {
54
54
  e next
55
- "We should not reach this line" should == true
55
+ "We is not reach this line" is: true
56
56
  } catch (Fancy StopIteration) => ex {
57
- ex result should == nil
57
+ ex result is: nil
58
58
  }
59
59
  }
60
60
 
61
- it: "sets result on Fancy StopIteration when out of values" for: 'next when: {
61
+ it: "sets result on Fancy StopIteration when out of values" with: 'next when: {
62
62
  o = Object new
63
63
  def o each: block {
64
64
  block call: [1]
@@ -66,19 +66,37 @@ FancySpec describe: FancyEnumerator with: {
66
66
  }
67
67
  e = o to_enum
68
68
 
69
- e next should == 1
69
+ e next is: 1
70
70
  try {
71
71
  e next
72
- "We should not reach this line" should == true
72
+ "We is not reach this line" is: true
73
73
  } catch (Fancy StopIteration) => ex {
74
- ex result should == 42
74
+ ex result is: 42
75
75
  }
76
76
  }
77
77
 
78
- it: "iterates with an object" for: 'with:each: when: {
78
+ it: "iterates with an object" with: 'with:each: when: {
79
79
  enum = (42..45) to_enum
80
80
  result = enum with: [] each: |val, obj| { obj << val }
81
- result should == [42, 43, 44, 45]
81
+ result is: [42, 43, 44, 45]
82
+ }
83
+
84
+ it: "chunks up into enums" with: 'chunk: when: {
85
+ enum = (1..42) to_enum
86
+ chunked = enum chunk: |n| { n % 3 == 0 }
87
+ chunked next is: [false, [1,2]]
88
+ chunked next is: [true, [3]]
89
+ }
90
+
91
+ it: "converts to an Array" with: 'to_a when: {
92
+ enum = (1..10) to_enum
93
+ enum to_a is: [1,2,3,4,5,6,7,8,9,10]
94
+ }
95
+
96
+ it: "has ended (no more values left)" with: 'ended? when: {
97
+ enum = (1..9) to_enum
98
+ 10 times: { enum ended? is: false; enum next } # move forward
99
+ enum ended? is: true
82
100
  }
83
101
  }
84
102