fancy 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. data/bin/fancy +1 -1
  2. data/bin/fspec +1 -1
  3. data/bin/ifancy +1 -0
  4. data/boot/compiler/parser/ext/fancy_parser.bundle +0 -0
  5. data/boot/fancy_ext/array.rb +0 -1
  6. data/boot/fancy_ext/object.rb +10 -0
  7. data/boot/rbx-compiler/parser/Makefile +207 -0
  8. data/boot/rbx-compiler/parser/fancy_parser.bundle +0 -0
  9. data/boot/rbx-compiler/parser/lexer.c +2314 -0
  10. data/boot/rbx-compiler/parser/lexer.h +316 -0
  11. data/boot/rbx-compiler/parser/parser.c +3133 -0
  12. data/boot/rbx-compiler/parser/parser.h +131 -0
  13. data/doc/api/fancy.jsonp +1 -1
  14. data/examples/echo.fy +1 -1
  15. data/examples/stupid_quicksort.fy +1 -1
  16. data/lib/array.fy +4 -0
  17. data/lib/block.fy +11 -8
  18. data/lib/class.fy +21 -0
  19. data/lib/compiler/ast.fy +1 -0
  20. data/lib/compiler/ast/identifier.fy +1 -3
  21. data/lib/compiler/ast/method_spec.fy +6 -0
  22. data/lib/contracts.fy +2 -2
  23. data/lib/documentation.fy +25 -24
  24. data/lib/enumerable.fy +38 -21
  25. data/lib/fancy_spec.fy +24 -17
  26. data/lib/fdoc.fy +32 -16
  27. data/lib/future.fy +26 -1
  28. data/lib/object.fy +4 -1
  29. data/lib/parser/ext/Makefile +207 -0
  30. data/lib/parser/ext/fancy_parser.bundle +0 -0
  31. data/lib/parser/ext/lexer.c +2442 -0
  32. data/lib/parser/ext/lexer.h +316 -0
  33. data/lib/parser/ext/lexer.lex +4 -4
  34. data/lib/parser/ext/parser.c +3400 -0
  35. data/lib/parser/ext/parser.h +135 -0
  36. data/lib/parser/ext/parser.y +52 -74
  37. data/lib/parser/methods.fy +20 -8
  38. data/lib/parser/parse_error.fy +2 -2
  39. data/lib/range.fy +1 -1
  40. data/lib/rbx.fy +1 -0
  41. data/lib/rbx/block.fy +0 -12
  42. data/lib/rbx/class.fy +1 -1
  43. data/lib/rbx/compiled_method.fy +4 -0
  44. data/lib/{eval.fy → rbx/eval.fy} +3 -3
  45. data/lib/rbx/hash.fy +13 -3
  46. data/lib/rbx/method.fy +1 -0
  47. data/lib/rbx/object.fy +5 -1
  48. data/lib/rbx/range.fy +1 -1
  49. data/lib/rbx/scopes.fy +15 -0
  50. data/lib/rbx/symbol.fy +4 -0
  51. data/lib/rbx/thread.fy +1 -1
  52. data/lib/set.fy +11 -0
  53. data/lib/string.fy +17 -17
  54. data/lib/symbol.fy +7 -3
  55. data/lib/tuple.fy +3 -8
  56. data/lib/version.fy +1 -1
  57. data/ruby_lib/fancy +1 -1
  58. data/ruby_lib/fancy.rb +6 -19
  59. data/ruby_lib/interactive/hilight.rb +5 -5
  60. data/tests/block.fy +36 -13
  61. data/tests/class.fy +124 -120
  62. data/tests/contracts.fy +9 -8
  63. data/tests/future.fy +29 -10
  64. data/tests/method.fy +5 -0
  65. data/tests/range.fy +8 -0
  66. data/tests/set.fy +16 -6
  67. data/tests/struct.fy +4 -4
  68. metadata +60 -55
  69. data/lib/queue.fy +0 -7
  70. data/tests/future_proxy.fy +0 -8
@@ -27,14 +27,15 @@ FancySpec describe: Class Contracts with: {
27
27
  class Interface {
28
28
  expects_interface_on_inclusion: ['hello, 'world]
29
29
  }
30
+
30
31
  {
31
32
  class C {
32
33
  include: Interface
33
34
  }
34
- } raises: Class Contracts InterfaceNotImplementedError with: |e| {
35
- e methods is: ['hello, 'world]
36
- e interface is: Interface
37
- e including_class is: C
35
+ } raises: Class Contracts InterfaceNotImplementedError with: @{
36
+ methods is: ['hello, 'world]
37
+ interface is: Interface
38
+ including_class is: C
38
39
  }
39
40
 
40
41
  {
@@ -42,10 +43,10 @@ FancySpec describe: Class Contracts with: {
42
43
  def hello
43
44
  include: Interface
44
45
  }
45
- } raises: Class Contracts InterfaceNotImplementedError with: |e| {
46
- e methods is: ['world]
47
- e interface is: Interface
48
- e including_class is: D
46
+ } raises: Class Contracts InterfaceNotImplementedError with: @{
47
+ methods is: ['world]
48
+ interface is: Interface
49
+ including_class is: D
49
50
  }
50
51
  }
51
52
  }
@@ -18,7 +18,7 @@ FancySpec describe: FutureSend with: {
18
18
 
19
19
  it: "accesses the same future from multiple threads and blocks them until the value is computed" when: {
20
20
  def another_method {
21
- Thread sleep: 0.01
21
+ Thread sleep: 0.1
22
22
  42
23
23
  }
24
24
 
@@ -67,14 +67,15 @@ FancySpec describe: FutureSend with: {
67
67
  called? = false
68
68
  failed? = false
69
69
  val = 0
70
- f = { Thread sleep: 0.01; "Fail!" raise! } @ call
71
- f when_done: |v| {
72
- val = v
73
- called? = true
74
- }
75
- f when_failed: |err| {
76
- val = err
77
- failed? = true
70
+ f = { Thread sleep: 0.01; "Fail!" raise! } @ call . tap: @{
71
+ when_done: |v| {
72
+ val = v
73
+ called? = true
74
+ }
75
+ when_failed: |err| {
76
+ val = err
77
+ failed? = true
78
+ }
78
79
  }
79
80
 
80
81
  f value
@@ -83,4 +84,22 @@ FancySpec describe: FutureSend with: {
83
84
  val message is: "Fail!"
84
85
  val is_a?: Exception
85
86
  }
86
- }
87
+ }
88
+
89
+ FancySpec describe: FutureCollection with: {
90
+ it: "iterates over each future's value" with: 'each: when: {
91
+ futures = ("a".."z") map: |l| { l @ inspect }
92
+ FutureCollection[futures] each: |val| {
93
+ val =~ /[a-z]/ . is_not: nil
94
+ }
95
+ }
96
+
97
+ it: "awaits all futures to complete" with: 'await_all when: {
98
+ futures = (0..100) map: |i| {
99
+ { Thread sleep: 0.01; i * 2 } @ call
100
+ }
101
+ futures all?: @{ completed? } . is: false
102
+ FutureCollection[futures] await_all
103
+ futures all?: @{ completed? } . is: true
104
+ }
105
+ }
@@ -135,4 +135,9 @@ FancySpec describe: Method with: {
135
135
  def obj bar
136
136
  def obj bar: @x
137
137
  }
138
+
139
+ it: "parses correcly / with a single slash on method body" when: {
140
+ def / x { '/ }
141
+ self / 1 . is: '/
142
+ }
138
143
  }
@@ -8,4 +8,12 @@ FancySpec describe: Range with: {
8
8
  it: "has a working literal syntax" when: {
9
9
  (1..10) is: (Range new: 1 to: 10)
10
10
  }
11
+
12
+ it: "returns a string representation" with: ['inspect, 'to_s] when: {
13
+ (1..10) inspect is: "(1..10)"
14
+ (100..1000) tap: @{
15
+ inspect is: "(100..1000)"
16
+ to_s is: "(100..1000)"
17
+ }
18
+ }
11
19
  }
@@ -24,7 +24,7 @@ FancySpec describe: Set with: {
24
24
  s << 'foo
25
25
  s << 'foo
26
26
  s size is: 1
27
- s is: (Set[['foo]])
27
+ s is: $ Set[['foo]]
28
28
  s is_not: ['foo] # Sets and Arrays differ
29
29
  }
30
30
 
@@ -100,9 +100,9 @@ FancySpec describe: Set with: {
100
100
  it: "removes a value in the Set" with: 'remove: when: {
101
101
  s = Set[(1,2,3)]
102
102
  s remove: 2
103
- s is: (Set[(1,3)])
103
+ s is: $ Set[(1,3)]
104
104
  s remove: 1
105
- s is: (Set[[3]])
105
+ s is: $ Set[[3]]
106
106
  s remove: 3
107
107
  s empty? . is: true
108
108
  }
@@ -110,18 +110,28 @@ FancySpec describe: Set with: {
110
110
  it: "returns the union of two sets" with: '+ when: {
111
111
  s1 = Set[(1,2,3)]
112
112
  s2 = Set[(3,4,5)]
113
- s1 + s2 is: (Set[(1,2,3,4,5)])
113
+ s1 + s2 is: $ Set[(1,2,3,4,5)]
114
114
  }
115
115
 
116
116
  it: "returns the difference of two sets" with: '- when: {
117
117
  s1 = Set[(1,2,3)]
118
118
  s2 = Set[(3,4,5)]
119
- s1 - s2 is: (Set[(1,2)])
119
+ s1 - s2 is: $ Set[(1,2)]
120
120
  }
121
121
 
122
122
  it: "returns the intersection of two sets" with: '& when: {
123
123
  s1 = Set[(1,2,3)]
124
124
  s2 = Set[(2,3,4,5)]
125
- s1 & s2 is: (Set[(2,3)])
125
+ s1 & s2 is: $ Set[(2,3)]
126
+ }
127
+
128
+ it: "removes all elements from a Set" with: 'clear when: {
129
+ s = Set[(1,2,3)]
130
+ s empty? is: false
131
+ s size is: 3
132
+ s clear
133
+ s empty? is: true
134
+ s size is: 0
135
+ s is: $ Set[[]]
126
136
  }
127
137
  }
@@ -6,13 +6,13 @@ FancySpec describe: Struct with: {
6
6
  }
7
7
 
8
8
  it: "creates setter methods for a struct's fields" when: {
9
- Point instance_methods includes?: "x:" . is: true
10
- Point instance_methods includes?: "y:" . is: true
9
+ Point instance_methods includes?: 'x: . is: true
10
+ Point instance_methods includes?: 'y: . is: true
11
11
  }
12
12
 
13
13
  it: "creates getter methods for a struct's fields" when: {
14
- Point instance_methods includes?: ":x" . is: true
15
- Point instance_methods includes?: ":y" . is: true
14
+ Point instance_methods includes?: ':x . is: true
15
+ Point instance_methods includes?: ':y . is: true
16
16
  }
17
17
 
18
18
  it: "works with getter and setter methods as expected" when: {
metadata CHANGED
@@ -1,60 +1,63 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: fancy
3
- version: !ruby/object:Gem::Version
4
- hash: 1509009585894205680
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.10.0
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 9
9
- - 0
10
- version: 0.9.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Christopher Bertels
14
9
  autorequire:
15
10
  bindir: ruby_lib
16
11
  cert_chain: []
17
-
18
- date: 2013-06-05 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2013-07-30 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: rubinius-actor
22
16
  prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
24
22
  none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 2002549777813010636
29
- segments:
30
- - 0
31
- version: "0"
32
23
  type: :runtime
33
- version_requirements: *id001
34
- description: |
35
- The Fancy Programming Language
36
-
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ! '>='
27
+ - !ruby/object:Gem::Version
28
+ version: '0'
29
+ none: false
30
+ description: ! 'The Fancy Programming Language
31
+
32
+
37
33
  Fancy is a fully self-hosted, dynamic, pure class-based
34
+
38
35
  object-oriented programming language heavily inspired by Smalltalk,
36
+
39
37
  Ruby and Erlang. It supports dynamic code evaluation (as in Ruby &
38
+
40
39
  Smalltalk), class-based mixins, generic pattern matching, runtime
40
+
41
41
  introspection & reflection, "monkey patching" and much more. It runs
42
+
42
43
  on Rubinius, the Ruby VM, and thus has first-class integration with
43
- Ruby's core library and any additional Ruby libraries that run on
44
+
45
+ Ruby''s core library and any additional Ruby libraries that run on
46
+
44
47
  Rubinius, including most C-extensions.
45
48
 
49
+ '
46
50
  email: chris@fancy-lang.org
47
- executables:
51
+ executables:
48
52
  - fancy
49
53
  - ifancy
50
54
  - fdoc
51
55
  - fyi
52
56
  - fspec
53
- extensions:
57
+ extensions:
54
58
  - boot/extconf.rb
55
59
  extra_rdoc_files: []
56
-
57
- files:
60
+ files:
58
61
  - README.md
59
62
  - LICENSE
60
63
  - AUTHORS
@@ -78,7 +81,6 @@ files:
78
81
  - lib/dynamic_slot_object.fy
79
82
  - lib/enumerable.fy
80
83
  - lib/enumerator.fy
81
- - lib/eval.fy
82
84
  - lib/exception.fy
83
85
  - lib/false_class.fy
84
86
  - lib/fancy_spec.fy
@@ -102,7 +104,6 @@ files:
102
104
  - lib/package.fy
103
105
  - lib/parser.fy
104
106
  - lib/proxies.fy
105
- - lib/queue.fy
106
107
  - lib/range.fy
107
108
  - lib/rbx.fy
108
109
  - lib/set.fy
@@ -145,6 +146,7 @@ files:
145
146
  - lib/rbx/directory.fy
146
147
  - lib/rbx/documentation.fy
147
148
  - lib/rbx/environment_variables.fy
149
+ - lib/rbx/eval.fy
148
150
  - lib/rbx/exception.fy
149
151
  - lib/rbx/fiber.fy
150
152
  - lib/rbx/file.fy
@@ -163,6 +165,7 @@ files:
163
165
  - lib/rbx/proc.fy
164
166
  - lib/rbx/range.fy
165
167
  - lib/rbx/regexp.fy
168
+ - lib/rbx/scopes.fy
166
169
  - lib/rbx/string.fy
167
170
  - lib/rbx/stringio.fy
168
171
  - lib/rbx/symbol.fy
@@ -183,6 +186,7 @@ files:
183
186
  - lib/compiler/ast/match.fy
184
187
  - lib/compiler/ast/message_send.fy
185
188
  - lib/compiler/ast/method_def.fy
189
+ - lib/compiler/ast/method_spec.fy
186
190
  - lib/compiler/ast/node.fy
187
191
  - lib/compiler/ast/range.fy
188
192
  - lib/compiler/ast/return.fy
@@ -195,7 +199,13 @@ files:
195
199
  - lib/parser/ext/ext.c
196
200
  - lib/parser/ext/ext.h
197
201
  - lib/parser/ext/extconf.rb
202
+ - lib/parser/ext/fancy_parser.bundle
203
+ - lib/parser/ext/lexer.c
204
+ - lib/parser/ext/lexer.h
198
205
  - lib/parser/ext/lexer.lex
206
+ - lib/parser/ext/Makefile
207
+ - lib/parser/ext/parser.c
208
+ - lib/parser/ext/parser.h
199
209
  - lib/parser/ext/parser.y
200
210
  - lib/parser/ext/README
201
211
  - tests/argv.fy
@@ -216,7 +226,6 @@ files:
216
226
  - tests/file.fy
217
227
  - tests/fixnum.fy
218
228
  - tests/future.fy
219
- - tests/future_proxy.fy
220
229
  - tests/hash.fy
221
230
  - tests/html.fy
222
231
  - tests/integer.fy
@@ -327,7 +336,12 @@ files:
327
336
  - boot/rbx-compiler/parser/fancy_parser.bundle
328
337
  - boot/rbx-compiler/parser/fancy_parser.c
329
338
  - boot/rbx-compiler/parser/fancy_parser.h
339
+ - boot/rbx-compiler/parser/lexer.c
340
+ - boot/rbx-compiler/parser/lexer.h
330
341
  - boot/rbx-compiler/parser/lexer.lex
342
+ - boot/rbx-compiler/parser/Makefile
343
+ - boot/rbx-compiler/parser/parser.c
344
+ - boot/rbx-compiler/parser/parser.h
331
345
  - boot/rbx-compiler/parser/parser.rb
332
346
  - boot/rbx-compiler/parser/parser.y
333
347
  - boot/rbx-compiler/parser/Rakefile
@@ -353,39 +367,30 @@ files:
353
367
  - boot/rbx-compiler/compiler/ast/super.rb
354
368
  - boot/rbx-compiler/compiler/ast/try_catch_block.rb
355
369
  - boot/rbx-compiler/compiler/ast/tuple_literal.rb
370
+ - boot/compiler/parser/ext/fancy_parser.bundle
356
371
  homepage: http://www.fancy-lang.org
357
- licenses:
372
+ licenses:
358
373
  - BSD
359
374
  post_install_message:
360
375
  rdoc_options: []
361
-
362
- require_paths:
376
+ require_paths:
363
377
  - ruby_lib
364
- required_ruby_version: !ruby/object:Gem::Requirement
378
+ required_ruby_version: !ruby/object:Gem::Requirement
379
+ requirements:
380
+ - - ! '>='
381
+ - !ruby/object:Gem::Version
382
+ version: 1.9.3
365
383
  none: false
366
- requirements:
367
- - - ">="
368
- - !ruby/object:Gem::Version
369
- hash: 2002549777813010636
370
- segments:
371
- - 0
372
- version: "0"
373
- required_rubygems_version: !ruby/object:Gem::Requirement
384
+ required_rubygems_version: !ruby/object:Gem::Requirement
385
+ requirements:
386
+ - - ! '>='
387
+ - !ruby/object:Gem::Version
388
+ version: '0'
374
389
  none: false
375
- requirements:
376
- - - ">="
377
- - !ruby/object:Gem::Version
378
- hash: 2002549777813010636
379
- segments:
380
- - 0
381
- version: "0"
382
390
  requirements: []
383
-
384
391
  rubyforge_project: fancy
385
392
  rubygems_version: 1.8.25
386
393
  signing_key:
387
394
  specification_version: 3
388
395
  summary: The Fancy Programming Language
389
396
  test_files: []
390
-
391
- has_rdoc: false
@@ -1,7 +0,0 @@
1
- class Queue {
2
- forwards_unary_ruby_methods
3
-
4
- ruby_aliases: ['<<, 'clear, 'deq, 'empty?, 'length, 'num_waiting, 'pop, 'shift, 'size]
5
- alias_method: 'push: for_ruby: 'push
6
- alias_method: 'enqueue: for_ruby: 'enq
7
- }
@@ -1,8 +0,0 @@
1
- # FancySpec describe: FutureProxy with: {
2
- # it: "returns a FutureProxy" with: 'future when: {
3
- # f = "foo" future
4
- # "yo: #{f to_s inspect}" println
5
- # "foo" future: @{ println }
6
- # }
7
- # }
8
- nil