fancy 0.3.0 → 0.3.1
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.
- data/{README → README.md} +33 -50
- data/Rakefile +6 -1
- data/bin/fyi +13 -10
- data/boot/fancy_ext.rb +1 -0
- data/boot/fancy_ext/block_env.rb +6 -2
- data/boot/fancy_ext/console.rb +4 -0
- data/boot/fancy_ext/object.rb +6 -0
- data/boot/rbx-compiler/compiler/ast/identifier.rb +5 -1
- data/boot/rbx-compiler/compiler/ast/match.rb +4 -5
- data/boot/rbx-compiler/compiler/ast/super.rb +1 -0
- data/boot/rbx-compiler/parser/fancy_parser.bundle +0 -0
- data/boot/rbx-compiler/parser/lexer.c +2316 -0
- data/boot/rbx-compiler/parser/lexer.h +315 -0
- data/boot/rbx-compiler/parser/parser.c +3105 -0
- data/boot/rbx-compiler/parser/parser.h +114 -0
- data/boot/rbx-compiler/parser/parser.rb +2 -2
- data/boot/rbx-compiler/parser/parser.y +3 -3
- data/doc/api/fancy.jsonp +1 -1
- data/doc/features.md +14 -3
- data/examples/async_send.fy +11 -0
- data/examples/fibonacci.fy +1 -1
- data/examples/future.fy +30 -0
- data/examples/futures.fy +14 -0
- data/examples/game_of_life.fy +1 -1
- data/examples/matchers.fy +1 -1
- data/examples/pattern_matching.fy +3 -3
- data/examples/stupid_quicksort.fy +1 -1
- data/examples/threads.fy +1 -1
- data/extconf.rb +7 -0
- data/lib/array.fy +25 -5
- data/lib/block.fy +20 -18
- data/lib/boot.fy +7 -2
- data/lib/class.fy +33 -2
- data/lib/compiler/ast.fy +2 -0
- data/lib/compiler/ast/assign.fy +5 -5
- data/lib/compiler/ast/async_send.fy +25 -0
- data/lib/compiler/ast/block.fy +3 -3
- data/lib/compiler/ast/future_send.fy +20 -0
- data/lib/compiler/ast/identifier.fy +13 -7
- data/lib/compiler/ast/match.fy +32 -22
- data/lib/compiler/ast/message_send.fy +4 -4
- data/lib/compiler/ast/method_def.fy +1 -1
- data/lib/compiler/ast/script.fy +2 -2
- data/lib/compiler/ast/super.fy +1 -0
- data/lib/compiler/compiler.fy +2 -0
- data/lib/documentation.fy +4 -4
- data/lib/enumerable.fy +14 -7
- data/lib/fancy_spec.fy +2 -2
- data/lib/fdoc.fy +7 -7
- data/lib/fiber.fy +11 -0
- data/lib/fiber_pool.fy +78 -0
- data/lib/file.fy +1 -1
- data/lib/future.fy +32 -0
- data/lib/hash.fy +5 -5
- data/lib/lazy_array.fy +23 -0
- data/lib/main.fy +35 -25
- data/lib/method.fy +1 -1
- data/lib/nil_class.fy +4 -0
- data/lib/object.fy +59 -7
- data/lib/package.fy +11 -2
- data/lib/package/installer.fy +50 -20
- data/lib/package/list.fy +34 -0
- data/lib/package/specification.fy +19 -1
- data/lib/parser/ext/Makefile +162 -0
- data/lib/parser/ext/lexer.c +2360 -0
- data/lib/parser/ext/lexer.h +315 -0
- data/lib/parser/ext/lexer.lex +4 -0
- data/lib/parser/ext/parser.c +3382 -0
- data/lib/parser/ext/parser.h +118 -0
- data/lib/parser/ext/parser.y +43 -3
- data/lib/parser/methods.fy +34 -7
- data/lib/parser/parse_error.fy +10 -0
- data/lib/proxy.fy +16 -0
- data/lib/rbx.fy +3 -0
- data/lib/rbx/array.fy +78 -40
- data/lib/rbx/block.fy +35 -1
- data/lib/rbx/class.fy +5 -3
- data/lib/rbx/code_loader.fy +6 -6
- data/lib/rbx/console.fy +1 -1
- data/lib/rbx/date.fy +12 -0
- data/lib/rbx/documentation.fy +5 -5
- data/lib/rbx/exception.fy +1 -1
- data/lib/rbx/fiber.fy +4 -8
- data/lib/rbx/file.fy +4 -3
- data/lib/rbx/fixnum.fy +1 -0
- data/lib/rbx/float.fy +1 -0
- data/lib/rbx/hash.fy +3 -2
- data/lib/rbx/io.fy +5 -5
- data/lib/rbx/match_data.fy +10 -0
- data/lib/rbx/method.fy +4 -4
- data/lib/rbx/no_method_error.fy +1 -1
- data/lib/rbx/object.fy +8 -15
- data/lib/rbx/regexp.fy +4 -0
- data/lib/rbx/string.fy +39 -1
- data/lib/rbx/symbol.fy +1 -1
- data/lib/rbx/system.fy +0 -6
- data/lib/rbx/thread.fy +5 -0
- data/lib/rbx/time.fy +14 -0
- data/lib/rbx/tuple.fy +1 -0
- data/lib/set.fy +1 -1
- data/lib/stack.fy +1 -1
- data/lib/string.fy +2 -2
- data/lib/thread_pool.fy +101 -0
- data/lib/tuple.fy +37 -6
- data/ruby_lib/fancy.rb +46 -0
- data/tests/block.fy +39 -0
- data/tests/class.fy +40 -1
- data/tests/file.fy +2 -2
- data/tests/hash.fy +7 -7
- data/tests/nil_class.fy +2 -2
- data/tests/object.fy +10 -2
- data/tests/pattern_matching.fy +18 -7
- metadata +34 -7
data/tests/nil_class.fy
CHANGED
@@ -22,11 +22,11 @@ FancySpec describe: NilClass with: {
|
|
22
22
|
|
23
23
|
it: "should be true for calling || with any non-nil value" for: '|| when: {
|
24
24
|
(nil || true) should == true
|
25
|
-
(nil || 'foo) should ==
|
25
|
+
(nil || 'foo) should == 'foo
|
26
26
|
}
|
27
27
|
|
28
28
|
it: "should be nil for calling || with a nil value" for: '|| when: {
|
29
|
-
(nil || nil) should ==
|
29
|
+
(nil || nil) should == nil
|
30
30
|
}
|
31
31
|
|
32
32
|
it: "should NOT call the block" for: 'if_true: when: {
|
data/tests/object.fy
CHANGED
@@ -101,8 +101,8 @@ FancySpec describe: Object with: {
|
|
101
101
|
}
|
102
102
|
|
103
103
|
it: "should be true for calling || with any value" for: '|| when: {
|
104
|
-
('foo || 'bar) should ==
|
105
|
-
('foo || nil) should ==
|
104
|
+
('foo || 'bar) should == 'foo
|
105
|
+
('foo || nil) should == 'foo
|
106
106
|
}
|
107
107
|
|
108
108
|
# end boolean messages
|
@@ -122,4 +122,12 @@ FancySpec describe: Object with: {
|
|
122
122
|
'foo true? should == nil
|
123
123
|
"hello, world" true? should == nil
|
124
124
|
}
|
125
|
+
|
126
|
+
it: "should return the correct value" for: 'returning:do: when: {
|
127
|
+
returning: [] do: |arr| {
|
128
|
+
arr << 1
|
129
|
+
arr << 2
|
130
|
+
arr << 3
|
131
|
+
} . should == [1,2,3]
|
132
|
+
}
|
125
133
|
}
|
data/tests/pattern_matching.fy
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
FancySpec describe: "Pattern Matching" with: {
|
2
2
|
it: "should match a value correctly by its class" when: {
|
3
3
|
def do_match: obj {
|
4
|
-
match obj
|
4
|
+
match obj {
|
5
5
|
case String -> 'string
|
6
6
|
case Fixnum -> 'fixnum
|
7
7
|
case _ -> 'anything
|
@@ -16,7 +16,7 @@ FancySpec describe: "Pattern Matching" with: {
|
|
16
16
|
}
|
17
17
|
|
18
18
|
it: "should bind a given match arg, if present, to the result of the match operation" when: {
|
19
|
-
match "foobarbaz"
|
19
|
+
match "foobarbaz" {
|
20
20
|
case /foo([a-z]+)baz/ -> |matcher|
|
21
21
|
local1, local2, local3 = 'ignore, 'this_too, 'this_also
|
22
22
|
matcher[1] should == "bar"
|
@@ -24,7 +24,7 @@ FancySpec describe: "Pattern Matching" with: {
|
|
24
24
|
}
|
25
25
|
|
26
26
|
it: "should only bind given match arg to the scope of the match case" when: {
|
27
|
-
match "foobarbaz"
|
27
|
+
match "foobarbaz" {
|
28
28
|
case /foo([a-z]+)baz/ -> |local_of_case|
|
29
29
|
local_of_case == nil . should == false
|
30
30
|
}
|
@@ -33,7 +33,7 @@ FancySpec describe: "Pattern Matching" with: {
|
|
33
33
|
}
|
34
34
|
|
35
35
|
it: "should only bind locals of the match clause to the scope of the match case" when: {
|
36
|
-
match "foobarbaz"
|
36
|
+
match "foobarbaz" {
|
37
37
|
case /foo([a-z]+)baz/ -> |local_of_case|
|
38
38
|
local1 = "Hi, I am some local, that should be gone after this block."
|
39
39
|
}
|
@@ -43,7 +43,7 @@ FancySpec describe: "Pattern Matching" with: {
|
|
43
43
|
|
44
44
|
it: "should bind any additional match args to the matched values" when: {
|
45
45
|
str = "foo bar baz"
|
46
|
-
match str
|
46
|
+
match str {
|
47
47
|
case /^foo (.*) (.*)$/ -> |all, match1, match2|
|
48
48
|
all class should == MatchData
|
49
49
|
match1 should == "bar"
|
@@ -56,7 +56,7 @@ FancySpec describe: "Pattern Matching" with: {
|
|
56
56
|
(num, num * num) # create a Tuple
|
57
57
|
}
|
58
58
|
|
59
|
-
match create_tuple: 10
|
59
|
+
match create_tuple: 10 {
|
60
60
|
case Tuple -> |md, x, y, z|
|
61
61
|
# convention: md[0] always holds the entire object that was matched.
|
62
62
|
md[0] should == (create_tuple: 10)
|
@@ -71,7 +71,7 @@ FancySpec describe: "Pattern Matching" with: {
|
|
71
71
|
[num, num ** 2, num ** 3, num ** 4]
|
72
72
|
}
|
73
73
|
|
74
|
-
match create_array: 2
|
74
|
+
match create_array: 2 {
|
75
75
|
case Array -> |_, a,b,c,d|
|
76
76
|
a should == 2
|
77
77
|
b should == (2 ** 2)
|
@@ -79,4 +79,15 @@ FancySpec describe: "Pattern Matching" with: {
|
|
79
79
|
d should == (2 ** 4)
|
80
80
|
}
|
81
81
|
}
|
82
|
+
|
83
|
+
it: "should not try to bind the match args if the match failed" when: {
|
84
|
+
["hello world!", "hello you!", "no hello here!"] each: |str| {
|
85
|
+
match str {
|
86
|
+
case /^hello (.*)$/ -> |_, name|
|
87
|
+
name should_not == nil
|
88
|
+
|
89
|
+
case _ -> name should == nil
|
90
|
+
}
|
91
|
+
}
|
92
|
+
}
|
82
93
|
}
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fancy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 1
|
10
|
+
version: 0.3.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Christopher Bertels
|
@@ -37,24 +37,28 @@ executables:
|
|
37
37
|
- ifancy
|
38
38
|
- fdoc
|
39
39
|
- fyi
|
40
|
-
extensions:
|
41
|
-
|
40
|
+
extensions:
|
41
|
+
- extconf.rb
|
42
42
|
extra_rdoc_files: []
|
43
43
|
|
44
44
|
files:
|
45
|
-
- README
|
45
|
+
- README.md
|
46
46
|
- LICENSE
|
47
47
|
- AUTHORS
|
48
48
|
- Rakefile
|
49
|
+
- extconf.rb
|
50
|
+
- ruby_lib/fancy.rb
|
49
51
|
- lib/argv.fy
|
50
52
|
- lib/array.fy
|
51
53
|
- lib/block.fy
|
52
54
|
- lib/boot.fy
|
53
55
|
- lib/class.fy
|
54
56
|
- lib/compiler/ast/assign.fy
|
57
|
+
- lib/compiler/ast/async_send.fy
|
55
58
|
- lib/compiler/ast/block.fy
|
56
59
|
- lib/compiler/ast/class_def.fy
|
57
60
|
- lib/compiler/ast/expression_list.fy
|
61
|
+
- lib/compiler/ast/future_send.fy
|
58
62
|
- lib/compiler/ast/identifier.fy
|
59
63
|
- lib/compiler/ast/literals.fy
|
60
64
|
- lib/compiler/ast/match.fy
|
@@ -81,8 +85,12 @@ files:
|
|
81
85
|
- lib/fancy_spec.fy
|
82
86
|
- lib/fdoc.fy
|
83
87
|
- lib/fdoc_hook.fy
|
88
|
+
- lib/fiber.fy
|
89
|
+
- lib/fiber_pool.fy
|
84
90
|
- lib/file.fy
|
91
|
+
- lib/future.fy
|
85
92
|
- lib/hash.fy
|
93
|
+
- lib/lazy_array.fy
|
86
94
|
- lib/main.fy
|
87
95
|
- lib/method.fy
|
88
96
|
- lib/nil_class.fy
|
@@ -90,17 +98,21 @@ files:
|
|
90
98
|
- lib/object.fy
|
91
99
|
- lib/package/dependency.fy
|
92
100
|
- lib/package/installer.fy
|
101
|
+
- lib/package/list.fy
|
93
102
|
- lib/package/specification.fy
|
94
103
|
- lib/package/uninstaller.fy
|
95
104
|
- lib/package.fy
|
96
105
|
- lib/parser/methods.fy
|
106
|
+
- lib/parser/parse_error.fy
|
97
107
|
- lib/parser.fy
|
108
|
+
- lib/proxy.fy
|
98
109
|
- lib/rbx/array.fy
|
99
110
|
- lib/rbx/bignum.fy
|
100
111
|
- lib/rbx/block.fy
|
101
112
|
- lib/rbx/class.fy
|
102
113
|
- lib/rbx/code_loader.fy
|
103
114
|
- lib/rbx/console.fy
|
115
|
+
- lib/rbx/date.fy
|
104
116
|
- lib/rbx/directory.fy
|
105
117
|
- lib/rbx/documentation.fy
|
106
118
|
- lib/rbx/environment_variables.fy
|
@@ -126,6 +138,7 @@ files:
|
|
126
138
|
- lib/rbx/tcp_server.fy
|
127
139
|
- lib/rbx/tcp_socket.fy
|
128
140
|
- lib/rbx/thread.fy
|
141
|
+
- lib/rbx/time.fy
|
129
142
|
- lib/rbx/tuple.fy
|
130
143
|
- lib/rbx.fy
|
131
144
|
- lib/set.fy
|
@@ -133,13 +146,19 @@ files:
|
|
133
146
|
- lib/string.fy
|
134
147
|
- lib/struct.fy
|
135
148
|
- lib/symbol.fy
|
149
|
+
- lib/thread_pool.fy
|
136
150
|
- lib/true_class.fy
|
137
151
|
- lib/tuple.fy
|
138
152
|
- lib/version.fy
|
139
153
|
- lib/parser/ext/ext.c
|
140
154
|
- lib/parser/ext/ext.h
|
141
155
|
- lib/parser/ext/extconf.rb
|
156
|
+
- lib/parser/ext/lexer.c
|
157
|
+
- lib/parser/ext/lexer.h
|
142
158
|
- lib/parser/ext/lexer.lex
|
159
|
+
- lib/parser/ext/Makefile
|
160
|
+
- lib/parser/ext/parser.c
|
161
|
+
- lib/parser/ext/parser.h
|
143
162
|
- lib/parser/ext/parser.y
|
144
163
|
- lib/parser/ext/README
|
145
164
|
- tests/argv.fy
|
@@ -174,6 +193,7 @@ files:
|
|
174
193
|
- examples/arithmetic.fy
|
175
194
|
- examples/armstrong_numbers.fy
|
176
195
|
- examples/array.fy
|
196
|
+
- examples/async_send.fy
|
177
197
|
- examples/blocks.fy
|
178
198
|
- examples/boolean.fy
|
179
199
|
- examples/call_with_receiver.fy
|
@@ -191,6 +211,8 @@ files:
|
|
191
211
|
- examples/fibonacci.fy
|
192
212
|
- examples/files.fy
|
193
213
|
- examples/finally.fy
|
214
|
+
- examples/future.fy
|
215
|
+
- examples/futures.fy
|
194
216
|
- examples/game_of_life.fy
|
195
217
|
- examples/hashes.fy
|
196
218
|
- examples/hello_world.fy
|
@@ -237,6 +259,7 @@ files:
|
|
237
259
|
- boot/compile.fy
|
238
260
|
- boot/fancy_ext/block_env.rb
|
239
261
|
- boot/fancy_ext/class.rb
|
262
|
+
- boot/fancy_ext/console.rb
|
240
263
|
- boot/fancy_ext/kernel.rb
|
241
264
|
- boot/fancy_ext/module.rb
|
242
265
|
- boot/fancy_ext/object.rb
|
@@ -274,7 +297,11 @@ files:
|
|
274
297
|
- boot/rbx-compiler/parser/fancy_parser.bundle
|
275
298
|
- boot/rbx-compiler/parser/fancy_parser.c
|
276
299
|
- boot/rbx-compiler/parser/fancy_parser.h
|
300
|
+
- boot/rbx-compiler/parser/lexer.c
|
301
|
+
- boot/rbx-compiler/parser/lexer.h
|
277
302
|
- boot/rbx-compiler/parser/lexer.lex
|
303
|
+
- boot/rbx-compiler/parser/parser.c
|
304
|
+
- boot/rbx-compiler/parser/parser.h
|
278
305
|
- boot/rbx-compiler/parser/parser.rb
|
279
306
|
- boot/rbx-compiler/parser/parser.y
|
280
307
|
- boot/rbx-compiler/parser/Rakefile
|
@@ -291,7 +318,7 @@ post_install_message:
|
|
291
318
|
rdoc_options: []
|
292
319
|
|
293
320
|
require_paths:
|
294
|
-
-
|
321
|
+
- ruby_lib
|
295
322
|
required_ruby_version: !ruby/object:Gem::Requirement
|
296
323
|
none: false
|
297
324
|
requirements:
|