fancy 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. data/LICENSE +1 -1
  2. data/README.md +5 -4
  3. data/bin/fspec +19 -1
  4. data/bin/ifancy +139 -35
  5. data/boot/README +2 -9
  6. data/boot/extconf.rb +0 -1
  7. data/boot/fancy_ext/module.rb +5 -15
  8. data/boot/fancy_ext/thread.rb +22 -9
  9. data/boot/rbx-compiler/README +0 -4
  10. data/boot/rbx-compiler/parser/fancy_parser.bundle +0 -0
  11. data/boot/rbx-compiler/parser/parser.y +1 -0
  12. data/doc/api/fancy.css +1 -6
  13. data/doc/api/fancy.jsonp +1 -1
  14. data/doc/api/fdoc.js +2 -4
  15. data/doc/api/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  16. data/doc/api/images/ui-bg_flat_0_eeeeee_40x100.png +0 -0
  17. data/doc/api/images/ui-bg_flat_55_ffffff_40x100.png +0 -0
  18. data/doc/api/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  19. data/doc/api/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  20. data/doc/api/images/ui-bg_highlight-soft_100_f6f6f6_1x100.png +0 -0
  21. data/doc/api/images/ui-bg_highlight-soft_25_0073ea_1x100.png +0 -0
  22. data/doc/api/images/ui-bg_highlight-soft_50_dddddd_1x100.png +0 -0
  23. data/doc/api/images/ui-icons_0073ea_256x240.png +0 -0
  24. data/doc/api/images/ui-icons_454545_256x240.png +0 -0
  25. data/doc/api/images/ui-icons_666666_256x240.png +0 -0
  26. data/doc/api/images/ui-icons_ff0084_256x240.png +0 -0
  27. data/doc/api/images/ui-icons_ffffff_256x240.png +0 -0
  28. data/doc/api/index.html +5 -4
  29. data/doc/api/jquery-1.8.2.min.js +2 -0
  30. data/doc/api/jquery-ui-1.9.0.custom.min.css +5 -0
  31. data/doc/api/jquery-ui-1.9.0.custom.min.js +6 -0
  32. data/doc/features.md +8 -3
  33. data/examples/argv.fy +1 -1
  34. data/examples/closures.fy +1 -4
  35. data/examples/echo.fy +2 -2
  36. data/examples/guess_number.fy +18 -0
  37. data/examples/nested_classes.fy +3 -15
  38. data/lib/argv.fy +23 -18
  39. data/lib/array.fy +18 -37
  40. data/lib/block.fy +125 -0
  41. data/lib/boot.fy +1 -0
  42. data/lib/compiler/ast/block.fy +1 -1
  43. data/lib/compiler/ast/identifier.fy +1 -1
  44. data/lib/compiler/ast/message_send.fy +0 -13
  45. data/lib/compiler/ast/method_def.fy +1 -1
  46. data/lib/compiler/ast/singleton_method_def.fy +1 -0
  47. data/lib/compiler/ast/tuple_literal.fy +1 -1
  48. data/lib/compiler/command.fy +1 -1
  49. data/lib/compiler/compiler.fy +8 -6
  50. data/lib/contracts.fy +1 -1
  51. data/lib/directory.fy +1 -1
  52. data/lib/dynamic_slot_object.fy +1 -1
  53. data/lib/enumerable.fy +316 -25
  54. data/lib/enumerator.fy +11 -8
  55. data/lib/eval.fy +0 -3
  56. data/lib/fancy_spec.fy +27 -0
  57. data/lib/fdoc.fy +8 -8
  58. data/lib/file.fy +25 -1
  59. data/lib/hash.fy +91 -0
  60. data/lib/html.fy +40 -11
  61. data/lib/integer.fy +4 -0
  62. data/lib/main.fy +18 -11
  63. data/lib/object.fy +33 -7
  64. data/lib/option_parser.fy +20 -1
  65. data/lib/package/dependency.fy +8 -0
  66. data/lib/package/dependency_installer.fy +3 -6
  67. data/lib/package/handler.fy +4 -4
  68. data/lib/package/installer.fy +2 -5
  69. data/lib/package/list.fy +3 -4
  70. data/lib/parser/ext/parser.y +1 -0
  71. data/lib/proxies.fy +0 -2
  72. data/lib/queue.fy +7 -0
  73. data/lib/rbx.fy +1 -0
  74. data/lib/rbx/actor.fy +3 -1
  75. data/lib/rbx/alpha.fy +24 -0
  76. data/lib/rbx/array.fy +3 -1
  77. data/lib/rbx/class.fy +5 -8
  78. data/lib/rbx/date_time.fy +14 -0
  79. data/lib/rbx/file.fy +6 -0
  80. data/lib/rbx/hash.fy +42 -0
  81. data/lib/rbx/thread.fy +5 -7
  82. data/lib/string.fy +56 -4
  83. data/lib/symbol.fy +29 -1
  84. data/lib/time.fy +17 -0
  85. data/lib/vars.fy +4 -3
  86. data/lib/version.fy +1 -1
  87. data/ruby_lib/interactive/hilight.rb +125 -0
  88. data/tests/array.fy +19 -7
  89. data/tests/block.fy +103 -4
  90. data/tests/class.fy +31 -26
  91. data/tests/control_flow.fy +0 -1
  92. data/tests/dynamic_key_hash.fy +22 -1
  93. data/tests/enumerable.fy +239 -7
  94. data/tests/enumerator.fy +7 -0
  95. data/tests/file.fy +16 -0
  96. data/tests/future.fy +1 -11
  97. data/tests/future_proxy.fy +8 -0
  98. data/tests/hash.fy +132 -9
  99. data/tests/html.fy +30 -13
  100. data/tests/integer.fy +3 -0
  101. data/tests/method.fy +6 -11
  102. data/tests/object.fy +12 -5
  103. data/tests/option_parser.fy +12 -3
  104. data/tests/string.fy +69 -1
  105. data/tests/symbol.fy +24 -0
  106. metadata +42 -12
  107. data/boot/rsexp_pretty_printer.rb +0 -76
  108. data/doc/api/jquery-ui.min.js +0 -401
  109. data/doc/api/jquery.tools.min.js +0 -192
  110. data/doc/api/themeswitchertool.js +0 -250
  111. data/examples/future_sends.fy +0 -15
data/tests/class.fy CHANGED
@@ -355,23 +355,24 @@ FancySpec describe: Class with: {
355
355
  NameSpace Array is_not: Array
356
356
  }
357
357
 
358
- # it: "returns all nested classes of a class" with: 'nested_classes when: {
359
- # class Outer {
360
- # }
361
- # Outer nested_classes is: []
362
-
363
- # class Outer {
364
- # class Inner1 {
365
- # }
366
- # }
367
- # Outer nested_classes is: [Outer::Inner1]
368
-
369
- # class Outer {
370
- # class Inner2 {
371
- # }
372
- # }
373
- # Outer nested_classes is: [Outer Inner1, Outer Inner2]
374
- # }
358
+ it: "returns all nested classes of a class" with: 'nested_classes when: {
359
+ class OuterB {
360
+ NotAClass = 'nope
361
+ }
362
+ OuterB nested_classes is: $ Set[[]]
363
+
364
+ class OuterB {
365
+ class InnerB1 {
366
+ }
367
+ }
368
+ OuterB nested_classes is: $ Set[[OuterB::InnerB1]]
369
+
370
+ class OuterB {
371
+ class InnerB2 {
372
+ }
373
+ }
374
+ OuterB nested_classes is: $ Set[[OuterB InnerB1, OuterB InnerB2]]
375
+ }
375
376
 
376
377
  it: "finds other nested classes in the same parent class" when: {
377
378
  class MyOuter {
@@ -659,17 +660,21 @@ FancySpec describe: Class with: {
659
660
 
660
661
  it: "defines a lazy slot" with: 'lazy_slot:value: when: {
661
662
  class LazyClass {
662
- lazy_slot: 'foo value: { Thread sleep: 0.01; 42 * @count }
663
- def initialize: @count
663
+ read_slot: 'count
664
+ lazy_slot: 'foo value: { @count = @count + 1; 42 }
665
+ def initialize {
666
+ @count = 0
667
+ }
664
668
  }
665
669
 
666
- f = LazyClass new: 2
667
- start = Time now
668
- f foo is: 84
669
- Time now - start >= 0.01 is: true
670
- start = Time now
671
- f foo is: 84
672
- Time now - start <= 0.01 is: true
670
+ f = LazyClass new
671
+ f count is: 0
672
+ f foo is: 42
673
+ f count is: 1
674
+ f foo is: 42
675
+ f count is: 1
676
+ 10 times: { f foo }
677
+ f count is: 1
673
678
  }
674
679
 
675
680
  it: "returns a string representation of itself and its superclass, if any" with: 'inspect when: {
@@ -1,5 +1,4 @@
1
1
  FancySpec describe: "Control Flow" with: {
2
-
3
2
  it: "does NOT call the block if not nil" with: 'if_nil: when: {
4
3
  'foo if_nil: { 'is_nil } . is: nil
5
4
  "hello, world" if_nil: { 'is_nil } . is: nil
@@ -5,12 +5,33 @@ FancySpec describe: DynamicKeyHash with: {
5
5
  name: "Chris"
6
6
  age: 25
7
7
  country: "Germany"
8
+ nested: { yo: "off" }
8
9
  }
9
10
 
10
11
  hash = dkh hash
11
- Set[hash keys] is: $ Set[['name, 'age, 'country]]
12
+ Set[hash keys] is: $ Set[['name, 'age, 'country, 'nested]]
12
13
  hash['name] is: "Chris"
13
14
  hash['age] is: 25
14
15
  hash['country] is: "Germany"
16
+ hash['nested] is_a?: Block . is: true
17
+ }
18
+
19
+ it: "returns a deeply nested hash correctly" when: {
20
+ dkh = DynamicKeyHash new: true
21
+ dkh tap: @{
22
+ foo: @{
23
+ bar: @{
24
+ baz: "yo"
25
+ }
26
+ }
27
+ }
28
+
29
+ dkh hash is: <[
30
+ 'foo => <[
31
+ 'bar => <[
32
+ 'baz => "yo"
33
+ ]>
34
+ ]>
35
+ ]>
15
36
  }
16
37
  }
data/tests/enumerable.fy CHANGED
@@ -6,6 +6,17 @@ FancySpec describe: Fancy Enumerable with: {
6
6
  [[1,2], [2,3,4], [-1]] superior_by: '< taking: 'first . is: [-1]
7
7
  }
8
8
 
9
+ it: "returns an Array of mapped values" with: 'map: when: {
10
+ [] map: 'identity . is: []
11
+ (1,2,3) map: 'squared . is: [1,4,9]
12
+ "foo" map: 'upcase . is: ["F", "O", "O"]
13
+ }
14
+
15
+ it: "returns an Array of mapped values by calling a block with each element and its index" with: 'map_with_index: when: {
16
+ [] map_with_index: 'identity . is: []
17
+ [1,2,3] map_with_index: |x i| { i * 2 } . is: [0,2,4]
18
+ }
19
+
9
20
  it: "chain-maps all blocks on all values" with: 'map_chained: when: {
10
21
  (1,2,3) map_chained: ('doubled, 'squared, 'to_s) . is: ["4", "16", "36"]
11
22
  (1,2,3) map_chained: (@{ + 1 }, 'to_s) . is: ["2", "3", "4"]
@@ -14,15 +25,18 @@ FancySpec describe: Fancy Enumerable with: {
14
25
  }
15
26
 
16
27
  it: "maps over its elements with their index" with: 'map_with_index: when: {
17
- (1,2,3) map_with_index: |x i| {
18
- x + i
19
- } . is: [1,3,5]
28
+ (1,2,3) map_with_index: |x i| { x + i } . is: [1,3,5]
20
29
 
21
- [1,2,3,4] map_with_index: |x i| {
22
- i
23
- } . is: [0,1,2,3]
30
+ [1,2,3,4] map_with_index: |_ i| { i } . is: [0,1,2,3]
24
31
 
25
- [] map_with_index: |x i| { i } . is: []
32
+ [] map_with_index: |_ i| { i } . is: []
33
+ }
34
+
35
+ it: "returns a flattened Array of mapped values" with: 'flat_map: when: {
36
+ [] flat_map: 'identity . is: []
37
+ (1,2,3) flat_map: 'identity . is: [1,2,3]
38
+ [(1,2,3), (4,5,6)] flat_map: 'sum . is: [6, 15]
39
+ [[1,2,3], [4,5,6]] flat_map: 'identity . is: [1,2,3,4,5,6]
26
40
  }
27
41
 
28
42
  it: "counts the amount of elements for which a block yields true" with: 'count: when: {
@@ -83,6 +97,12 @@ FancySpec describe: Fancy Enumerable with: {
83
97
  "fabc" sorted? is: false
84
98
  }
85
99
 
100
+ it: "sorts by a given block" with: 'sort_by: when: {
101
+ [[1,2], [1,2,3], [1], []] sort_by: @{ size } . is: [[], [1], [1,2], [1,2,3]]
102
+ [[1,2], [1,2,3], [1], []] sort_by: 'size . is: [[], [1], [1,2], [1,2,3]]
103
+ ["abc", "abcd", "ab", "a", ""] sort_by: @{ size } . is: ["", "a", "ab", "abc", "abcd"]
104
+ }
105
+
86
106
  it: "splits a collection at an index" with: 'split_at: when: {
87
107
  [] split_at: 0 . is: [[],[]]
88
108
  [1] split_at: 0 . is: [[],[1]]
@@ -114,6 +134,7 @@ FancySpec describe: Fancy Enumerable with: {
114
134
 
115
135
  it: "drops elements from itself as long a block yields true" with: 'drop_while: when: {
116
136
  (1..15) drop_while: |x| { x < 10 } . is: (10 upto: 15)
137
+ "aaabcd" drop_while: /a/ . is: ["b","c","d"]
117
138
  }
118
139
 
119
140
  it: "returns the first n elements" with: 'first: when: {
@@ -154,4 +175,215 @@ FancySpec describe: Fancy Enumerable with: {
154
175
  [NoMethodError, IOError, ZeroDivisionError] join_by: '>< . is: (NoMethodError >< IOError >< ZeroDivisionError)
155
176
  [NoMethodError, IOError, ZeroDivisionError] join_by: '<> . is: (NoMethodError <> IOError <> ZeroDivisionError)
156
177
  }
178
+
179
+ it: "returns the element if found" with: 'find: when: {
180
+ [1,2,3] tap: @{
181
+ find: 0 . is: nil
182
+ find: 1 . is: 1
183
+ find: 2 . is: 2
184
+ find: 3 . is: 3
185
+ find: 4 . is: nil
186
+ }
187
+ }
188
+
189
+ it: "calls a block with the element if found" with: 'find:do: when: {
190
+ found = []
191
+ [1,2,3] tap: @{
192
+ insert = |x| { found << x }
193
+ find: 0 do: insert
194
+ find: 1 do: insert
195
+ find: 2 do: insert
196
+ find: 3 do: insert
197
+ find: 4 do: insert
198
+ }
199
+ found is: [1,2,3]
200
+ }
201
+
202
+ it: "calls a block with the element and its index if found" with: 'find_with_index:do: when: {
203
+ found = []
204
+ [1,2,3] tap: @{
205
+ insert = |x i| { found << (x,i) }
206
+ find_with_index: 0 do: insert
207
+ find_with_index: 1 do: insert
208
+ find_with_index: 2 do: insert
209
+ find_with_index: 3 do: insert
210
+ find_with_index: 4 do: insert
211
+ }
212
+ found is: [(1,0), (2,1), (3,2)]
213
+ }
214
+
215
+ it: "calls a block with an element and its indexes" with: 'for_every:with_index_do: when: {
216
+ found = []
217
+ [1,2,3,2,1] tap: @{
218
+ insert = |x i| { found << (x,i) }
219
+ for_every: 0 with_index_do: insert
220
+ for_every: 1 with_index_do: insert
221
+ for_every: 2 with_index_do: insert
222
+ for_every: 3 with_index_do: insert
223
+ for_every: 4 with_index_do: insert
224
+ }
225
+ found is: [(1,0), (1,4), (2,1), (2,3), (3,2)]
226
+ }
227
+
228
+ it: "calls a block with an element for every occurance" with: 'for_every:do: when: {
229
+ arr = [1,2,3,2,1]
230
+
231
+ c = 0
232
+ arr for_every: 0 do: { c = c + 1 }
233
+ c is: 0
234
+
235
+ arr for_every: 1 do: { c = c + 1 }
236
+ c is: 2
237
+
238
+ c = 0
239
+ arr for_every: 2 do: { c = c + 1 }
240
+ c is: 2
241
+
242
+ c = 0
243
+ arr for_every: 2 do: { c = c + 1 }
244
+ c is: 2
245
+
246
+ c = 0
247
+ arr for_every: 3 do: { c = c + 1 }
248
+ c is: 1
249
+
250
+ arr for_every: 1 do: @{ is: 1 }
251
+ arr for_every: 2 do: @{ is: 2 }
252
+ arr for_every: 3 do: @{ is: 3 }
253
+ }
254
+
255
+ it: "returns the last index of an element or nil" with: 'last_index_of: when: {
256
+ [] last_index_of: nil . is: nil
257
+ [] last_index_of: 1 . is: nil
258
+ [1,2,1,2] last_index_of: 1 . is: 2
259
+ [1,2,1,2] last_index_of: 2 . is: 3
260
+ [1,2,1,2] last_index_of: 3 . is: nil
261
+ }
262
+
263
+ it: "is selected from it with each index" with: 'select_with_index: when: {
264
+ ["yooo",2,3,1,'foo,"bar"] select_with_index: |x i| { x is_a?: Fixnum } . is: [[2,1], [3,2], [1,3]]
265
+ }
266
+
267
+ it: "returns a chunked array based on a given block" with: 'chunk_by: when: {
268
+ [] chunk_by: @{ nil? } . is: []
269
+ [1] chunk_by: @{ nil? } . is: [[false, [1]]]
270
+ [1,2] chunk_by: @{ odd? } . is: [
271
+ [true, [1]],
272
+ [false, [2]]
273
+ ]
274
+
275
+ [1,3,4,5,7,2,6,8,10,9] do: @{
276
+ chunk_by: 'even? . is: [
277
+ [false, [1,3]],
278
+ [true, [4]],
279
+ [false, [5,7]],
280
+ [true, [2,6,8,10]],
281
+ [false, [9]]
282
+ ]
283
+
284
+ chunk_by: 'odd? . is: [
285
+ [true, [1,3]],
286
+ [false, [4]],
287
+ [true, [5,7]],
288
+ [false, [2,6,8,10]],
289
+ [true, [9]]
290
+ ]
291
+
292
+ chunk_by: 'nil? . is: [
293
+ [false, [1,3,4,5,7,2,6,8,10,9]]
294
+ ]
295
+ }
296
+ }
297
+
298
+ it: "returns a hash grouped by the value returned by a block called with the elements" with: 'group_by: when: {
299
+ [] group_by: 'nil? . is: <[]>
300
+ [1,3,5] group_by: @{ odd? } . is: <[true => [1,3,5]]>
301
+ (0,1,2,3) group_by: 'even? . is: <[false => [1,3], true => [0,2]]>
302
+ ('foo, 1, 2, 'bar) group_by: @{ class } . is: <[Symbol => ['foo, 'bar], Fixnum => [1,2]]>
303
+ "FooBar" group_by: @{ uppercase? } . is: <[true => ["F", "B"], false => ["o", "o", "a", "r"]]>
304
+ }
305
+
306
+ it: "returns its min and max value" with: 'min_max when: {
307
+ [] min_max is: (nil, nil)
308
+ [1] min_max is: (1, 1)
309
+ (1,2,3,4) min_max is: (1, 4)
310
+ (4,2,1,3) min_max is: (1, 4)
311
+ }
312
+
313
+ it: "returns its min and max value based on a given block" with: 'min_max_by: when: {
314
+ [] min_max_by: 'nil . is: (nil, nil)
315
+ ["foo"] min_max_by: 'size . is: ("foo", "foo")
316
+ ["a", "bc", "def"] min_max_by: @{ size } . is: ("a", "def")
317
+ ["long", "a", "bc", "def"] min_max_by: @{ size } . is: ("a", "long")
318
+ }
319
+
320
+ it: "returns the minimum" with: 'min when: {
321
+ [] min is: nil
322
+ [100] min is: 100
323
+ [0, 1] min is: 0
324
+ [-100, 100] min is: -100
325
+ [-4,-3,-2,-1,0,1,2,3,4,5] min is: -4
326
+ }
327
+
328
+ it: "returns the minimum based on a block" with: 'min_by: when: {
329
+ [] min_by: 'size . is: nil
330
+ [[1, 2, 3]] min_by: 'size . is: [1, 2, 3]
331
+ ["foo", "foobar"] min_by: @{ size } . is: "foo"
332
+ [[1, 2], ["foo", "bar", "baz"]] min_by: @{ size } . is: [1, 2]
333
+ }
334
+
335
+ it: "returns the maximum" with: 'max when: {
336
+ [] max is: nil
337
+ [100] max is: 100
338
+ [0, 1] max is: 1
339
+ [-100, 100] max is: 100
340
+ [-4,-3,-2,-1,0,1,2,3,4,5] max is: 5
341
+ }
342
+
343
+ it: "returns the maximum based on a block" with: 'max_by: when: {
344
+ [] max_by: 'size . is: nil
345
+ [[1, 2, 3]] max_by: 'size . is: [1, 2, 3]
346
+ ["foo", "foobar"] max_by: @{ size } . is: "foobar"
347
+ [[1, 2], ["foo", "bar", "baz"]] max_by: @{ size } . is: ["foo", "bar", "baz"]
348
+ }
349
+
350
+ it: "returns true if exactly one element yields true with a given block" with: 'one?: when: {
351
+ [] one?: 'nil? . is: false
352
+ (1,2) one?: 'odd? . is: true
353
+ (1,2,3) one?: 'odd? . is: false
354
+ "fooBar" one?: 'uppercase? . is: true
355
+ }
356
+
357
+ it: "returns true if a given block yields true for none of the elements" with: 'none?: when: {
358
+ [] none?: 'nil? . is: true
359
+ [1] none?: 'odd? . is: false
360
+ [1] none?: 'even? . is: true
361
+ [1,3,5] none?: 'even? . is: true
362
+ "foobarBaz" none?: 'uppercase? . is: false
363
+ }
364
+
365
+ it: "returns the sum of all the elements" with: 'sum when: {
366
+ [] sum is: 0
367
+ [1] sum is: 1
368
+ [-1,0,1] sum is: 0
369
+ (1,2,3) sum is: 6
370
+ }
371
+
372
+ it: "returns the product of all the elements" with: 'product when: {
373
+ [] product is: 1
374
+ [1] product is: 1
375
+ [1,2] product is: 2
376
+ [1,2,3] product is: 6
377
+ [-1,5,2] product is: -10
378
+ [1,0,1] product is: 0
379
+ }
380
+
381
+ it: "retuns the average value of all elements" with: 'average when: {
382
+ [] average is: 0
383
+ [1] average is: 1
384
+ [1,2] average is: 1.5
385
+ [2,4,6] average is: 4
386
+ [-1,0,1] average is: 0
387
+ [-1,1,2] average is: $ 2.0 / 3
388
+ }
157
389
  }
data/tests/enumerator.fy CHANGED
@@ -98,6 +98,13 @@ FancySpec describe: Fancy Enumerator with: {
98
98
  10 times: { enum ended? is: false; enum next } # move forward
99
99
  enum ended? is: true
100
100
  }
101
+
102
+ it: "is an Enumerable" when: {
103
+ enum = (1..9) to_enum
104
+ enum select: 'even? . is: [2,4,6,8]
105
+ enum rewind
106
+ enum map: @{ + 1 } . is: $ (2..10) to_a
107
+ }
101
108
  }
102
109
 
103
110
  # => [:each, :each_with_index, :each_with_object, :with_index, :with_object, :next_values, :peek_values, :next, :peek, :feed, :rewind, :inspect]
data/tests/file.fy CHANGED
@@ -17,6 +17,10 @@ FancySpec describe: File with: {
17
17
  }
18
18
  }
19
19
 
20
+ it: "reads all lines in a file correctly" with: 'readlines: when: {
21
+ File readlines: "README.md" . is: $ File read: "README.md" with: @{ readlines }
22
+ }
23
+
20
24
  it: "writes a file correctly" with: 'write:with: when: {
21
25
  dirname = "tmp"
22
26
  filename = "#{dirname}/write_test.txt"
@@ -140,4 +144,16 @@ FancySpec describe: File with: {
140
144
  ]>
141
145
  File delete: filename
142
146
  }
147
+
148
+ it: "overwrites a file correctly" with: 'overwrite:with: when: {
149
+ filename = "/tmp/#{Time now to_i random}_overwrite_test.fy"
150
+ try {
151
+ File write: filename with: @{ println: "foo"; println: "bar" }
152
+ File read: filename . is: "foo\nbar\n"
153
+ File overwrite: filename with: @{ println: "bar"; println: "foo" }
154
+ File read: filename . is: "bar\nfoo\n"
155
+ } finally {
156
+ File delete!: filename
157
+ }
158
+ }
143
159
  }
data/tests/future.fy CHANGED
@@ -16,19 +16,9 @@ FancySpec describe: FutureSend with: {
16
16
  a is: nil
17
17
  }
18
18
 
19
- # it: "composes Futures to create execution pipelines" with: '&& when: {
20
- # def some_computation: num {
21
- # num upto: (num ** num ** num)
22
- # }
23
-
24
- # f = self @ some_computation: 2 && @{select: 'even?} && @{size}
25
- # f is_a?: FutureSend . is: true
26
- # f value is_a?: Fixnum . is: true
27
- # }
28
-
29
19
  it: "accesses the same future from multiple threads and blocks them until the value is computed" when: {
30
20
  def another_method {
31
- Thread sleep: 0.25
21
+ Thread sleep: 0.01
32
22
  42
33
23
  }
34
24