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,101 +1,118 @@
1
1
  FancySpec describe: Hash with: {
2
- it: "should be empty on initialization" for: 'empty? when: {
2
+ it: "is empty on initialization" with: 'empty? when: {
3
3
  hash = <[]>
4
- hash size should == 0
5
- hash empty? should == true
4
+ hash size is: 0
5
+ hash empty? is: true
6
6
  }
7
7
 
8
- it: "should be empty on initialization via Hash#new" for: 'size when: {
8
+ it: "is empty on initialization via Hash#new" with: 'size when: {
9
9
  hash = Hash new
10
- hash size should == 0
11
- hash empty? should == true
10
+ hash size is: 0
11
+ hash empty? is: true
12
12
  }
13
13
 
14
- it: "should contain one entry" when: {
14
+ it: "contains one entry" when: {
15
15
  hash = <['foo => "bar"]>
16
- hash size should == 1
17
- hash empty? should == false
16
+ hash size is: 1
17
+ hash empty? is: false
18
18
  }
19
19
 
20
- it: "should contain 10 square values after 10 insertions" for: 'at: when: {
20
+ it: "contains 10 square values after 10 insertions" with: 'at: when: {
21
21
  hash = Hash new
22
22
  10 times: |i| {
23
23
  hash at: i put: (i * i)
24
24
  }
25
25
 
26
26
  10 times: |i| {
27
- hash at: i . should == (i * i)
27
+ hash at: i . is: (i * i)
28
28
  }
29
29
  }
30
30
 
31
- it: "should override the value for a given key" for: 'at: when: {
31
+ it: "overrides the value for a given key" with: 'at: when: {
32
32
  hash = <['foo => "bar"]>
33
- hash at: 'foo . should == "bar"
33
+ hash at: 'foo . is: "bar"
34
34
  hash at: 'foo put: 'foobarbaz
35
- hash at: 'foo . should == 'foobarbaz
35
+ hash at: 'foo . is: 'foobarbaz
36
36
  }
37
37
 
38
- it: "should return all keys" for: 'keys when: {
38
+ it: "returns all keys" with: 'keys when: {
39
39
  hash = <['foo => "bar", 'bar => "baz", 'foobar => 112.21]>
40
- hash keys should =? ['foo, 'bar, 'foobar]
40
+ hash keys is =? ['foo, 'bar, 'foobar]
41
41
  }
42
42
 
43
- it: "should return all values" for: 'values when: {
43
+ it: "returns all values" with: 'values when: {
44
44
  hash = <['foo => "bar", 'bar => "baz", 'foobar => 112.21]>
45
- hash values should =? ["bar", "baz", 112.21]
45
+ hash values is =? ["bar", "baz", 112.21]
46
46
  }
47
47
 
48
- it: "should return value by the []-operator" for: "[]" when: {
48
+ it: "returns value by the []-operator" with: '[] when: {
49
49
  hash = <['foo => "bar", 'bar => "baz", 'foobar => 112.21]>
50
- hash['foo] should == "bar"
51
- hash['bar] should == "baz"
52
- hash['foobar] should == 112.21
50
+ hash['foo] is: "bar"
51
+ hash['bar] is: "baz"
52
+ hash['foobar] is: 112.21
53
53
  }
54
54
 
55
- it: "should return nil if the key isn't defined" for: '[] when: {
56
- <['foo => "bar"]> ['bar] . should == nil
57
- <[]> ['foobar] . should == nil
58
- <['foo => "bar"]> [nil] . should == nil
55
+ it: "returns nil if the key isn't defined" with: '[] when: {
56
+ <['foo => "bar"]> ['bar] . is: nil
57
+ <[]> ['foobar] . is: nil
58
+ <['foo => "bar"]> [nil] . is: nil
59
59
  }
60
60
 
61
- it: "should call the Block for each key and value" for: 'each: when: {
61
+ it: "calls the Block for each key and value" with: 'each: when: {
62
62
  hash = <['foo => "bar", 'bar => "baz", 'foobar => 112.21]>
63
63
  hash each: |key val| {
64
- val should == (hash[key])
64
+ val is: (hash[key])
65
65
  }
66
66
  }
67
67
 
68
- it: "should call the Block with each key" for: 'each_key: when: {
68
+ it: "calls the Block with each key" with: 'each_key: when: {
69
69
  hash = <['foo => "bar", 'bar => "baz", 'foobar => 112.21]>
70
70
  count = 0
71
71
  hash each_key: |key| {
72
- key should == (hash keys[count])
72
+ key is: (hash keys[count])
73
73
  count = count + 1
74
74
  }
75
75
  }
76
76
 
77
- it: "should call the Block with each value" for: 'each_value: when: {
77
+ it: "calls the Block with each value" with: 'each_value: when: {
78
78
  hash = <['foo => "bar", 'bar => "baz", 'foobar => 112.21]>
79
79
  count = 0
80
80
  hash each_value: |val| {
81
- val should == (hash values[count])
81
+ val is: (hash values[count])
82
82
  count = count + 1
83
83
  }
84
84
  }
85
85
 
86
- it: "should call most Enumerable methods with each pair" when: {
86
+ it: "calls Enumerable methods with each pair" when: {
87
87
  hash = <['hello => "world", 'fancy => "is cool"]>
88
88
 
89
- hash map: |pair| { pair[0] } . should =? ['hello, 'fancy] # order does not matter
89
+ hash map: |pair| { pair[0] } . is =? ['hello, 'fancy] # order does not matter
90
90
 
91
91
  hash select: |pair| { pair[1] to_s includes?: "c" } .
92
- should == [['fancy, "is cool"]]
92
+ is: [['fancy, "is cool"]]
93
93
 
94
94
  hash reject: |pair| { pair[0] to_s includes?: "l" } .
95
- map: 'second . should == ["is cool"]
95
+ map: 'second . is: ["is cool"]
96
96
  }
97
97
 
98
- it: "should return an Array of the key-value pairs" for: 'to_a when: {
99
- <['foo => "bar", 'bar => "baz"]> to_a should =? [['foo, "bar"], ['bar, "baz"]]
98
+ it: "returns an Array of the key-value pairs" with: 'to_a when: {
99
+ <['foo => "bar", 'bar => "baz"]> to_a is =? [['foo, "bar"], ['bar, "baz"]]
100
+ }
101
+
102
+ it: "returns multiple values if given an array of keys" with: '[] when: {
103
+ hash = <['foo => 1, 'bar => "foobar", 'baz => 42, "hello world" => "hello!"]>
104
+ a, b, c = hash values_at: ('foo, 'bar, "hello world")
105
+ a is: 1
106
+ b is: "foobar"
107
+ c is: "hello!"
108
+ }
109
+
110
+ it: "includes a key" with: 'includes?: when: {
111
+ h = <['foo => "bar", 'bar => "baz"]>
112
+ h includes?: 'foo . is: true
113
+ h includes?: 'bar . is: true
114
+ h includes?: "foo" . is: false
115
+ h includes?: "bar" . is: false
116
+ h includes?: nil . is: false
100
117
  }
101
118
  }
@@ -1,9 +1,9 @@
1
1
  FancySpec describe: Method with: {
2
- it: "should return a Method object" when: {
3
- [1,2,3] method: "each:" . class should == Method
2
+ it: "returns a Method object" when: {
3
+ [1,2,3] method: "each:" . class is: Method
4
4
  }
5
5
 
6
- # it: "should return the (correct) sender object of the MessageSend" when: {
6
+ # it: "returns the (correct) sender object of the MessageSend" when: {
7
7
  # class SenderTest {
8
8
  # def give_me_the_sender! {
9
9
  # __sender__
@@ -11,10 +11,10 @@ FancySpec describe: Method with: {
11
11
  # }
12
12
 
13
13
  # x = SenderTest new
14
- # x give_me_the_sender! should == self
14
+ # x give_me_the_sender! is: self
15
15
  # }
16
16
 
17
- it: "should return the amount of arguments a Method takes" for: 'argcount when: {
17
+ it: "returns the amount of arguments a Method takes" with: 'arity when: {
18
18
  class Foo {
19
19
  def no_args {
20
20
  }
@@ -26,19 +26,19 @@ FancySpec describe: Method with: {
26
26
  }
27
27
  }
28
28
 
29
- Foo instance_method: 'no_args . arity should == 0
30
- Foo instance_method: "one_arg:" . arity should == 1
31
- Foo instance_method: "two:args:" . arity should == 2
32
- Foo instance_method: "three:args:ok:" . arity should == 3
29
+ Foo instance_method: 'no_args . arity is: 0
30
+ Foo instance_method: "one_arg:" . arity is: 1
31
+ Foo instance_method: "two:args:" . arity is: 2
32
+ Foo instance_method: "three:args:ok:" . arity is: 3
33
33
  }
34
34
 
35
- it: "should return the return value" when: {
35
+ it: "returns the return value" when: {
36
36
  def foo: bar {
37
37
  return "returning!"
38
38
  bar # will never get executed
39
39
  }
40
40
 
41
- foo: "yay" . should == "returning!"
41
+ foo: "yay" . is: "returning!"
42
42
 
43
43
  # another example
44
44
 
@@ -49,8 +49,8 @@ FancySpec describe: Method with: {
49
49
  0
50
50
  }
51
51
 
52
- f: 10 . should == 0
53
- f: 9 . should == 100
52
+ f: 10 . is: 0
53
+ f: 9 . is: 100
54
54
 
55
55
  # and another one
56
56
 
@@ -63,10 +63,10 @@ FancySpec describe: Method with: {
63
63
  return 0
64
64
  }
65
65
 
66
- foo should == 8
66
+ foo is: 8
67
67
  }
68
68
 
69
- it: "should return only from block-scope not from method-scope" when: {
69
+ it: "returns only from block-scope not from method-scope" when: {
70
70
  def self foo {
71
71
  10 times: |i| {
72
72
  i == 8 if_true: {
@@ -75,68 +75,75 @@ FancySpec describe: Method with: {
75
75
  }
76
76
  0
77
77
  }
78
- foo should == 8
78
+ foo is: 8
79
79
  }
80
80
 
81
- it: "should return locally (from block-scope not from method-scope" when: {
81
+ it: "returns locally (from block-scope not from method-scope" when: {
82
82
  def self foo {
83
83
  [1,2,3] select: |x| { return_local x != 3 }
84
84
  }
85
- foo should == [1,2]
85
+ foo is: [1,2]
86
86
  }
87
87
 
88
88
  class Foo {
89
89
  def bar {
90
90
  }
91
- def private private_bar {
91
+ def private_bar {
92
92
  }
93
- def protected protected_bar {
93
+ private: 'private_bar
94
+ def protected_bar {
94
95
  }
96
+ protected: 'protected_bar
95
97
  }
96
98
 
97
- it: "should be public" for: 'public? when: {
98
- Foo instance_method: 'bar . public? should == true
99
- Foo instance_method: 'private_bar . public? should == false
100
- Foo instance_method: 'protected_bar . public? should == false
99
+ it: "is public" with: 'public? when: {
100
+ Foo instance_method: 'bar . public? is: true
101
+ Foo instance_method: 'private_bar . public? is: false
102
+ Foo instance_method: 'protected_bar . public? is: false
101
103
  }
102
104
 
103
- it: "should be private" for: 'private? when: {
104
- Foo instance_method: 'bar . private? should == false
105
- Foo instance_method: 'private_bar . private? should == true
106
- Foo instance_method: 'protected_bar . private? should == false
105
+ it: "is private" with: 'private? when: {
106
+ Foo instance_method: 'bar . private? is: false
107
+ Foo instance_method: 'private_bar . private? is: true
108
+ Foo instance_method: 'protected_bar . private? is: false
107
109
  }
108
110
 
109
- it: "should be protected" for: 'protected? when: {
110
- Foo instance_method: 'bar . protected? should == false
111
- Foo instance_method: 'private_bar . protected? should == false
112
- Foo instance_method: 'protected_bar . protected? should == true
111
+ it: "is protected" with: 'protected? when: {
112
+ Foo instance_method: 'bar . protected? is: false
113
+ Foo instance_method: 'private_bar . protected? is: false
114
+ Foo instance_method: 'protected_bar . protected? is: true
113
115
  }
114
116
 
115
- it: "should set the default values for optional argument, when not passed in" when: {
117
+ it: "sets the default values for optional argument, when not passed in" when: {
116
118
  def foo: arg1 bar: arg2 ("foo") baz: arg3 (nil) {
117
119
  arg1 ++ arg2 ++ arg3
118
120
  }
119
121
 
120
- foo: "hello" bar: "world" baz: "!" . should == "helloworld!"
121
- foo: "hello" bar: "world" . should == "helloworld"
122
- foo: "hello" . should == "hellofoo"
122
+ foo: "hello" bar: "world" baz: "!" . is: "helloworld!"
123
+ foo: "hello" bar: "world" . is: "helloworld"
124
+ foo: "hello" . is: "hellofoo"
123
125
  }
124
126
 
125
- it: "should have default values for all arguments, if none given" when: {
127
+ it: "has default values for all arguments, if none given" when: {
126
128
  def a: arg1 ("foo") b: arg2 ("bar") c: arg3 ("baz") {
127
129
  [arg1, arg2, arg3]
128
130
  }
129
131
 
130
- a: "hello" b: "world" c: "!" . should == ["hello", "world", "!"]
131
- a: "hello" b: "world" . should == ["hello", "world", "baz"]
132
- a: "hello" . should == ["hello", "bar", "baz"]
133
- a should == ["foo", "bar", "baz"]
132
+ a: "hello" b: "world" c: "!" . is: ["hello", "world", "!"]
133
+ a: "hello" b: "world" . is: ["hello", "world", "baz"]
134
+ a: "hello" . is: ["hello", "bar", "baz"]
135
+ a is: ["foo", "bar", "baz"]
134
136
  }
135
137
 
136
- it: "should return multiple values (as a Tuple)" when: {
138
+ it: "returns multiple values (as a Tuple)" when: {
137
139
  def multiple_return_values: x {
138
140
  (x, x + x, x + x + x)
139
141
  }
140
- val = multiple_return_values: 3 . should == (3, 6, 9)
142
+ val = multiple_return_values: 3 . is: (3, 6, 9)
143
+ }
144
+
145
+ it: "parses methods without a body and default args correctly" when: {
146
+ def fooaa: bar ("fo");
147
+ fooaa: 10
141
148
  }
142
149
  }
@@ -1,62 +1,62 @@
1
1
  FancySpec describe: NilClass with: {
2
- it: "should be false for calling and: with any value" for: 'and: when: {
3
- nil and: true . should == nil
4
- nil and: 'foo . should == nil
5
- nil and: nil . should == nil
6
- false and: true . should == false
7
- false and: 'foo . should == false
8
- false and: nil . should == false
2
+ it: "is false for calling and: with any value" with: 'and: when: {
3
+ nil and: true . is: nil
4
+ nil and: 'foo . is: nil
5
+ nil and: nil . is: nil
6
+ false and: true . is: false
7
+ false and: 'foo . is: false
8
+ false and: nil . is: false
9
9
  }
10
10
 
11
- it: "should be nil/false for calling && with any value" for: '&& when: {
12
- (nil && true) should == nil
13
- (nil && 'foo) should == nil
14
- (nil && nil) should == nil
15
- (false && true) should == false
16
- (false && 'foo) should == false
17
- (false && nil) should == false
11
+ it: "is nil/false for calling && with any value" with: '&& when: {
12
+ (nil && true) is: nil
13
+ (nil && 'foo) is: nil
14
+ (nil && nil) is: nil
15
+ (false && true) is: false
16
+ (false && 'foo) is: false
17
+ (false && nil) is: false
18
18
  }
19
19
 
20
- it: "should be true for calling or: with any non-nil value" for: 'or: when: {
21
- nil or: true . should == true
22
- nil or: 'foo . should == 'foo
20
+ it: "is true for calling or: with any non-nil value" with: 'or: when: {
21
+ nil or: true . is: true
22
+ nil or: 'foo . is: 'foo
23
23
  }
24
24
 
25
- it: "should be nil/false for calling or: with a nil/false value" for: 'or: when: {
26
- nil or: nil . should == nil
27
- nil or: false . should == false
25
+ it: "is nil/false for calling or: with a nil/false value" with: 'or: when: {
26
+ nil or: nil . is: nil
27
+ nil or: false . is: false
28
28
  }
29
29
 
30
- it: "should be true for calling || with any non-nil value" for: '|| when: {
31
- (nil || true) should == true
32
- (nil || 'foo) should == 'foo
30
+ it: "is true for calling || with any non-nil value" with: '|| when: {
31
+ (nil || true) is: true
32
+ (nil || 'foo) is: 'foo
33
33
  }
34
34
 
35
- it: "should be nil for calling || with a nil value" for: '|| when: {
36
- (nil || nil) should == nil
35
+ it: "is nil for calling || with a nil value" with: '|| when: {
36
+ (nil || nil) is: nil
37
37
  }
38
38
 
39
- it: "should NOT call the block" for: 'if_true: when: {
40
- nil if_true: { 'then } . should == nil
39
+ it: "does not call the block" with: 'if_true: when: {
40
+ nil if_true: { 'then } . is: nil
41
41
  }
42
42
 
43
- it: "should not call the block" for: 'if_false: when: {
44
- nil if_false: { 'false } . should == nil
43
+ it: "does not call the block" with: 'if_false: when: {
44
+ nil if_false: { 'false } . is: nil
45
45
  }
46
46
 
47
- it: "should be nil" for: 'nil? when: {
48
- nil nil? should == true
47
+ it: "is nil" with: 'nil? when: {
48
+ nil nil? is: true
49
49
  }
50
50
 
51
- it: "should be false" for: 'false? when: {
52
- nil false? should == false
51
+ it: "is false" with: 'false? when: {
52
+ nil false? is: false
53
53
  }
54
54
 
55
- it: "should NOT be true" for: 'true? when: {
56
- nil true? should == false
55
+ it: "is not true" with: 'true? when: {
56
+ nil true? is: false
57
57
  }
58
58
 
59
- it: "should call the block if nil" for: 'if_nil: when: {
60
- nil if_nil: { 'is_nil } . should == 'is_nil
59
+ it: "calls the block if nil" with: 'if_nil: when: {
60
+ nil if_nil: { 'is_nil } . is: 'is_nil
61
61
  }
62
62
  }
@@ -1,39 +1,39 @@
1
1
  FancySpec describe: Object with: {
2
- it: "should dynamically evaluate a message-send with no arguments" when: {
2
+ it: "dynamically evaluates a message-send with no arguments" when: {
3
3
  obj = 42
4
- obj send_message: 'to_s . should == "42"
4
+ obj receive_message: 'to_s . is: "42"
5
5
  }
6
6
 
7
- it: "should dynamically evaluate a message-send with a list of arguments" when: {
7
+ it: "dynamically evaluates a message-send with a list of arguments" when: {
8
8
  obj = "hello, world"
9
- obj send_message: 'from:to: with_params: [0,4] . should == "hello"
9
+ obj receive_message: 'from:to: with_params: [0,4] . is: "hello"
10
10
  }
11
11
 
12
- it: "should dynamically define slotvalues" when: {
12
+ it: "dynamically defines slotvalues" when: {
13
13
  obj = Object new
14
- obj get_slot: 'foo . should == nil
14
+ obj get_slot: 'foo . is: nil
15
15
  obj set_slot: 'foo value: "hello, world"
16
- obj get_slot: 'foo . should == "hello, world"
16
+ obj get_slot: 'foo . is: "hello, world"
17
17
  }
18
18
 
19
- it: "should undefine a singleton method" when: {
19
+ it: "undefines a singleton method" when: {
20
20
  def self a_singleton_method {
21
21
  "a singleton method!"
22
22
  }
23
- self a_singleton_method should == "a singleton method!"
23
+ self a_singleton_method is: "a singleton method!"
24
24
  self undefine_singleton_method: 'a_singleton_method
25
- { self a_singleton_method } should raise: NoMethodError
25
+ { self a_singleton_method } raises: NoMethodError
26
26
  }
27
27
 
28
- it: "should return its class" when: {
29
- nil class should == NilClass
30
- true class should == TrueClass
31
- "foo" class should == String
32
- 'bar class should == Symbol
33
- { 'a_block } class should == Block
28
+ it: "returns its class" when: {
29
+ nil class is: NilClass
30
+ true class is: TrueClass
31
+ "foo" class is: String
32
+ 'bar class is: Symbol
33
+ { 'a_block } class is: Block
34
34
  }
35
35
 
36
- it: "should call unkown_message:with_params: when calling an undefined method" when: {
36
+ it: "calls unkown_message:with_params: when calling an undefined method" when: {
37
37
  class UnknownMessage {
38
38
  def unknown_message: message with_params: params {
39
39
  "Got: " ++ message ++ " " ++ params
@@ -41,93 +41,102 @@ FancySpec describe: Object with: {
41
41
  }
42
42
 
43
43
  obj = UnknownMessage new
44
- obj this_is_not_defined: "It's true!" . should == "Got: this_is_not_defined: It's true!"
44
+ obj this_is_not_defined: "It's true!" . is: "Got: this_is_not_defined: It's true!"
45
45
  }
46
46
 
47
- it: "should return a correct string representation" when: {
48
- 3 to_s should == "3"
49
- 'foo to_s should == "foo"
50
- nil to_s should == ""
47
+ it: "returns a correct string representation" when: {
48
+ 3 to_s is: "3"
49
+ 'foo to_s is: "foo"
50
+ nil to_s is: ""
51
51
  }
52
52
 
53
- it: "should return a correct array representation" when: {
54
- nil to_a should == []
55
- 'foo to_a should == ['foo]
56
- <['foo => "bar", 'bar => "baz"]> to_a should =? [['bar, "baz"], ['foo, "bar"]]
53
+ it: "returns a correct array representation" when: {
54
+ nil to_a is: []
55
+ 'foo to_a is: ['foo]
56
+ <['foo => "bar", 'bar => "baz"]> to_a is =? [['bar, "baz"], ['foo, "bar"]]
57
57
  }
58
58
 
59
- it: "should return a correct fixnum representation" when: {
60
- nil to_i should == 0
61
- 3 to_i should == 3
62
- 3.28437 to_i should == 3
59
+ it: "returns a correct fixnum representation" when: {
60
+ nil to_i is: 0
61
+ 3 to_i is: 3
62
+ 3.28437 to_i is: 3
63
63
  }
64
64
 
65
- it: "should be an Object of the correct Class (or Superclass)" when: {
66
- Object new is_a?: Object . should == true
67
- "foo" is_a?: String . should == true
68
- "foo" is_a?: Object . should == true
69
- 1123 is_a?: Fixnum . should == true
70
- 1123 is_a?: Object . should == true
71
- 132.123 is_a?: Float . should == true
72
- 132.123 is_a?: Object . should == true
65
+ it: "is an Object of the correct Class (or Superclass)" when: {
66
+ Object new is_a?: Object . is: true
67
+ "foo" is_a?: String . is: true
68
+ "foo" is_a?: Object . is: true
69
+ 1123 is_a?: Fixnum . is: true
70
+ 1123 is_a?: Object . is: true
71
+ 132.123 is_a?: Float . is: true
72
+ 132.123 is_a?: Object . is: true
73
73
  }
74
74
 
75
75
  # boolean messages
76
76
 
77
- it: "should be true for calling and: with non-nil values" for: 'and: when: {
78
- 'foo and: 'bar . should == 'bar
77
+ it: "is true for calling and: with non-nil values" with: 'and: when: {
78
+ 'foo and: 'bar . is: 'bar
79
79
  }
80
80
 
81
- it: "should be false for calling and: with a nil value" for: 'and: when: {
82
- 'foo and: nil . should == nil
81
+ it: "is false for calling and: with a nil value" with: 'and: when: {
82
+ 'foo and: nil . is: nil
83
83
  }
84
84
 
85
- it: "should be true for calling && with non-nil values" for: '&& when: {
86
- ('foo && 'bar) should == 'bar
85
+ it: "is true for calling && with non-nil values" with: '&& when: {
86
+ ('foo && 'bar) is: 'bar
87
87
  }
88
88
 
89
- it: "should be false for calling && with a nil value" for: '&& when: {
90
- ('foo && nil) should == nil
89
+ it: "is false for calling && with a nil value" with: '&& when: {
90
+ ('foo && nil) is: nil
91
91
  }
92
92
 
93
93
 
94
- it: "should be true for calling or: with any value" for: 'or: when: {
95
- 'foo or: 'bar . should == 'foo
96
- 'foo or: nil . should == 'foo
94
+ it: "is true for calling or: with any value" with: 'or: when: {
95
+ 'foo or: 'bar . is: 'foo
96
+ 'foo or: nil . is: 'foo
97
97
  }
98
98
 
99
- it: "should be true for calling || with any value" for: '|| when: {
100
- ('foo || 'bar) should == 'foo
101
- ('foo || nil) should == 'foo
99
+ it: "is true for calling || with any value" with: '|| when: {
100
+ ('foo || 'bar) is: 'foo
101
+ ('foo || nil) is: 'foo
102
+ }
103
+
104
+ it: "is true if only one of them is not true" with: 'xor: when: {
105
+ true xor: false . is: true
106
+ false xor: false . is: false
107
+ nil xor: nil . is: false
108
+ false xor: false . is: false
109
+ false xor: nil . is: false
110
+ 1 xor: nil . is: true
102
111
  }
103
112
 
104
113
  # end boolean messages
105
114
 
106
- it: "should NOT be nil for non-nil values" for: 'nil? when: {
107
- 'foo nil? should == false
108
- 1 nil? should == false
109
- "hello" nil? should == false
115
+ it: "is not nil for non-nil values" with: 'nil? when: {
116
+ 'foo nil? is: false
117
+ 1 nil? is: false
118
+ "hello" nil? is: false
110
119
  }
111
120
 
112
- it: "should NOT be false for non-nil values" for: 'false? when: {
113
- 'foo false? should == false
114
- "hello, world" false? should == false
121
+ it: "is not false for non-nil values" with: 'false? when: {
122
+ 'foo false? is: false
123
+ "hello, world" false? is: false
115
124
  }
116
125
 
117
- it: "should not be true" for: 'true? when: {
118
- 'foo true? should == false
119
- "hello, world" true? should == false
126
+ it: "is not true" with: 'true? when: {
127
+ 'foo true? is: false
128
+ "hello, world" true? is: false
120
129
  }
121
130
 
122
- it: "should return the correct value" for: 'returning:do: when: {
131
+ it: "returns the correct value" with: 'returning:do: when: {
123
132
  returning: [] do: |arr| {
124
133
  arr << 1
125
134
  arr << 2
126
135
  arr << 3
127
- } . should == [1,2,3]
136
+ } . is: [1,2,3]
128
137
  }
129
138
 
130
- it: "should only call a method if the receiver responds to it using a RespondsToProxy" for: 'if_responds? when: {
139
+ it: "only calls a method if the receiver responds to it using a RespondsToProxy" with: 'if_responds? when: {
131
140
  class SomeClass {
132
141
  def some_method {
133
142
  'it_works!
@@ -135,18 +144,91 @@ FancySpec describe: Object with: {
135
144
  }
136
145
 
137
146
  s = SomeClass new
138
- s if_responds? some_method should == 'it_works!
139
- s if_responds? some_undefined_method should == nil
147
+ s if_responds? some_method is: 'it_works!
148
+ s if_responds? some_undefined_method is: nil
140
149
  }
141
150
 
142
- it: "should call the backtick: method when using the '`' syntax" for: 'backtick: when: {
143
- `cat #{__FILE__}` should == (File read: __FILE__)
151
+ it: "calls the backtick: method when using the '`' syntax" with: 'backtick: when: {
152
+ `cat #{__FILE__}` is: (File read: __FILE__)
144
153
 
145
154
  # override backticks
146
155
  def backtick: str {
147
156
  str + " - NOT!"
148
157
  }
149
158
 
150
- `ls -al` should == "ls -al - NOT!"
159
+ `ls -al` is: "ls -al - NOT!"
160
+ }
161
+
162
+ it: "overrides true and does some wacky stuff" with: 'true when: {
163
+ class MyClass {
164
+ def true {
165
+ false
166
+ }
167
+
168
+ def do_wacky_things {
169
+ 4 == 5
170
+ }
171
+ }
172
+ MyClass new do_wacky_things is: false
173
+
174
+ {
175
+ true is: false
176
+ } call_with_receiver: (MyClass new)
177
+ }
178
+
179
+ it: "overrides nil" with: 'nil when: {
180
+ class MyClass {
181
+ def nil {
182
+ true
183
+ }
184
+ }
185
+
186
+ { nil is: true } call_with_receiver: (MyClass new)
187
+ }
188
+
189
+ it: "overrides false" with: 'false when: {
190
+ class MyClass2 {
191
+ def false {
192
+ true
193
+ }
194
+ }
195
+
196
+ { false is: true } call_with_receiver: (MyClass2 new)
197
+ }
198
+
199
+ it: "implicitly sends a message to self if no receiver is specified" when: {
200
+ def test { 42 }
201
+ test is: 42
202
+ self test is: 42
203
+ test is: (self test)
204
+ }
205
+
206
+ it: "calls a given block in the context of the receiver (like a message cascade)" with: 'do: when: {
207
+ arr = []
208
+ arr do: {
209
+ << 1
210
+ << 2
211
+ << 3
212
+ select!: 'even?
213
+ }
214
+ arr is: [2]
215
+ arr do: {
216
+ is: [2] # same
217
+ }
218
+ }
219
+
220
+ it: "returns a set of its slot names" with: 'slots when: {
221
+ class GotSlots {
222
+ def initialize {
223
+ @x, @y = 1, 2
224
+ }
225
+ def set_another_slot {
226
+ @z = 123
227
+ }
228
+ }
229
+ gs = GotSlots new
230
+ gs slots is: $ Set[['x, 'y]]
231
+ gs set_another_slot
232
+ gs slots is: $ Set[['x,'y,'z]]
151
233
  }
152
234
  }