sourcify 0.1.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/.document +5 -0
- data/.gitignore +21 -0
- data/HISTORY.txt +4 -0
- data/LICENSE +20 -0
- data/README.rdoc +154 -0
- data/Rakefile +114 -0
- data/VERSION +1 -0
- data/lib/sourcify.rb +12 -0
- data/lib/sourcify/proc.rb +53 -0
- data/lib/sourcify/proc/counter.rb +41 -0
- data/lib/sourcify/proc/lexer.rb +40 -0
- data/lib/sourcify/proc/lexer18.rb +224 -0
- data/lib/sourcify/proc/lexer19.rb +195 -0
- data/lib/sourcify/proc/parser.rb +74 -0
- data/sourcify.gemspec +109 -0
- data/spec/proc/19x_extras.rb +27 -0
- data/spec/proc/readme +5 -0
- data/spec/proc/to_sexp_variables_spec.rb +146 -0
- data/spec/proc/to_source_from_braced_block_w_nested_braced_block_spec.rb +33 -0
- data/spec/proc/to_source_from_braced_block_w_nested_hash_spec.rb +34 -0
- data/spec/proc/to_source_from_braced_block_wo_nesting_complication_spec.rb +46 -0
- data/spec/proc/to_source_from_do_end_block_w_nested_begin_spec.rb +35 -0
- data/spec/proc/to_source_from_do_end_block_w_nested_case_spec.rb +35 -0
- data/spec/proc/to_source_from_do_end_block_w_nested_class_spec.rb +89 -0
- data/spec/proc/to_source_from_do_end_block_w_nested_do_end_block_spec.rb +33 -0
- data/spec/proc/to_source_from_do_end_block_w_nested_for_spec.rb +132 -0
- data/spec/proc/to_source_from_do_end_block_w_nested_if_spec.rb +73 -0
- data/spec/proc/to_source_from_do_end_block_w_nested_method_spec.rb +33 -0
- data/spec/proc/to_source_from_do_end_block_w_nested_module_spec.rb +49 -0
- data/spec/proc/to_source_from_do_end_block_w_nested_unless_spec.rb +73 -0
- data/spec/proc/to_source_from_do_end_block_w_nested_until_spec.rb +176 -0
- data/spec/proc/to_source_from_do_end_block_w_nested_while_spec.rb +176 -0
- data/spec/proc/to_source_from_do_end_block_wo_nesting_complication_spec.rb +46 -0
- data/spec/proc/to_source_from_multi_blocks_w_many_matches_spec.rb +73 -0
- data/spec/proc/to_source_from_multi_blocks_w_single_match_spec.rb +31 -0
- data/spec/proc/to_source_from_multi_do_end_blocks_w_single_match_spec.rb +31 -0
- data/spec/proc/to_source_magic_file_var_spec.rb +127 -0
- data/spec/proc/to_source_magic_line_var_spec.rb +127 -0
- data/spec/proc/to_source_variables_spec.rb +29 -0
- data/spec/spec_helper.rb +41 -0
- metadata +159 -0
data/sourcify.gemspec
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{sourcify}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["NgTzeYang"]
|
12
|
+
s.date = %q{2010-08-28}
|
13
|
+
s.description = %q{}
|
14
|
+
s.email = %q{ngty77@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"HISTORY.txt",
|
23
|
+
"LICENSE",
|
24
|
+
"README.rdoc",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"lib/sourcify.rb",
|
28
|
+
"lib/sourcify/proc.rb",
|
29
|
+
"lib/sourcify/proc/counter.rb",
|
30
|
+
"lib/sourcify/proc/lexer.rb",
|
31
|
+
"lib/sourcify/proc/lexer18.rb",
|
32
|
+
"lib/sourcify/proc/lexer19.rb",
|
33
|
+
"lib/sourcify/proc/parser.rb",
|
34
|
+
"sourcify.gemspec",
|
35
|
+
"spec/proc/19x_extras.rb",
|
36
|
+
"spec/proc/readme",
|
37
|
+
"spec/proc/to_sexp_variables_spec.rb",
|
38
|
+
"spec/proc/to_source_from_braced_block_w_nested_braced_block_spec.rb",
|
39
|
+
"spec/proc/to_source_from_braced_block_w_nested_hash_spec.rb",
|
40
|
+
"spec/proc/to_source_from_braced_block_wo_nesting_complication_spec.rb",
|
41
|
+
"spec/proc/to_source_from_do_end_block_w_nested_begin_spec.rb",
|
42
|
+
"spec/proc/to_source_from_do_end_block_w_nested_case_spec.rb",
|
43
|
+
"spec/proc/to_source_from_do_end_block_w_nested_class_spec.rb",
|
44
|
+
"spec/proc/to_source_from_do_end_block_w_nested_do_end_block_spec.rb",
|
45
|
+
"spec/proc/to_source_from_do_end_block_w_nested_for_spec.rb",
|
46
|
+
"spec/proc/to_source_from_do_end_block_w_nested_if_spec.rb",
|
47
|
+
"spec/proc/to_source_from_do_end_block_w_nested_method_spec.rb",
|
48
|
+
"spec/proc/to_source_from_do_end_block_w_nested_module_spec.rb",
|
49
|
+
"spec/proc/to_source_from_do_end_block_w_nested_unless_spec.rb",
|
50
|
+
"spec/proc/to_source_from_do_end_block_w_nested_until_spec.rb",
|
51
|
+
"spec/proc/to_source_from_do_end_block_w_nested_while_spec.rb",
|
52
|
+
"spec/proc/to_source_from_do_end_block_wo_nesting_complication_spec.rb",
|
53
|
+
"spec/proc/to_source_from_multi_blocks_w_many_matches_spec.rb",
|
54
|
+
"spec/proc/to_source_from_multi_blocks_w_single_match_spec.rb",
|
55
|
+
"spec/proc/to_source_from_multi_do_end_blocks_w_single_match_spec.rb",
|
56
|
+
"spec/proc/to_source_magic_file_var_spec.rb",
|
57
|
+
"spec/proc/to_source_magic_line_var_spec.rb",
|
58
|
+
"spec/proc/to_source_variables_spec.rb",
|
59
|
+
"spec/spec_helper.rb"
|
60
|
+
]
|
61
|
+
s.homepage = %q{http://github.com/ngty/sourcify}
|
62
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
63
|
+
s.require_paths = ["lib"]
|
64
|
+
s.rubygems_version = %q{1.3.7}
|
65
|
+
s.summary = %q{Workarounds before ruby-core officially supports Proc#to_source (& friends)}
|
66
|
+
s.test_files = [
|
67
|
+
"spec/proc/to_source_from_do_end_block_w_nested_until_spec.rb",
|
68
|
+
"spec/proc/to_source_from_do_end_block_w_nested_begin_spec.rb",
|
69
|
+
"spec/proc/to_source_from_braced_block_w_nested_hash_spec.rb",
|
70
|
+
"spec/proc/to_source_from_braced_block_wo_nesting_complication_spec.rb",
|
71
|
+
"spec/proc/to_source_from_do_end_block_w_nested_while_spec.rb",
|
72
|
+
"spec/proc/to_source_from_multi_do_end_blocks_w_single_match_spec.rb",
|
73
|
+
"spec/proc/to_source_from_multi_blocks_w_many_matches_spec.rb",
|
74
|
+
"spec/proc/to_source_from_multi_blocks_w_single_match_spec.rb",
|
75
|
+
"spec/proc/to_source_from_do_end_block_w_nested_module_spec.rb",
|
76
|
+
"spec/proc/to_source_from_do_end_block_w_nested_do_end_block_spec.rb",
|
77
|
+
"spec/proc/to_source_from_do_end_block_w_nested_method_spec.rb",
|
78
|
+
"spec/proc/to_source_from_do_end_block_w_nested_class_spec.rb",
|
79
|
+
"spec/proc/to_source_from_do_end_block_w_nested_case_spec.rb",
|
80
|
+
"spec/proc/to_source_magic_line_var_spec.rb",
|
81
|
+
"spec/proc/to_source_from_do_end_block_w_nested_unless_spec.rb",
|
82
|
+
"spec/proc/19x_extras.rb",
|
83
|
+
"spec/proc/to_source_from_braced_block_w_nested_braced_block_spec.rb",
|
84
|
+
"spec/proc/to_source_from_do_end_block_wo_nesting_complication_spec.rb",
|
85
|
+
"spec/proc/to_source_variables_spec.rb",
|
86
|
+
"spec/proc/to_sexp_variables_spec.rb",
|
87
|
+
"spec/proc/to_source_magic_file_var_spec.rb",
|
88
|
+
"spec/proc/to_source_from_do_end_block_w_nested_if_spec.rb",
|
89
|
+
"spec/proc/to_source_from_do_end_block_w_nested_for_spec.rb",
|
90
|
+
"spec/spec_helper.rb"
|
91
|
+
]
|
92
|
+
|
93
|
+
if s.respond_to? :specification_version then
|
94
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
95
|
+
s.specification_version = 3
|
96
|
+
|
97
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
98
|
+
s.add_runtime_dependency(%q<ruby2ruby>, [">= 1.2.4"])
|
99
|
+
s.add_development_dependency(%q<bacon>, [">= 0"])
|
100
|
+
else
|
101
|
+
s.add_dependency(%q<ruby2ruby>, [">= 1.2.4"])
|
102
|
+
s.add_dependency(%q<bacon>, [">= 0"])
|
103
|
+
end
|
104
|
+
else
|
105
|
+
s.add_dependency(%q<ruby2ruby>, [">= 1.2.4"])
|
106
|
+
s.add_dependency(%q<bacon>, [">= 0"])
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
shared 'Proc#to_source from { ... } block (1.9.*)' do
|
2
|
+
|
3
|
+
should 'handle simple (w label keys)' do
|
4
|
+
(
|
5
|
+
lambda {
|
6
|
+
{a: 1, b: 2}
|
7
|
+
}
|
8
|
+
).should.be having_source(%Q\
|
9
|
+
proc do
|
10
|
+
{:a => 1, :b => 2}
|
11
|
+
end
|
12
|
+
\)
|
13
|
+
end
|
14
|
+
|
15
|
+
should 'handle nested (w label keys)' do
|
16
|
+
(
|
17
|
+
lambda {
|
18
|
+
{a: 1, b: {c: 3}}
|
19
|
+
}
|
20
|
+
).should.be having_source(%Q\
|
21
|
+
proc do
|
22
|
+
{:a => 1, :b => {:c => 3}}
|
23
|
+
end
|
24
|
+
\)
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
data/spec/proc/readme
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
Since Proc#to_source depends on Proc#to_sexp, getting Proc#to_source correct
|
2
|
+
implies the correctness of Proc#to_sexp, thus, there is no need to maintain
|
3
|
+
2 sets of almost similar specs ... the only spec worth maintaining separately
|
4
|
+
is the one for variables, since we are concerned with whether the correct
|
5
|
+
representation of sexp is there.
|
@@ -0,0 +1,146 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
|
3
|
+
describe "Proc#to_sexp (variables)" do
|
4
|
+
|
5
|
+
should 'handle non var' do
|
6
|
+
expected = s(:iter, s(:call, nil, :proc, s(:arglist)), nil, s(:call, nil, :x, s(:arglist)))
|
7
|
+
lambda { x }.should.be having_sexp(expected)
|
8
|
+
end
|
9
|
+
|
10
|
+
should 'handle local var' do
|
11
|
+
x, expected = 'lx', s(:iter, s(:call, nil, :proc, s(:arglist)), nil, s(:lvar, :x))
|
12
|
+
lambda { x }.should.be having_sexp(expected)
|
13
|
+
end
|
14
|
+
|
15
|
+
should 'handle instance var' do
|
16
|
+
@x, expected = 'ix', s(:iter, s(:call, nil, :proc, s(:arglist)), nil, s(:ivar, :@x))
|
17
|
+
lambda { @x }.should.be having_sexp(expected)
|
18
|
+
end
|
19
|
+
|
20
|
+
should 'handle class var' do
|
21
|
+
@@x, expected = 'cx', s(:iter, s(:call, nil, :proc, s(:arglist)), nil, s(:cvar, :@@x))
|
22
|
+
lambda { @@x }.should.be having_sexp(expected)
|
23
|
+
end
|
24
|
+
|
25
|
+
should 'handle global var' do
|
26
|
+
$x, expected = 'gx', s(:iter, s(:call, nil, :proc, s(:arglist)), nil, s(:gvar, :$x))
|
27
|
+
lambda { $x }.should.be having_sexp(expected)
|
28
|
+
end
|
29
|
+
|
30
|
+
should 'handle class_eval scoped local var' do
|
31
|
+
(
|
32
|
+
x = 1
|
33
|
+
lambda { Object.class_eval { y = x } }
|
34
|
+
).should.be having_sexp(
|
35
|
+
s(:iter,
|
36
|
+
s(:call, nil, :proc, s(:arglist)),
|
37
|
+
nil,
|
38
|
+
s(:iter,
|
39
|
+
s(:call, s(:const, :Object), :class_eval, s(:arglist)),
|
40
|
+
nil,
|
41
|
+
s(:lasgn, :y, s(:lvar, :x))))
|
42
|
+
)
|
43
|
+
end
|
44
|
+
|
45
|
+
should 'handle instance_eval scoped local var' do
|
46
|
+
(
|
47
|
+
x = 1
|
48
|
+
lambda { 'aa'.instance_eval { y = x } }
|
49
|
+
).should.be having_sexp(
|
50
|
+
s(:iter,
|
51
|
+
s(:call, nil, :proc, s(:arglist)),
|
52
|
+
nil,
|
53
|
+
s(:iter,
|
54
|
+
s(:call, s(:str, "aa"), :instance_eval, s(:arglist)),
|
55
|
+
nil,
|
56
|
+
s(:lasgn, :y, s(:lvar, :x))))
|
57
|
+
)
|
58
|
+
end
|
59
|
+
|
60
|
+
should 'handle define_method scoped local var' do
|
61
|
+
(
|
62
|
+
x = 1
|
63
|
+
lambda { Object.send(:define_method, :aa) { y = x } }
|
64
|
+
).should.be having_sexp(
|
65
|
+
s(:iter,
|
66
|
+
s(:call, nil, :proc, s(:arglist)),
|
67
|
+
nil,
|
68
|
+
s(:iter,
|
69
|
+
s(:call,
|
70
|
+
s(:const, :Object),
|
71
|
+
:send,
|
72
|
+
s(:arglist, s(:lit, :define_method), s(:lit, :aa))),
|
73
|
+
nil,
|
74
|
+
s(:lasgn, :y, s(:lvar, :x))))
|
75
|
+
)
|
76
|
+
end
|
77
|
+
|
78
|
+
should 'not handle class scoped local var (simple)' do
|
79
|
+
(
|
80
|
+
x = 1
|
81
|
+
lambda { class AA ; y = x ; end }
|
82
|
+
).should.be having_sexp(
|
83
|
+
s(:iter,
|
84
|
+
s(:call, nil, :proc, s(:arglist)),
|
85
|
+
nil,
|
86
|
+
s(:class, :AA, nil, s(:scope, s(:lasgn, :y, s(:call, nil, :x, s(:arglist))))))
|
87
|
+
)
|
88
|
+
end
|
89
|
+
|
90
|
+
should 'not handle class scoped local var (w inheritance)' do
|
91
|
+
(
|
92
|
+
x = 1
|
93
|
+
lambda { class AA < Object; y = x ; end }
|
94
|
+
).should.be having_sexp(
|
95
|
+
s(:iter,
|
96
|
+
s(:call, nil, :proc, s(:arglist)),
|
97
|
+
nil,
|
98
|
+
s(:class,
|
99
|
+
:AA,
|
100
|
+
s(:const, :Object),
|
101
|
+
s(:scope, s(:lasgn, :y, s(:call, nil, :x, s(:arglist))))))
|
102
|
+
)
|
103
|
+
end
|
104
|
+
|
105
|
+
should 'not handle class scoped local var (w singleton)' do
|
106
|
+
(
|
107
|
+
x = 1
|
108
|
+
lambda { class << 'AA'; y = x ; end }
|
109
|
+
).should.be having_sexp(
|
110
|
+
s(:iter,
|
111
|
+
s(:call, nil, :proc, s(:arglist)),
|
112
|
+
nil,
|
113
|
+
s(:sclass,
|
114
|
+
s(:str, "AA"),
|
115
|
+
s(:scope, s(:lasgn, :y, s(:call, nil, :x, s(:arglist))))))
|
116
|
+
)
|
117
|
+
end
|
118
|
+
|
119
|
+
should 'not handle module scoped local var' do
|
120
|
+
(
|
121
|
+
x = 1
|
122
|
+
lambda { module AA ; y = x ; end }
|
123
|
+
).should.be having_sexp(
|
124
|
+
s(:iter,
|
125
|
+
s(:call, nil, :proc, s(:arglist)),
|
126
|
+
nil,
|
127
|
+
s(:module, :AA, s(:scope, s(:lasgn, :y, s(:call, nil, :x, s(:arglist))))))
|
128
|
+
)
|
129
|
+
end
|
130
|
+
|
131
|
+
should 'not handle method scoped local var' do
|
132
|
+
(
|
133
|
+
x = 1
|
134
|
+
lambda { def aa ; y = x ; end }
|
135
|
+
).should.be having_sexp(
|
136
|
+
s(:iter,
|
137
|
+
s(:call, nil, :proc, s(:arglist)),
|
138
|
+
nil,
|
139
|
+
s(:defn,
|
140
|
+
:aa,
|
141
|
+
s(:args),
|
142
|
+
s(:scope, s(:block, s(:lasgn, :y, s(:call, nil, :x, s(:arglist)))))))
|
143
|
+
)
|
144
|
+
end
|
145
|
+
|
146
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
|
3
|
+
describe "Proc#to_source from { ... } block (w nested { ... } block)" do
|
4
|
+
|
5
|
+
should 'handle simple' do
|
6
|
+
(
|
7
|
+
lambda {
|
8
|
+
lambda { @x1 = 1 }
|
9
|
+
}
|
10
|
+
).should.be having_source(%Q\
|
11
|
+
proc do
|
12
|
+
lambda { @x1 = 1 }
|
13
|
+
end
|
14
|
+
\)
|
15
|
+
end
|
16
|
+
|
17
|
+
should 'handle nested' do
|
18
|
+
(
|
19
|
+
lambda {
|
20
|
+
lambda {
|
21
|
+
lambda { @x1 = 1 }
|
22
|
+
}
|
23
|
+
}
|
24
|
+
).should.be having_source(%Q\
|
25
|
+
proc do
|
26
|
+
lambda do
|
27
|
+
lambda { @x1 = 1 }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
\)
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
|
3
|
+
describe "Proc#to_source from { ... } block (w nested hash)" do
|
4
|
+
|
5
|
+
should 'handle simple' do
|
6
|
+
(
|
7
|
+
lambda {
|
8
|
+
{:a => 1, :b => 2}
|
9
|
+
}
|
10
|
+
).should.be having_source(%Q\
|
11
|
+
proc do
|
12
|
+
{:a => 1, :b => 2}
|
13
|
+
end
|
14
|
+
\)
|
15
|
+
end
|
16
|
+
|
17
|
+
should 'handle nested' do
|
18
|
+
(
|
19
|
+
lambda {
|
20
|
+
{:a => 1, :b => {:c => 3}}
|
21
|
+
}
|
22
|
+
).should.be having_source(%Q\
|
23
|
+
proc do
|
24
|
+
{:a => 1, :b => {:c => 3}}
|
25
|
+
end
|
26
|
+
\)
|
27
|
+
end
|
28
|
+
|
29
|
+
if RUBY_VERSION.include?('1.9.')
|
30
|
+
require File.join(File.dirname(__FILE__), '19x_extras')
|
31
|
+
behaves_like 'Proc#to_source from { ... } block (1.9.*)'
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
|
3
|
+
describe "Proc#to_source from { ... } block (wo nesting complication)" do
|
4
|
+
|
5
|
+
expected = 'proc { @x%s }'
|
6
|
+
|
7
|
+
should 'handle watever(..) { ... }' do
|
8
|
+
(
|
9
|
+
watever(:a, :b, {:c => 1}) { @x1 }
|
10
|
+
).should.be having_source(expected%1)
|
11
|
+
end
|
12
|
+
|
13
|
+
should 'handle watever(..) \ { ... }' do
|
14
|
+
(
|
15
|
+
watever(:a, :b, {:c => 1}) \
|
16
|
+
{ @x2 }
|
17
|
+
).should.be having_source(expected%2)
|
18
|
+
end
|
19
|
+
|
20
|
+
should 'handle watever { ... }' do
|
21
|
+
(
|
22
|
+
watever { @x3 }
|
23
|
+
).should.be having_source(expected%3)
|
24
|
+
end
|
25
|
+
|
26
|
+
should 'handle watever \ { ... }' do
|
27
|
+
(
|
28
|
+
watever \
|
29
|
+
{ @x4 }
|
30
|
+
).should.be having_source(expected%4)
|
31
|
+
end
|
32
|
+
|
33
|
+
should 'handle lambda { ... }' do
|
34
|
+
(
|
35
|
+
lambda { @x5 }
|
36
|
+
).should.be having_source(expected%5)
|
37
|
+
end
|
38
|
+
|
39
|
+
should 'handle lambda \ { ... }' do
|
40
|
+
(
|
41
|
+
lambda \
|
42
|
+
{ @x6 }
|
43
|
+
).should.be having_source(expected%6)
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
|
3
|
+
describe "Proc#to_source from do ... end block (w nested begin)" do
|
4
|
+
|
5
|
+
should 'handle simple' do
|
6
|
+
(
|
7
|
+
lambda do
|
8
|
+
begin @x1 = 1 end
|
9
|
+
end
|
10
|
+
).should.be having_source(%Q\
|
11
|
+
proc do
|
12
|
+
begin @x1 = 1 end
|
13
|
+
end
|
14
|
+
\)
|
15
|
+
end
|
16
|
+
|
17
|
+
should 'handle nested' do
|
18
|
+
(
|
19
|
+
lambda do
|
20
|
+
begin
|
21
|
+
@x1 = 1
|
22
|
+
begin @x2 = 2 end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
).should.be having_source(%Q\
|
26
|
+
proc do
|
27
|
+
begin
|
28
|
+
@x1 = 1
|
29
|
+
begin @x2 = 2 end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
\)
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
|
3
|
+
describe "Proc#to_source from do ... end block (w nested case)" do
|
4
|
+
|
5
|
+
should 'handle simple' do
|
6
|
+
(
|
7
|
+
lambda do
|
8
|
+
case @x1 when true then false end
|
9
|
+
end
|
10
|
+
).should.be having_source(%Q\
|
11
|
+
proc do
|
12
|
+
case @x1 when true then false end
|
13
|
+
end
|
14
|
+
\)
|
15
|
+
end
|
16
|
+
|
17
|
+
should 'handle nested' do
|
18
|
+
(
|
19
|
+
lambda do
|
20
|
+
case @x1
|
21
|
+
when true
|
22
|
+
case @x2 when false then true end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
).should.be having_source(%Q\
|
26
|
+
proc do
|
27
|
+
case @x1
|
28
|
+
when true
|
29
|
+
case @x2 when false then true end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
\)
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|