fancy 0.8.0 → 0.9.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.
- data/LICENSE +1 -1
- data/README.md +5 -4
- data/bin/fspec +19 -1
- data/bin/ifancy +139 -35
- data/boot/README +2 -9
- data/boot/extconf.rb +0 -1
- data/boot/fancy_ext/module.rb +5 -15
- data/boot/fancy_ext/thread.rb +22 -9
- data/boot/rbx-compiler/README +0 -4
- data/boot/rbx-compiler/parser/fancy_parser.bundle +0 -0
- data/boot/rbx-compiler/parser/parser.y +1 -0
- data/doc/api/fancy.css +1 -6
- data/doc/api/fancy.jsonp +1 -1
- data/doc/api/fdoc.js +2 -4
- data/doc/api/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/doc/api/images/ui-bg_flat_0_eeeeee_40x100.png +0 -0
- data/doc/api/images/ui-bg_flat_55_ffffff_40x100.png +0 -0
- data/doc/api/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/doc/api/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/doc/api/images/ui-bg_highlight-soft_100_f6f6f6_1x100.png +0 -0
- data/doc/api/images/ui-bg_highlight-soft_25_0073ea_1x100.png +0 -0
- data/doc/api/images/ui-bg_highlight-soft_50_dddddd_1x100.png +0 -0
- data/doc/api/images/ui-icons_0073ea_256x240.png +0 -0
- data/doc/api/images/ui-icons_454545_256x240.png +0 -0
- data/doc/api/images/ui-icons_666666_256x240.png +0 -0
- data/doc/api/images/ui-icons_ff0084_256x240.png +0 -0
- data/doc/api/images/ui-icons_ffffff_256x240.png +0 -0
- data/doc/api/index.html +5 -4
- data/doc/api/jquery-1.8.2.min.js +2 -0
- data/doc/api/jquery-ui-1.9.0.custom.min.css +5 -0
- data/doc/api/jquery-ui-1.9.0.custom.min.js +6 -0
- data/doc/features.md +8 -3
- data/examples/argv.fy +1 -1
- data/examples/closures.fy +1 -4
- data/examples/echo.fy +2 -2
- data/examples/guess_number.fy +18 -0
- data/examples/nested_classes.fy +3 -15
- data/lib/argv.fy +23 -18
- data/lib/array.fy +18 -37
- data/lib/block.fy +125 -0
- data/lib/boot.fy +1 -0
- data/lib/compiler/ast/block.fy +1 -1
- data/lib/compiler/ast/identifier.fy +1 -1
- data/lib/compiler/ast/message_send.fy +0 -13
- data/lib/compiler/ast/method_def.fy +1 -1
- data/lib/compiler/ast/singleton_method_def.fy +1 -0
- data/lib/compiler/ast/tuple_literal.fy +1 -1
- data/lib/compiler/command.fy +1 -1
- data/lib/compiler/compiler.fy +8 -6
- data/lib/contracts.fy +1 -1
- data/lib/directory.fy +1 -1
- data/lib/dynamic_slot_object.fy +1 -1
- data/lib/enumerable.fy +316 -25
- data/lib/enumerator.fy +11 -8
- data/lib/eval.fy +0 -3
- data/lib/fancy_spec.fy +27 -0
- data/lib/fdoc.fy +8 -8
- data/lib/file.fy +25 -1
- data/lib/hash.fy +91 -0
- data/lib/html.fy +40 -11
- data/lib/integer.fy +4 -0
- data/lib/main.fy +18 -11
- data/lib/object.fy +33 -7
- data/lib/option_parser.fy +20 -1
- data/lib/package/dependency.fy +8 -0
- data/lib/package/dependency_installer.fy +3 -6
- data/lib/package/handler.fy +4 -4
- data/lib/package/installer.fy +2 -5
- data/lib/package/list.fy +3 -4
- data/lib/parser/ext/parser.y +1 -0
- data/lib/proxies.fy +0 -2
- data/lib/queue.fy +7 -0
- data/lib/rbx.fy +1 -0
- data/lib/rbx/actor.fy +3 -1
- data/lib/rbx/alpha.fy +24 -0
- data/lib/rbx/array.fy +3 -1
- data/lib/rbx/class.fy +5 -8
- data/lib/rbx/date_time.fy +14 -0
- data/lib/rbx/file.fy +6 -0
- data/lib/rbx/hash.fy +42 -0
- data/lib/rbx/thread.fy +5 -7
- data/lib/string.fy +56 -4
- data/lib/symbol.fy +29 -1
- data/lib/time.fy +17 -0
- data/lib/vars.fy +4 -3
- data/lib/version.fy +1 -1
- data/ruby_lib/interactive/hilight.rb +125 -0
- data/tests/array.fy +19 -7
- data/tests/block.fy +103 -4
- data/tests/class.fy +31 -26
- data/tests/control_flow.fy +0 -1
- data/tests/dynamic_key_hash.fy +22 -1
- data/tests/enumerable.fy +239 -7
- data/tests/enumerator.fy +7 -0
- data/tests/file.fy +16 -0
- data/tests/future.fy +1 -11
- data/tests/future_proxy.fy +8 -0
- data/tests/hash.fy +132 -9
- data/tests/html.fy +30 -13
- data/tests/integer.fy +3 -0
- data/tests/method.fy +6 -11
- data/tests/object.fy +12 -5
- data/tests/option_parser.fy +12 -3
- data/tests/string.fy +69 -1
- data/tests/symbol.fy +24 -0
- metadata +42 -12
- data/boot/rsexp_pretty_printer.rb +0 -76
- data/doc/api/jquery-ui.min.js +0 -401
- data/doc/api/jquery.tools.min.js +0 -192
- data/doc/api/themeswitchertool.js +0 -250
- data/examples/future_sends.fy +0 -15
data/tests/hash.fy
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
FancySpec describe: Hash with: {
|
|
2
2
|
it: "is empty on initialization" with: 'empty? when: {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
<[]> tap: @{
|
|
4
|
+
size is: 0
|
|
5
|
+
empty? is: true
|
|
6
|
+
}
|
|
6
7
|
}
|
|
7
8
|
|
|
8
9
|
it: "is empty on initialization via Hash#new" with: 'size when: {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
Hash new tap: @{
|
|
11
|
+
size is: 0
|
|
12
|
+
empty? is: true
|
|
13
|
+
}
|
|
12
14
|
}
|
|
13
15
|
|
|
14
16
|
it: "contains one entry" when: {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
17
|
+
<['foo => "bar"]> tap: @{
|
|
18
|
+
size is: 1
|
|
19
|
+
empty? is: false
|
|
20
|
+
}
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
it: "contains 10 square values after 10 insertions" with: 'at: when: {
|
|
@@ -152,6 +155,34 @@ FancySpec describe: Hash with: {
|
|
|
152
155
|
}
|
|
153
156
|
}
|
|
154
157
|
|
|
158
|
+
it: "returns a nested object with slots based on key-value pairs in hashes" with: 'to_object_deep when: {
|
|
159
|
+
hashes = [
|
|
160
|
+
<[]>,
|
|
161
|
+
<['name => "foo", 'age => 42]>
|
|
162
|
+
]
|
|
163
|
+
|
|
164
|
+
hashes each: |h| {
|
|
165
|
+
o = h to_object_deep
|
|
166
|
+
o slots each: |s| {
|
|
167
|
+
o receive_message: s . is: $ h[s]
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
people = [
|
|
173
|
+
<['person => <['name => "foo", 'age => 42, 'city => "London"]>]>,
|
|
174
|
+
<['person => { name: "foo" age: 42 city: "London" }]> # even works with blocks, yay
|
|
175
|
+
]
|
|
176
|
+
|
|
177
|
+
people each: @{
|
|
178
|
+
to_object_deep tap: @{
|
|
179
|
+
person name is: "foo"
|
|
180
|
+
person age is: 42
|
|
181
|
+
person city is: "London"
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
155
186
|
it: "returns a hash with all entries for which a block yields true" with: 'select_keys: when: {
|
|
156
187
|
<[]> select_keys: { true } . is: <[]>
|
|
157
188
|
<[]> select_keys: { false } . is: <[]>
|
|
@@ -231,4 +262,96 @@ FancySpec describe: Hash with: {
|
|
|
231
262
|
]>
|
|
232
263
|
]>
|
|
233
264
|
}
|
|
265
|
+
|
|
266
|
+
it: "updates its values with a block" with: 'update_values: when: {
|
|
267
|
+
<[]> update_values: @{ to_s } . is: <[]>
|
|
268
|
+
h = <['name => "Tom", 'age => 21]>
|
|
269
|
+
h update_values: @{ * 2 }
|
|
270
|
+
h is: <['name => "TomTom", 'age => 42]>
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
it: "updates its keys with a block" with: 'update_keys: when: {
|
|
274
|
+
<[]> update_keys: @{ to_s } . is: <[]>
|
|
275
|
+
h = <['name => "Tom", 'age => 21]>
|
|
276
|
+
h update_keys: @{ to_s * 2 }
|
|
277
|
+
h is: <["namename" => "Tom", "ageage" => 21]>
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
it: "returns a new hash based on self with values updated with a block" with: 'with_updated_values: when: {
|
|
281
|
+
<[]> with_updated_values: @{ * 2 } . is: <[]>
|
|
282
|
+
h1 = <['name => "Tom", 'age => 21]>
|
|
283
|
+
h2 = h1 with_updated_values: @{ * 2 }
|
|
284
|
+
|
|
285
|
+
h1 is: <['name => "Tom", 'age => 21]>
|
|
286
|
+
h2 is: <['name => "TomTom", 'age => 42]>
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
it: "returns a new hash based on self with keys updated with a block" with: 'with_updated_keys: when: {
|
|
290
|
+
<[]> with_updated_keys: @{ * 2 } . is: <[]>
|
|
291
|
+
h1 = <['name => "Tom", 'age => 21]>
|
|
292
|
+
h2 = h1 with_updated_keys: @{ to_s * 2 }
|
|
293
|
+
|
|
294
|
+
h1 is: <['name => "Tom", 'age => 21]>
|
|
295
|
+
h2 is: <["namename" => "Tom", "ageage" => 21]>
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
it: "calls a block with a value for a given key, if available" with: 'with_value_for_key:do:else: when: {
|
|
299
|
+
h = <['hello => "world", 1 => 2, "foo" => "barbaz"]>
|
|
300
|
+
else_ran? = false
|
|
301
|
+
else_block = { else_ran? = true }
|
|
302
|
+
|
|
303
|
+
h with_value_for_key: 'hello do: @{ is: "world" } else: else_block
|
|
304
|
+
h with_value_for_key: 1 do: @{ is: 2 } else: else_block
|
|
305
|
+
h with_value_for_key: "foo" do: @{ "barbaz" } else: else_block
|
|
306
|
+
|
|
307
|
+
else_ran? = false
|
|
308
|
+
|
|
309
|
+
h with_value_for_key: "not in hash" do: {
|
|
310
|
+
"should not call this block!" raise!
|
|
311
|
+
} else: else_block
|
|
312
|
+
|
|
313
|
+
else_ran? is: true
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
it: "sets the default value on creation" when: {
|
|
317
|
+
h = Hash new: "default"
|
|
318
|
+
h['key] is: "default"
|
|
319
|
+
h['key]: "hallo"
|
|
320
|
+
h['key] is: "hallo"
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
it: "sets the default value" with: 'default: when: {
|
|
324
|
+
h = Hash new
|
|
325
|
+
h default is: nil
|
|
326
|
+
h default: "foo"
|
|
327
|
+
h default is: "foo"
|
|
328
|
+
|
|
329
|
+
block = |_ k| { k }
|
|
330
|
+
h default: block
|
|
331
|
+
h default is: block
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
it: "returns the default value" with: 'default when: {
|
|
335
|
+
Hash new default is: nil
|
|
336
|
+
Hash new: "foo" . default is: "foo"
|
|
337
|
+
|
|
338
|
+
block = |h k| { k * 2 }
|
|
339
|
+
Hash new: block . default is: block
|
|
340
|
+
Hash new: block . tap: |h| {
|
|
341
|
+
h[1] is: 2
|
|
342
|
+
h["foo"] is: "foofoo"
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
it: "returns the return value for a given key" with: 'default_for: when: {
|
|
347
|
+
Hash new: 2 . tap: @{
|
|
348
|
+
default_for: "foo" . is: 2
|
|
349
|
+
default_for: "bar" . is: 2
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
Hash new: |_ k| { k * 2 } . tap: @{
|
|
353
|
+
default_for: "foo" . is: "foofoo"
|
|
354
|
+
default_for: 100 . is: 200
|
|
355
|
+
}
|
|
356
|
+
}
|
|
234
357
|
}
|
data/tests/html.fy
CHANGED
|
@@ -16,18 +16,35 @@ FancySpec describe: HTML with: {
|
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
</html>
|
|
19
|
+
html = """
|
|
20
|
+
<html>
|
|
21
|
+
<head>
|
|
22
|
+
<title>
|
|
23
|
+
Hello
|
|
24
|
+
</title>
|
|
25
|
+
</head>
|
|
26
|
+
<body>
|
|
27
|
+
<h1>
|
|
28
|
+
Hello, World!
|
|
29
|
+
</h1>
|
|
30
|
+
</body>
|
|
31
|
+
</html>
|
|
32
|
+
"""
|
|
33
|
+
|
|
34
|
+
h to_s is: $ html skip_leading_indentation
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
it: "indents the generated html by a common offset" when: {
|
|
38
|
+
h = HTML new: @{
|
|
39
|
+
foo: @{ bar: "baz" }
|
|
40
|
+
} indentation: 3
|
|
41
|
+
|
|
42
|
+
h to_s lines is: [
|
|
43
|
+
" <foo>",
|
|
44
|
+
" <bar>",
|
|
45
|
+
" baz",
|
|
46
|
+
" </bar>",
|
|
47
|
+
" </foo>"
|
|
48
|
+
]
|
|
32
49
|
}
|
|
33
50
|
}
|
data/tests/integer.fy
CHANGED
data/tests/method.fy
CHANGED
|
@@ -3,17 +3,6 @@ FancySpec describe: Method with: {
|
|
|
3
3
|
[1,2,3] method: "each:" . class is: Method
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
# it: "returns the (correct) sender object of the MessageSend" when: {
|
|
7
|
-
# class SenderTest {
|
|
8
|
-
# def give_me_the_sender! {
|
|
9
|
-
# __sender__
|
|
10
|
-
# }
|
|
11
|
-
# }
|
|
12
|
-
|
|
13
|
-
# x = SenderTest new
|
|
14
|
-
# x give_me_the_sender! is: self
|
|
15
|
-
# }
|
|
16
|
-
|
|
17
6
|
it: "returns the amount of arguments a Method takes" with: 'arity when: {
|
|
18
7
|
class Foo {
|
|
19
8
|
def no_args
|
|
@@ -140,4 +129,10 @@ FancySpec describe: Method with: {
|
|
|
140
129
|
def fooaa: bar ("fo");
|
|
141
130
|
fooaa: 10
|
|
142
131
|
}
|
|
132
|
+
|
|
133
|
+
it: "can handle a singleton method def with an empty body" when: {
|
|
134
|
+
obj = "foo"
|
|
135
|
+
def obj bar
|
|
136
|
+
def obj bar: @x
|
|
137
|
+
}
|
|
143
138
|
}
|
data/tests/object.fy
CHANGED
|
@@ -25,7 +25,7 @@ FancySpec describe: Object with: {
|
|
|
25
25
|
{ self a_singleton_method } raises: NoMethodError
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
it: "returns its class" when: {
|
|
28
|
+
it: "returns its class" with: 'class when: {
|
|
29
29
|
nil class is: NilClass
|
|
30
30
|
true class is: TrueClass
|
|
31
31
|
"foo" class is: String
|
|
@@ -44,25 +44,32 @@ FancySpec describe: Object with: {
|
|
|
44
44
|
obj this_is_not_defined: "It's true!" . is: "Got: this_is_not_defined: It's true!"
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
it: "returns a correct string representation" when: {
|
|
47
|
+
it: "returns a correct string representation" with: 'to_s when: {
|
|
48
48
|
3 to_s is: "3"
|
|
49
49
|
'foo to_s is: "foo"
|
|
50
50
|
nil to_s is: ""
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
it: "returns a correct array representation" when: {
|
|
53
|
+
it: "returns a correct array representation" with: 'to_a when: {
|
|
54
54
|
nil to_a is: []
|
|
55
55
|
'foo to_a is: ['foo]
|
|
56
56
|
<['foo => "bar", 'bar => "baz"]> to_a is =? [['bar, "baz"], ['foo, "bar"]]
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
it: "returns a
|
|
59
|
+
it: "returns a hash based on own slot values" with: 'to_hash when: {
|
|
60
|
+
nil to_hash is: <[]>
|
|
61
|
+
false to_hash is: <[]>
|
|
62
|
+
true to_hash is: <[]>
|
|
63
|
+
(0..10) each: @{ to_hash is: <[]> }
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
it: "returns a correct fixnum representation" with: 'to_i when: {
|
|
60
67
|
nil to_i is: 0
|
|
61
68
|
3 to_i is: 3
|
|
62
69
|
3.28437 to_i is: 3
|
|
63
70
|
}
|
|
64
71
|
|
|
65
|
-
it: "is an Object of the correct Class (or Superclass)" when: {
|
|
72
|
+
it: "is an Object of the correct Class (or Superclass)" with: 'is_a?: when: {
|
|
66
73
|
Object new is_a?: Object . is: true
|
|
67
74
|
"foo" is_a?: String . is: true
|
|
68
75
|
"foo" is_a?: Object . is: true
|
data/tests/option_parser.fy
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require: "lib/option_parser"
|
|
2
2
|
|
|
3
3
|
FancySpec describe: OptionParser with: {
|
|
4
|
-
it: "parses an option with no argument" when: {
|
|
4
|
+
it: "parses an option with no argument" with: 'parse: when: {
|
|
5
5
|
parsed_option? = false
|
|
6
6
|
|
|
7
7
|
o = OptionParser new: @{
|
|
@@ -15,7 +15,7 @@ FancySpec describe: OptionParser with: {
|
|
|
15
15
|
parsed_option? is: true
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
it: "parses no option if none are passed" when: {
|
|
18
|
+
it: "parses no option if none are passed" with: 'parse: when: {
|
|
19
19
|
parsed_option? = false
|
|
20
20
|
o = OptionParser new: @{
|
|
21
21
|
with: "--foo [arg]" doc: "bla" do: |arg| {
|
|
@@ -31,7 +31,7 @@ FancySpec describe: OptionParser with: {
|
|
|
31
31
|
parsed_option? is: false
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
it: "parses an option with an argument" when: {
|
|
34
|
+
it: "parses an option with an argument" with: 'parse: when: {
|
|
35
35
|
parsed_option? = false
|
|
36
36
|
passed_args = []
|
|
37
37
|
|
|
@@ -77,4 +77,13 @@ FancySpec describe: OptionParser with: {
|
|
|
77
77
|
o parse: args
|
|
78
78
|
args is: [1, 2]
|
|
79
79
|
}
|
|
80
|
+
|
|
81
|
+
it: "parses options as a hash" with: 'parse_hash: when: {
|
|
82
|
+
o = OptionParser new: @{
|
|
83
|
+
with: "--some-option [some-value]" doc: "foo"
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
hash = o parse_hash: ["foo", "bar", "--some-option", "hello world!", "baz"]
|
|
87
|
+
hash is: <["--some-option" => "hello world!"]>
|
|
88
|
+
}
|
|
80
89
|
}
|
data/tests/string.fy
CHANGED
|
@@ -55,6 +55,25 @@ FancySpec describe: String with: {
|
|
|
55
55
|
"hello world" drop_while: |c| { c != " " } . join: "" . is: " world"
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
it: "drops the last element" with: 'drop_last: when: {
|
|
59
|
+
[] drop_last is: []
|
|
60
|
+
[1] drop_last is: []
|
|
61
|
+
"foo" drop_last is: ["f", "o"]
|
|
62
|
+
(1,2,3) drop_last is: [1,2]
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
it: "rops the last n elements" with: 'drop_last: when: {
|
|
66
|
+
[] drop_last: 1 . is: []
|
|
67
|
+
[] drop_last: 2 . is: []
|
|
68
|
+
[] drop_last: 0 . is: []
|
|
69
|
+
[1] drop_last: 0 . is: [1]
|
|
70
|
+
[1] drop_last: 1 . is: []
|
|
71
|
+
[1] drop_last: 2 . is: []
|
|
72
|
+
[1,2,3] drop_last: 1 . is: [1, 2]
|
|
73
|
+
[1,2,3] drop_last: 2 . is: [1]
|
|
74
|
+
[1,2,3] drop_last: 3 . is: []
|
|
75
|
+
}
|
|
76
|
+
|
|
58
77
|
it: "is empty" with: 'empty? when: {
|
|
59
78
|
"" empty? is: true
|
|
60
79
|
" " empty? is: false
|
|
@@ -70,7 +89,7 @@ FancySpec describe: String with: {
|
|
|
70
89
|
"hello world" at: 5 . blank? is: true
|
|
71
90
|
}
|
|
72
91
|
|
|
73
|
-
it: "is evaluated as fancy code and returns the correct value" when: {
|
|
92
|
+
it: "is evaluated as fancy code and returns the correct value" with: 'eval when: {
|
|
74
93
|
x = "'foo" eval
|
|
75
94
|
x is: 'foo
|
|
76
95
|
"3 + 4" eval is: 7
|
|
@@ -78,6 +97,14 @@ FancySpec describe: String with: {
|
|
|
78
97
|
"33.33" eval is: 33.33
|
|
79
98
|
}
|
|
80
99
|
|
|
100
|
+
it: "parses empty code with newlines correctly" with: 'eval when: {
|
|
101
|
+
"" eval is: nil
|
|
102
|
+
"\n" eval is: nil
|
|
103
|
+
"\n\n" eval is: nil
|
|
104
|
+
"\n \n \n" eval is: nil
|
|
105
|
+
" \n " eval is: nil
|
|
106
|
+
}
|
|
107
|
+
|
|
81
108
|
it: "returns itself times n" with: '* when: {
|
|
82
109
|
"foo" * 2 is: "foofoo"
|
|
83
110
|
"f" ++ ("o" * 2) ++ "bar" is: "foobar"
|
|
@@ -206,4 +233,45 @@ FancySpec describe: String with: {
|
|
|
206
233
|
|
|
207
234
|
""" multiline? is: true
|
|
208
235
|
}
|
|
236
|
+
|
|
237
|
+
it: "returns a snake cased version of itself" with: 'snake_cased when: {
|
|
238
|
+
"" snake_cased is: ""
|
|
239
|
+
"Foo" snake_cased is: "foo"
|
|
240
|
+
"FooB" snake_cased is: "foo_b"
|
|
241
|
+
"FooBarBaz" snake_cased is: "foo_bar_baz"
|
|
242
|
+
"Foo Bar Baz" snake_cased is: "foo bar baz"
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
it: "returns a camel cased version of itself" with: 'camel_cased when: {
|
|
246
|
+
"" camel_cased is: ""
|
|
247
|
+
"foo" camel_cased is: "Foo"
|
|
248
|
+
"foo_" camel_cased is: "Foo"
|
|
249
|
+
"foo_bar_baz" camel_cased is: "FooBarBaz"
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
it: "returns true if its uppercase" with: 'uppercase? when: {
|
|
253
|
+
"" uppercase? is: false
|
|
254
|
+
"foo" uppercase? is: false
|
|
255
|
+
"F" uppercase? is: true
|
|
256
|
+
"Foo" uppercase? is: false
|
|
257
|
+
"ABC" uppercase? is: true
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
it: "returns true if its lowercase" with: 'lowercase? when: {
|
|
261
|
+
"" lowercase? is: false
|
|
262
|
+
"foo" lowercase? is: true
|
|
263
|
+
"foA" lowercase? is: false
|
|
264
|
+
"A" lowercase? is: false
|
|
265
|
+
"abc" lowercase? is: true
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
it: "returns true if its begins with another string" with: 'starts_with?: when: {
|
|
269
|
+
"" starts_with?: "" . is: true
|
|
270
|
+
"foo" starts_with?: "f" . is: true
|
|
271
|
+
"foo" starts_with?: "fo" . is: true
|
|
272
|
+
"foo" starts_with?: "foo" . is: true
|
|
273
|
+
"foo" starts_with?: "fooo" . is: false
|
|
274
|
+
"foo" starts_with?: "oo" . is: false
|
|
275
|
+
"foo" starts_with?: "" . is: false
|
|
276
|
+
}
|
|
209
277
|
}
|
data/tests/symbol.fy
CHANGED
|
@@ -28,8 +28,32 @@ FancySpec describe: Symbol with: {
|
|
|
28
28
|
if: x then: 'foo else: 'bar . is: "foo"
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
it: "returns its arity correctly (when interpreted as a method name)" with: 'arity when: {
|
|
32
|
+
'foo arity is: 1
|
|
33
|
+
'foo_bar_baz arity is: 1
|
|
34
|
+
('+, '-, '*, '/) each: @{ arity is: 2 }
|
|
35
|
+
'foo: arity is: 2
|
|
36
|
+
'foo:bar: arity is: 3
|
|
37
|
+
'foo:bar:baz: arity is: 4
|
|
38
|
+
}
|
|
39
|
+
|
|
31
40
|
it: "returns self" with: 'to_sym when: {
|
|
32
41
|
'foo to_sym is: 'foo
|
|
33
42
|
'bar to_sym is: 'bar
|
|
34
43
|
}
|
|
44
|
+
|
|
45
|
+
it: "returns itself as a Block" with: 'to_block when: {
|
|
46
|
+
b = 'inspect to_block
|
|
47
|
+
b call: [2] . is: "2"
|
|
48
|
+
b call: ["foo"] . is: "\"foo\""
|
|
49
|
+
|
|
50
|
+
str = "hello, world yo!\"foo\""
|
|
51
|
+
b call: [str] . is: $ @{ inspect } call: [str]
|
|
52
|
+
|
|
53
|
+
add = '+ to_block
|
|
54
|
+
{ add call: [2] } raises: ArgumentError
|
|
55
|
+
add call: [0,1] . is: 1
|
|
56
|
+
add call: [2,3] . is: 5
|
|
57
|
+
{ add call: [2,3,4] } raises: ArgumentError
|
|
58
|
+
}
|
|
35
59
|
}
|