fancy 0.9.0 → 0.10.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 (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
@@ -72,9 +72,15 @@ class Hash {
72
72
  """
73
73
 
74
74
  match default_value {
75
- case Block -> @default_proc = true
75
+ case Block ->
76
+ @got_default_proc = true
77
+ @default = nil
78
+ @default_proc = default_value
79
+ case _ ->
80
+ @got_default_proc = false
81
+ @default = default_value
82
+ @default_proc = nil
76
83
  }
77
- @default = default_value
78
84
  }
79
85
 
80
86
  def default {
@@ -82,7 +88,11 @@ class Hash {
82
88
  @return Default value for @self.
83
89
  """
84
90
 
85
- @default
91
+ if: @got_default_proc then: {
92
+ @default_proc
93
+ } else: {
94
+ @default
95
+ }
86
96
  }
87
97
 
88
98
  def default_for: key {
@@ -98,6 +98,7 @@ class UnboundMethod {
98
98
  }
99
99
 
100
100
  def selector_with_args {
101
+ name = name to_s
101
102
  match name {
102
103
  case ":[]" -> return "[arg_0]"
103
104
  case "[]:" -> return "[arg_0]: arg_1"
@@ -1,10 +1,14 @@
1
1
  class Object {
2
- ruby_aliases: [ '==, '===, 'class, 'inspect, 'object_id, 'instance_variables, 'methods, 'instance_variable_get, 'instance_variable_set ]
2
+ ruby_aliases: [ '==, '===, 'class, 'inspect, 'object_id, 'instance_variables, 'methods, 'instance_variable_get, 'instance_variable_set, 'singleton_methods ]
3
3
 
4
4
  def initialize {
5
5
  initialize()
6
6
  }
7
7
 
8
+ def to_a {
9
+ [self]
10
+ }
11
+
8
12
  def require: file_path {
9
13
  """
10
14
  Loads and evaluates a given Fancy source file by trying to find the specified
@@ -1,5 +1,5 @@
1
1
  class Range {
2
- ruby_aliases: [ 'to_a, '==, '===, 'first, 'last ]
2
+ ruby_aliases: [ '==, '===, 'first, 'last ]
3
3
 
4
4
  def initialize: @start to: @end {
5
5
  """
@@ -0,0 +1,15 @@
1
+ class Rubinius VariableScope {
2
+ forwards_unary_ruby_methods
3
+
4
+ def receiver {
5
+ @self
6
+ }
7
+
8
+ def receiver: recv {
9
+ @self = recv
10
+ }
11
+ }
12
+
13
+ class Rubinius ConstantScope {
14
+ forwards_unary_ruby_methods
15
+ }
@@ -36,4 +36,8 @@ class Symbol {
36
36
  def to_fancy_message {
37
37
  to_s to_fancy_message to_sym
38
38
  }
39
+
40
+ def =~ regexp {
41
+ to_s =~ regexp
42
+ }
39
43
  }
@@ -29,7 +29,7 @@ class Thread {
29
29
 
30
30
  Thread metaclass ruby_alias: 'abort_on_exception
31
31
  Thread metaclass ruby_alias: 'current
32
- Thread metaclass ruby_alias: 'critical
32
+ # Thread metaclass ruby_alias: 'critical
33
33
  Thread metaclass ruby_alias: 'exit
34
34
  Thread metaclass ruby_alias: 'list
35
35
  Thread metaclass ruby_alias: 'main
data/lib/set.fy CHANGED
@@ -150,6 +150,17 @@ class Set {
150
150
  @hash delete: obj
151
151
  }
152
152
 
153
+ def clear {
154
+ """
155
+ @return @self.
156
+
157
+ Removes all elements from @self.
158
+ """
159
+
160
+ @hash = <[]>
161
+ self
162
+ }
163
+
153
164
  def + other {
154
165
  """
155
166
  @other Other Set to use for creating union Set.
@@ -10,23 +10,23 @@ class String {
10
10
 
11
11
  include: Fancy Enumerable
12
12
 
13
- instance_method: '== . documentation: """
14
- Compares @self to another @String@ and returns @true, if equal, @false otherwise.
15
- """
16
-
17
- instance_method: 'uppercase . documentation: """
18
- @return Uppercased version of @self.
19
-
20
- Example:
21
- \"hello world\" uppercase # => \"HELLO WORLD\"
22
- """
23
-
24
- instance_method: 'lowercase . documentation: """
25
- @return Lowercased version of @self.
26
-
27
- Example:
28
- \"HELLO WORLD\" lowercase # => \"hello world\"
29
- """
13
+ method_documentation: <[
14
+ '== => """
15
+ Compares @self to another @String@ and returns @true, if equal, @false otherwise.
16
+ """,
17
+ 'uppercase => """
18
+ @return Uppercased version of @self.
19
+
20
+ Example:
21
+ \"hello world\" uppercase # => \"HELLO WORLD\"
22
+ """,
23
+ 'lowercase => """
24
+ @return Lowercased version of @self.
25
+
26
+ Example:
27
+ \"HELLO WORLD\" lowercase # => \"hello world\"
28
+ """
29
+ ]>
30
30
 
31
31
  def ++ other {
32
32
  """
@@ -56,13 +56,17 @@ class Symbol {
56
56
  def arity {
57
57
  m = message_name to_s
58
58
  match m {
59
- case /^:[a-zA-Z0-9_]+$/ -> m count: |c| { c == ":" }
60
- case /^:\W+$/ -> 2
61
- case _ -> m count: |c| { c == ":" } + 1
59
+ case /^:[a-zA-Z0-9_]+$/ -> m count: |c| { c == ":" } # unary message
60
+ case /^:\W+$/ -> 2 # binary operator
61
+ case _ -> m count: |c| { c == ":" } + 1 # multi-arg message
62
62
  }
63
63
  }
64
64
 
65
65
  def to_sym {
66
+ """
67
+ @return @self.
68
+ """
69
+
66
70
  self
67
71
  }
68
72
 
@@ -59,19 +59,14 @@ class Tuple {
59
59
  Returns sub-array starting at from: and going to to:
60
60
  """
61
61
 
62
- if: (from < 0) then: {
63
- from = size + from
64
- }
65
- if: (to < 0) then: {
66
- to = size + to
67
- }
62
+ { from = size + from } if: $ from < 0
63
+ { to = size + to } if: $ to < 0
68
64
  subarr = []
69
65
  try {
70
66
  from upto: to do: |i| {
71
67
  subarr << (at: i)
72
68
  }
73
- } catch ObjectBoundsExceededError {
74
- }
69
+ } catch ObjectBoundsExceededError {}
75
70
  subarr
76
71
  }
77
72
 
@@ -1,6 +1,6 @@
1
1
  class Fancy {
2
2
  VERSION_MAJOR = 0
3
- VERSION_MINOR = 9
3
+ VERSION_MINOR = 10
4
4
  VERSION_PATCH = 0
5
5
 
6
6
  VERSION = [VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH] join: "."
@@ -25,7 +25,7 @@ begin
25
25
  Fancy::CodeLoader.push_loadpath File.expand_path("../lib", base)
26
26
 
27
27
  # Load compiler+eval support
28
- Fancy::CodeLoader.load_compiled_file File.expand_path("../lib/eval", base)
28
+ Fancy::CodeLoader.load_compiled_file File.expand_path("../lib/rbx/eval", base)
29
29
 
30
30
  # Run main
31
31
  Fancy::CodeLoader.load_compiled_file File.expand_path("../lib/main", base)
@@ -12,28 +12,15 @@ bcl.load_compiled_file File.expand_path("../lib/rbx/code_loader", base)
12
12
  Fancy::CodeLoader.push_loadpath File.expand_path("../lib", base)
13
13
 
14
14
  # Load compiler+eval support
15
- Fancy::CodeLoader.load_compiled_file File.expand_path("../lib/eval", base)
15
+ Fancy::CodeLoader.load_compiled_file File.expand_path("../lib/rbx/eval", base)
16
16
 
17
17
  class Object
18
- def fancy_message_args name_and_args
19
- method_name = []
20
- args = []
21
- name_and_args.each_with_index do |a, i|
22
- if i % 2 == 0
23
- method_name << a
24
- else
25
- args << a
26
- end
27
- end
28
- return [method_name.join(":") + ":", args]
29
- end
30
-
31
- def fy(*array_or_name)
32
- if array_or_name.size > 1
33
- message_name, args = fancy_message_args array_or_name
34
- self.send(message_name, *args)
18
+ def fy(message)
19
+ case message
20
+ when Hash
21
+ __send__(message.keys.join(":") << ":", *message.values)
35
22
  else
36
- self.send(":#{array_or_name}")
23
+ __send__(":#{message}")
37
24
  end
38
25
  end
39
26
 
@@ -9,7 +9,8 @@ module CodeRay
9
9
  file_extension 'fy'
10
10
 
11
11
  SPECIAL_FORMS = %w[
12
- def throw try catch class
12
+ self super return return_local def class
13
+ throw try catch finally retry match case
13
14
  ] # :nodoc:
14
15
 
15
16
  CORE_FORMS = %w[
@@ -26,14 +27,13 @@ module CodeRay
26
27
  add(PREDEFINED_CONSTANTS, :predefined_constant)
27
28
 
28
29
  KEYWORD_NEXT_TOKEN_KIND = WordList.new(nil).
29
- add(%w[ def defn defn- definline defmacro defmulti defmethod defstruct defonce declare ], :function).
30
- add(%w[ ns ], :namespace).
31
- add(%w[ defprotocol defrecord ], :class)
30
+ add(%w[ def ], :function).
31
+ add(%w[ class ], :class)
32
32
 
33
33
  BASIC_IDENTIFIER = /[a-zA-Z$%*\/_+!?&<>\-=]=?[a-zA-Z0-9$&*+!\/_?<>\-\#]*/
34
34
  CLASS_IDENTIFIER = /[A-Z]+[A-Za-z0-9]*|[A-Z]+[A-Za-z0-9]\:\:|\:\:[A-Z]+[A-Za-z0-9]*/
35
35
  IDENTIFIER = /(?!-\d)(?:(?:#{BASIC_IDENTIFIER}\.)*#{BASIC_IDENTIFIER}(?:\/#{BASIC_IDENTIFIER})?\.?)|\.\.?/
36
- SYMBOL = /\'[A-z]+[A-z0-9\:\!\%\^\&\*\_\-\+\=\|\?\\\/\>\<\.]*/o
36
+ SYMBOL = /\'[A-z0-9\:\!\%\^\&\*\_\-\+\=\|\?\\\/\>\<\~\.]+/o
37
37
  DIGIT = /\d+/
38
38
  DIGIT10 = DIGIT
39
39
  DIGIT16 = /[0-9a-f]/i
@@ -359,26 +359,24 @@ FancySpec describe: Block with: {
359
359
  a is: [2,1,2,1]
360
360
  }
361
361
 
362
- it: "calls itself while logging errors to *stdout*" with: 'call_with_errors_logged when: {
362
+ it: "calls itself while logging errors to *stderr*" with: 'call_with_errors_logged when: {
363
363
  io = StringIO new
364
- let: '*stdout* be: io in: {
364
+ let: '*stderr* be: io in: {
365
365
  {
366
- "hello" println
367
366
  2 / 0
368
367
  } call_with_errors_logged
369
368
  }
370
- io string is: "hello\ndivided by 0\n"
369
+ io string is: "divided by 0\n"
371
370
  }
372
371
 
373
- it: "calls itself with arguments while logging errors to *stdout*" with: 'call_with_errors_logged: when: {
372
+ it: "calls itself with arguments while logging errors to *stderr*" with: 'call_with_errors_logged: when: {
374
373
  io = StringIO new
375
- let: '*stdout* be: io in: {
374
+ let: '*stderr* be: io in: {
376
375
  |x y| {
377
- "x: #{x} y: #{y}" println
378
376
  2 / 0
379
377
  } call_with_errors_logged: [10, 20]
380
378
  }
381
- io string is: "x: 10 y: 20\ndivided by 0\n"
379
+ io string is: "divided by 0\n"
382
380
  }
383
381
 
384
382
  it: "calls itself while logging errors to a given IO object" with: 'call_with_errors_logged_to: when: {
@@ -389,16 +387,41 @@ FancySpec describe: Block with: {
389
387
  io string is: "divided by 0\n"
390
388
 
391
389
  io = StringIO new
392
- { "fail!" raise! } call_with_errors_logged_to: io
390
+ {
391
+ { "fail!" raise! } call_with_errors_logged_to: io
392
+ } does_not raise: StandardError
393
+ io string is: "fail!\n"
394
+ }
395
+
396
+ it: "calls itself while logging errors to a given IO object and reraising exceptions" with: 'call_with_errors_logged_to:reraise: when: {
397
+ io = StringIO new
398
+ {
399
+ {
400
+ "fail!" raise!
401
+ } call_with_errors_logged_to: io reraise: true
402
+ } raises: StandardError
393
403
  io string is: "fail!\n"
394
404
  }
395
405
 
396
406
  it: "calls itself with arguments while logging errors to a given IO object" with: 'call:with_errors_logged_to: when: {
397
407
  io = StringIO new
398
- |x y| {
399
- io println: "x: #{x} y: #{y}"
400
- 2 / 0
401
- } call: [10, 20] with_errors_logged_to: io
408
+ {
409
+ |x y| {
410
+ io println: "x: #{x} y: #{y}"
411
+ 2 / 0
412
+ } call: [10, 20] with_errors_logged_to: io
413
+ } does_not raise: ZeroDivisionError
414
+ io string is: "x: 10 y: 20\ndivided by 0\n"
415
+ }
416
+
417
+ it: "calls itself with arguments while logging errors to a given IO object and reraising exceptions" with: 'call:with_errors_logged_to:reraise: when: {
418
+ io = StringIO new
419
+ {
420
+ |x y| {
421
+ io println: "x: #{x} y: #{y}"
422
+ 2 / 0
423
+ } call: [10, 20] with_errors_logged_to: io reraise: true
424
+ } raises: ZeroDivisionError
402
425
  io string is: "x: 10 y: 20\ndivided by 0\n"
403
426
  }
404
427
  }
@@ -36,6 +36,8 @@ class ClassWithPrivate {
36
36
  private: 'private_method
37
37
  }
38
38
 
39
+ require: "stringio"
40
+
39
41
  FancySpec describe: Class with: {
40
42
  it: "does NOT find the method when not mixed-in" with: 'responds_to?: when: {
41
43
  instance = ClassWithMixin new
@@ -208,7 +210,8 @@ FancySpec describe: Class with: {
208
210
  Symbol superclass is: Object
209
211
  StdError superclass is: Exception
210
212
  Class superclass is: Module
211
- Object superclass is: nil
213
+ Object superclass is: BasicObject
214
+ BasicObject superclass is: nil
212
215
 
213
216
  IOError superclass is: StandardError
214
217
  NoMethodError superclass is: NameError
@@ -438,7 +441,7 @@ FancySpec describe: Class with: {
438
441
  try {
439
442
  [] equal?: [1,2] . is: true # is fail
440
443
  } catch NoMethodError => e {
441
- e method_name is: 'equal?:
444
+ e message does =~ /equal\?:/
442
445
  }
443
446
 
444
447
  class Array {
@@ -453,9 +456,9 @@ FancySpec describe: Class with: {
453
456
  class B : A
454
457
  class C : B
455
458
 
456
- A ancestors is: [A, Object, Kernel]
457
- B ancestors is: [B, A, Object, Kernel]
458
- C ancestors is: [C, B, A, Object, Kernel]
459
+ A ancestors is: [A, Object, Kernel, BasicObject]
460
+ B ancestors is: [B, A, Object, Kernel, BasicObject]
461
+ C ancestors is: [C, B, A, Object, Kernel, BasicObject]
459
462
  }
460
463
 
461
464
  it: "makes methods private" with: 'private: when: {
@@ -605,7 +608,7 @@ FancySpec describe: Class with: {
605
608
  }
606
609
 
607
610
  it: "returns its nested constants" with: 'constants when: {
608
- WithConstants constants =? ["Foo", "Bar", "Nested"] is: true
611
+ WithConstants constants =? ['Foo, 'Bar, 'Nested] is: true
609
612
  }
610
613
 
611
614
  it: "returns a constants value" with: '[] when: {
@@ -684,7 +687,8 @@ FancySpec describe: Class with: {
684
687
  Fixnum inspect is: "Fixnum : Integer"
685
688
  MySuperClass inspect is: "MySuperClass : Object"
686
689
  MySubClass inspect is: "MySubClass : MySuperClass"
687
- Object inspect is: "Object"
690
+ Object inspect is: "Object : BasicObject"
691
+ BasicObject inspect is: "BasicObject"
688
692
  }
689
693
 
690
694
  it: "returns the right amount of instance methods" with: 'instance_methods: when: {
@@ -700,156 +704,156 @@ FancySpec describe: Class with: {
700
704
  Set[OneMethod instance_methods] is: $ Set[Object instance_methods + (OneMethod instance_methods: false)]
701
705
  }
702
706
 
703
- it: "defines a before_method handler" with: 'before_method:run: when: {
704
- class BeforeMethodClass {
705
- read_slot: 'x
706
- def initialize: @x
707
- def before: arr {
708
- arr << "Before Method: #{@x}"
709
- }
710
- def my_method: arr {
711
- arr << "My Method: #{@x}"
712
- }
707
+ # it: "defines a before_method handler" with: 'before_method:run: when: {
708
+ # class BeforeMethodClass {
709
+ # read_slot: 'x
710
+ # def initialize: @x
711
+ # def before: arr {
712
+ # arr << "Before Method: #{@x}"
713
+ # }
714
+ # def my_method: arr {
715
+ # arr << "My Method: #{@x}"
716
+ # }
713
717
 
714
- before_method: 'my_method: run: 'before:
715
- }
718
+ # before_method: 'my_method: run: 'before:
719
+ # }
716
720
 
717
- b1 = BeforeMethodClass new: 1
718
- b2 = BeforeMethodClass new: 2
721
+ # b1 = BeforeMethodClass new: 1
722
+ # b2 = BeforeMethodClass new: 2
719
723
 
720
- array = []
724
+ # array = []
721
725
 
722
- b1 my_method: array
723
- b2 my_method: array
726
+ # b1 my_method: array
727
+ # b2 my_method: array
724
728
 
725
- array is: [
726
- "Before Method: 1", "My Method: 1",
727
- "Before Method: 2", "My Method: 2"
728
- ]
729
+ # array is: [
730
+ # "Before Method: 1", "My Method: 1",
731
+ # "Before Method: 2", "My Method: 2"
732
+ # ]
729
733
 
730
- # we can also pass blocks
734
+ # # we can also pass blocks
731
735
 
732
- BeforeMethodClass before_method: 'my_method: run: |receiver array| {
733
- array << "Before Block: #{receiver x}"
734
- }
736
+ # BeforeMethodClass before_method: 'my_method: run: |receiver array| {
737
+ # array << "Before Block: #{receiver x}"
738
+ # }
735
739
 
736
- array = []
740
+ # array = []
737
741
 
738
- b1 my_method: array
739
- b2 my_method: array
742
+ # b1 my_method: array
743
+ # b2 my_method: array
740
744
 
741
- array is: [
742
- "Before Block: 1", "Before Method: 1", "My Method: 1",
743
- "Before Block: 2", "Before Method: 2", "My Method: 2"
744
- ]
745
- }
745
+ # array is: [
746
+ # "Before Block: 1", "Before Method: 1", "My Method: 1",
747
+ # "Before Block: 2", "Before Method: 2", "My Method: 2"
748
+ # ]
749
+ # }
746
750
 
747
- it: "defines an after_method handler" with: 'after_method:run: when: {
748
- class AfterMethodClass {
749
- read_slot: 'x
750
- def initialize: @x
751
- def after: arr {
752
- arr << "After Method: #{@x}"
753
- }
754
- def my_method: arr {
755
- arr << "My Method: #{@x}"
756
- }
751
+ # it: "defines an after_method handler" with: 'after_method:run: when: {
752
+ # class AfterMethodClass {
753
+ # read_slot: 'x
754
+ # def initialize: @x
755
+ # def after: arr {
756
+ # arr << "After Method: #{@x}"
757
+ # }
758
+ # def my_method: arr {
759
+ # arr << "My Method: #{@x}"
760
+ # }
757
761
 
758
- after_method: 'my_method: run: 'after:
759
- }
762
+ # after_method: 'my_method: run: 'after:
763
+ # }
760
764
 
761
- b1 = AfterMethodClass new: 1
762
- b2 = AfterMethodClass new: 2
765
+ # b1 = AfterMethodClass new: 1
766
+ # b2 = AfterMethodClass new: 2
763
767
 
764
- array = []
768
+ # array = []
765
769
 
766
- b1 my_method: array
767
- b2 my_method: array
770
+ # b1 my_method: array
771
+ # b2 my_method: array
768
772
 
769
- array is: [
770
- "My Method: 1", "After Method: 1",
771
- "My Method: 2", "After Method: 2"
772
- ]
773
+ # array is: [
774
+ # "My Method: 1", "After Method: 1",
775
+ # "My Method: 2", "After Method: 2"
776
+ # ]
773
777
 
774
- AfterMethodClass after_method: 'my_method: run: |receiver array| {
775
- "block getting called yo"
776
- array << "After Block: #{receiver x}"
777
- }
778
+ # AfterMethodClass after_method: 'my_method: run: |receiver array| {
779
+ # "block getting called yo"
780
+ # array << "After Block: #{receiver x}"
781
+ # }
778
782
 
779
- array = []
783
+ # array = []
780
784
 
781
- b1 my_method: array
782
- b2 my_method: array
785
+ # b1 my_method: array
786
+ # b2 my_method: array
783
787
 
784
- array is: [
785
- "My Method: 1", "After Method: 1", "After Block: 1",
786
- "My Method: 2", "After Method: 2", "After Block: 2"
787
- ]
788
- }
788
+ # array is: [
789
+ # "My Method: 1", "After Method: 1", "After Block: 1",
790
+ # "My Method: 2", "After Method: 2", "After Block: 2"
791
+ # ]
792
+ # }
789
793
 
790
794
 
791
- it: "defines an around_method handler" with: 'around_method:run: when: {
792
- class AroundMethodClass {
793
- read_slot: 'x
794
- def initialize: @x
795
- def around: arr {
796
- arr << "Around Method: #{@x}"
797
- }
798
- def my_method: arr {
799
- arr << "My Method: #{@x}"
800
- }
795
+ # it: "defines an around_method handler" with: 'around_method:run: when: {
796
+ # class AroundMethodClass {
797
+ # read_slot: 'x
798
+ # def initialize: @x
799
+ # def around: arr {
800
+ # arr << "Around Method: #{@x}"
801
+ # }
802
+ # def my_method: arr {
803
+ # arr << "My Method: #{@x}"
804
+ # }
801
805
 
802
- around_method: 'my_method: run: 'around:
803
- }
806
+ # around_method: 'my_method: run: 'around:
807
+ # }
804
808
 
805
- b1 = AroundMethodClass new: 1
806
- b2 = AroundMethodClass new: 2
809
+ # b1 = AroundMethodClass new: 1
810
+ # b2 = AroundMethodClass new: 2
807
811
 
808
- array = []
812
+ # array = []
809
813
 
810
- b1 my_method: array
811
- b2 my_method: array
814
+ # b1 my_method: array
815
+ # b2 my_method: array
812
816
 
813
- array is: [
814
- "Around Method: 1", "My Method: 1", "Around Method: 1",
815
- "Around Method: 2", "My Method: 2", "Around Method: 2"
816
- ]
817
+ # array is: [
818
+ # "Around Method: 1", "My Method: 1", "Around Method: 1",
819
+ # "Around Method: 2", "My Method: 2", "Around Method: 2"
820
+ # ]
817
821
 
818
822
 
819
- AroundMethodClass around_method: 'my_method: run: |receiver array| {
820
- array << "Around Block: #{receiver x}"
821
- }
823
+ # AroundMethodClass around_method: 'my_method: run: |receiver array| {
824
+ # array << "Around Block: #{receiver x}"
825
+ # }
822
826
 
823
- array = []
827
+ # array = []
824
828
 
825
- b1 my_method: array
826
- b2 my_method: array
829
+ # b1 my_method: array
830
+ # b2 my_method: array
827
831
 
828
- array is: [
829
- "Around Block: 1", "Around Method: 1", "My Method: 1", "Around Method: 1", "Around Block: 1",
830
- "Around Block: 2", "Around Method: 2", "My Method: 2", "Around Method: 2", "Around Block: 2"
831
- ]
832
- }
832
+ # array is: [
833
+ # "Around Block: 1", "Around Method: 1", "My Method: 1", "Around Method: 1", "Around Block: 1",
834
+ # "Around Block: 2", "Around Method: 2", "My Method: 2", "Around Method: 2", "Around Block: 2"
835
+ # ]
836
+ # }
833
837
 
834
- it: "defines a custom calling chain for a method" with: 'define_calling_chain:for_method: when: {
835
- class CallingChainClass {
836
- def foo: arr { arr << "foo" }
837
- def bar: arr { arr << "bar" }
838
- def baz: arr { arr << "baz" }
838
+ # it: "defines a custom calling chain for a method" with: 'define_calling_chain:for_method: when: {
839
+ # class CallingChainClass {
840
+ # def foo: arr { arr << "foo" }
841
+ # def bar: arr { arr << "bar" }
842
+ # def baz: arr { arr << "baz" }
839
843
 
840
- define_calling_chain: ('foo:, 'bar:, 'baz:) for_method: 'foo:
841
- }
844
+ # define_calling_chain: ('foo:, 'bar:, 'baz:) for_method: 'foo:
845
+ # }
842
846
 
843
- arr = []
844
- CallingChainClass new foo: arr
845
- arr is: ["foo", "bar", "baz"]
847
+ # arr = []
848
+ # CallingChainClass new foo: arr
849
+ # arr is: ["foo", "bar", "baz"]
846
850
 
847
- CallingChainClass define_calling_chain: [|receiver arr|{ receiver baz: arr }, 'bar:] for_method: 'bar:
851
+ # CallingChainClass define_calling_chain: [|receiver arr|{ receiver baz: arr }, 'bar:] for_method: 'bar:
848
852
 
849
- arr = []
850
- CallingChainClass new bar: arr
851
- arr is: ["baz", "bar"]
852
- }
853
+ # arr = []
854
+ # CallingChainClass new bar: arr
855
+ # arr is: ["baz", "bar"]
856
+ # }
853
857
 
854
858
  it: "exposes a Fancy method as a Ruby method to Ruby" with: 'expose_to_ruby:as: when: {
855
859
  class ExposeToRuby {