opal 0.3.2 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +85 -127
- data/bin/opal +3 -3
- data/lib/core.rb +114 -0
- data/{gems/core/lib → lib}/core/array.rb +68 -187
- data/{gems/core/lib → lib}/core/basic_object.rb +22 -5
- data/lib/core/class.rb +38 -0
- data/{gems/core/lib → lib}/core/dir.rb +1 -1
- data/lib/core/enumerable.rb +33 -0
- data/{gems/core/lib → lib}/core/error.rb +1 -4
- data/{gems/core/lib → lib}/core/false_class.rb +0 -0
- data/{gems/core/lib → lib}/core/file.rb +11 -3
- data/{gems/core/lib → lib}/core/hash.rb +12 -0
- data/{gems/core/lib → lib}/core/kernel.rb +114 -86
- data/lib/core/match_data.rb +33 -0
- data/lib/core/module.rb +97 -0
- data/{gems/core/lib → lib}/core/nil_class.rb +0 -0
- data/{gems/core/lib → lib}/core/numeric.rb +5 -0
- data/{gems/core/lib → lib}/core/object.rb +0 -0
- data/{gems/core/lib → lib}/core/proc.rb +13 -3
- data/{gems/core/lib → lib}/core/range.rb +10 -0
- data/{gems/core/lib → lib}/core/regexp.rb +33 -1
- data/{gems/core/lib → lib}/core/string.rb +25 -10
- data/{gems/core/lib → lib}/core/symbol.rb +3 -3
- data/{gems/core/lib → lib}/core/top_self.rb +0 -0
- data/{gems/core/lib → lib}/core/true_class.rb +0 -0
- data/lib/dev.rb +169 -0
- data/{gems/ospec/lib → lib}/ospec.rb +1 -0
- data/lib/ospec/autorun.rb +8 -0
- data/{gems/ospec/lib → lib}/ospec/dsl.rb +2 -2
- data/{gems/ospec/lib → lib}/ospec/example.rb +0 -0
- data/{gems/ospec/lib → lib}/ospec/example/before_and_after_hooks.rb +0 -0
- data/{gems/ospec/lib → lib}/ospec/example/errors.rb +0 -0
- data/{gems/ospec/lib → lib}/ospec/example/example_group.rb +0 -0
- data/{gems/ospec/lib → lib}/ospec/example/example_group_factory.rb +0 -3
- data/{gems/ospec/lib → lib}/ospec/example/example_group_hierarchy.rb +4 -3
- data/{gems/ospec/lib → lib}/ospec/example/example_group_methods.rb +1 -1
- data/{gems/ospec/lib → lib}/ospec/example/example_group_proxy.rb +3 -2
- data/{gems/ospec/lib → lib}/ospec/example/example_methods.rb +1 -1
- data/{gems/ospec/lib → lib}/ospec/example/example_proxy.rb +7 -7
- data/{gems/ospec/lib → lib}/ospec/expectations.rb +0 -0
- data/{gems/ospec/lib → lib}/ospec/expectations/errors.rb +0 -0
- data/{gems/ospec/lib → lib}/ospec/expectations/fail_with.rb +4 -3
- data/{gems/ospec/lib → lib}/ospec/expectations/handler.rb +6 -0
- data/lib/ospec/helpers/scratch.rb +18 -0
- data/{gems/ospec/lib → lib}/ospec/matchers.rb +2 -2
- data/{gems/ospec/lib → lib}/ospec/matchers/be.rb +0 -0
- data/{gems/ospec/lib → lib}/ospec/matchers/generated_descriptions.rb +0 -0
- data/{gems/ospec/lib → lib}/ospec/matchers/operator_matcher.rb +2 -0
- data/lib/ospec/matchers/raise_error.rb +38 -0
- data/lib/ospec/runner.rb +90 -0
- data/{gems/ospec/lib → lib}/ospec/runner/example_group_runner.rb +10 -13
- data/lib/ospec/runner/formatter/html_formatter.rb +139 -0
- data/{gems/ospec/lib → lib}/ospec/runner/formatter/terminal_formatter.rb +0 -0
- data/{gems/ospec/lib → lib}/ospec/runner/options.rb +1 -3
- data/{gems/ospec/lib → lib}/ospec/runner/reporter.rb +0 -9
- data/lib/racc/parser.rb +165 -0
- data/lib/strscan.rb +52 -0
- data/{lib → opal_lib}/opal.rb +2 -0
- data/opal_lib/opal/build_methods.rb +51 -0
- data/opal_lib/opal/builder.rb +164 -0
- data/opal_lib/opal/bundle.rb +70 -0
- data/opal_lib/opal/command.rb +68 -0
- data/{lib → opal_lib}/opal/context.rb +21 -9
- data/{lib → opal_lib}/opal/context/console.rb +0 -2
- data/opal_lib/opal/context/file_system.rb +34 -0
- data/{lib → opal_lib}/opal/context/loader.rb +26 -8
- data/opal_lib/opal/gem.rb +84 -0
- data/{lib → opal_lib}/opal/rake/builder_task.rb +2 -2
- data/opal_lib/opal/rake/spec_task.rb +32 -0
- data/{lib → opal_lib}/opal/ruby/nodes.rb +730 -109
- data/{lib → opal_lib}/opal/ruby/parser.rb +90 -23
- data/opal_lib/opal/ruby/ruby_parser.rb +4862 -0
- data/opal_lib/opal/ruby/ruby_parser.y +1454 -0
- data/opal_lib/opal/version.rb +4 -0
- data/runtime/class.js +359 -0
- data/runtime/debug.js +84 -0
- data/runtime/fs.js +199 -0
- data/runtime/init.js +558 -0
- data/runtime/loader.js +351 -0
- data/runtime/module.js +109 -0
- data/runtime/post.js +10 -0
- data/runtime/pre.js +7 -0
- data/runtime/runtime.js +351 -0
- metadata +88 -175
- data/.gitignore +0 -7
- data/Changelog +0 -31
- data/LICENSE +0 -75
- data/Rakefile +0 -86
- data/gems/core/README.md +0 -14
- data/gems/core/Rakefile +0 -8
- data/gems/core/core.gemspec +0 -13
- data/gems/core/lib/core.rb +0 -34
- data/gems/core/lib/core/class.rb +0 -31
- data/gems/core/lib/core/module.rb +0 -100
- data/gems/core/lib/core/vm.rb +0 -16
- data/gems/core/spec/core/array/append_spec.rb +0 -30
- data/gems/core/spec/core/array/assoc_spec.rb +0 -29
- data/gems/core/spec/core/array/at_spec.rb +0 -37
- data/gems/core/spec/core/array/clear_spec.rb +0 -22
- data/gems/core/spec/core/array/collect_bang_spec.rb +0 -27
- data/gems/core/spec/core/array/collect_spec.rb +0 -27
- data/gems/core/spec/core/array/compact_spec.rb +0 -41
- data/gems/core/spec/core/array/concat_spec.rb +0 -15
- data/gems/core/spec/core/array/constructor_spec.rb +0 -14
- data/gems/core/spec/core/array/each_spec.rb +0 -9
- data/gems/core/spec/core/array/element_reference_spec.rb +0 -4
- data/gems/core/spec/core/array/first_spec.rb +0 -35
- data/gems/core/spec/core/array/include_spec.rb +0 -9
- data/gems/core/spec/core/array/join_spec.rb +0 -6
- data/gems/core/spec/core/array/last_spec.rb +0 -51
- data/gems/core/spec/core/array/length_spec.rb +0 -6
- data/gems/core/spec/core/array/map_spec.rb +0 -33
- data/gems/core/spec/core/array/reverse_spec.rb +0 -6
- data/gems/core/spec/core/builtin_constants/builtin_constants_spec.rb +0 -7
- data/gems/core/spec/core/false/and_spec.rb +0 -10
- data/gems/core/spec/core/false/inspect_spec.rb +0 -6
- data/gems/core/spec/core/false/or_spec.rb +0 -10
- data/gems/core/spec/core/false/to_s_spec.rb +0 -6
- data/gems/core/spec/core/false/xor_spec.rb +0 -10
- data/gems/core/spec/core/file/join_spec.rb +0 -19
- data/gems/core/spec/core/hash/assoc_spec.rb +0 -32
- data/gems/core/spec/core/kernel/instance_eval_spec.rb +0 -0
- data/gems/core/spec/core/kernel/loop_spec.rb +0 -24
- data/gems/core/spec/core/kernel/raise_spec.rb +0 -0
- data/gems/core/spec/core/module/attr_accessor_spec.rb +0 -28
- data/gems/core/spec/core/number/lt_spec.rb +0 -12
- data/gems/core/spec/core/string/sub_spec.rb +0 -24
- data/gems/core/spec/core/true/and_spec.rb +0 -10
- data/gems/core/spec/core/true/inspect_spec.rb +0 -6
- data/gems/core/spec/core/true/or_spec.rb +0 -10
- data/gems/core/spec/core/true/to_s_spec.rb +0 -6
- data/gems/core/spec/core/true/xor_spec.rb +0 -10
- data/gems/core/spec/language/and_spec.rb +0 -61
- data/gems/core/spec/language/array_spec.rb +0 -68
- data/gems/core/spec/language/block_spec.rb +0 -38
- data/gems/core/spec/language/break_spec.rb +0 -36
- data/gems/core/spec/language/case_spec.rb +0 -103
- data/gems/core/spec/language/def_spec.rb +0 -21
- data/gems/core/spec/language/eigenclass_spec.rb +0 -60
- data/gems/core/spec/language/file_spec.rb +0 -13
- data/gems/core/spec/language/fixtures/block.rb +0 -21
- data/gems/core/spec/language/fixtures/super.rb +0 -293
- data/gems/core/spec/language/hash_spec.rb +0 -29
- data/gems/core/spec/language/if_spec.rb +0 -54
- data/gems/core/spec/language/loop_spec.rb +0 -11
- data/gems/core/spec/language/metaclass_spec.rb +0 -21
- data/gems/core/spec/language/method_spec.rb +0 -124
- data/gems/core/spec/language/next_spec.rb +0 -25
- data/gems/core/spec/language/or_spec.rb +0 -34
- data/gems/core/spec/language/redo_spec.rb +0 -24
- data/gems/core/spec/language/regexp_spec.rb +0 -26
- data/gems/core/spec/language/rescue_spec.rb +0 -20
- data/gems/core/spec/language/return_spec.rb +0 -47
- data/gems/core/spec/language/string_spec.rb +0 -25
- data/gems/core/spec/language/super_spec.rb +0 -32
- data/gems/core/spec/language/until_spec.rb +0 -157
- data/gems/core/spec/language/variables_spec.rb +0 -155
- data/gems/core/spec/language/while_spec.rb +0 -163
- data/gems/core/spec/spec_helper.rb +0 -5
- data/gems/core_fs/README.md +0 -19
- data/gems/dev/Rakefile +0 -5
- data/gems/dev/lib/dev.js +0 -99
- data/gems/dev/lib/dev/generator.js +0 -1264
- data/gems/dev/lib/dev/parser.js +0 -979
- data/gems/dev/lib/dev/ruby_parser.js +0 -1088
- data/gems/dev/lib/dev/ruby_parser.y +0 -1267
- data/gems/dev/lib/dev/string_scanner.js +0 -38
- data/gems/dev/tools/racc2js/README.md +0 -39
- data/gems/dev/tools/racc2js/math_parser.js +0 -222
- data/gems/dev/tools/racc2js/math_parser.rb +0 -133
- data/gems/dev/tools/racc2js/math_parser.y +0 -28
- data/gems/dev/tools/racc2js/parser.js +0 -218
- data/gems/dev/tools/racc2js/racc2js.rb +0 -153
- data/gems/json/README.md +0 -4
- data/gems/json/json.gemspec +0 -14
- data/gems/json/lib/json.rb +0 -64
- data/gems/json/lib/json/ext.rb +0 -51
- data/gems/json/lib/json/json2.js +0 -481
- data/gems/ospec/README.md +0 -0
- data/gems/ospec/lib/ospec/autorun.rb +0 -3
- data/gems/ospec/lib/ospec/runner.rb +0 -40
- data/gems/ospec/lib/ospec/runner/formatter/html_formatter.rb +0 -91
- data/gems/ospec/ospec.gemspec +0 -0
- data/gems/rquery/README.md +0 -9
- data/gems/rquery/lib/rquery.rb +0 -10
- data/gems/rquery/lib/rquery/ajax.rb +0 -4
- data/gems/rquery/lib/rquery/css.rb +0 -96
- data/gems/rquery/lib/rquery/document.rb +0 -25
- data/gems/rquery/lib/rquery/element.rb +0 -292
- data/gems/rquery/lib/rquery/event.rb +0 -108
- data/gems/rquery/lib/rquery/jquery.js +0 -8177
- data/gems/rquery/lib/rquery/request.rb +0 -138
- data/gems/rquery/lib/rquery/response.rb +0 -49
- data/gems/rquery/rquery.gemspec +0 -16
- data/lib/opal.js +0 -1597
- data/lib/opal/builder.rb +0 -117
- data/lib/opal/bundle.rb +0 -131
- data/lib/opal/command.rb +0 -11
- data/lib/opal/context/file_system.rb +0 -19
- data/lib/opal/gem.rb +0 -153
- data/lib/opal/ruby/ruby_parser.rb +0 -5170
- data/lib/opal/ruby/ruby_parser.y +0 -1298
- data/opal.gemspec +0 -15
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
describe "Operator assignment 'var op= expr'" do
|
|
3
|
-
it "is equivalent to 'var = var op expr'" do
|
|
4
|
-
x = 13
|
|
5
|
-
(x += 5).should == 18
|
|
6
|
-
x.should == 18
|
|
7
|
-
|
|
8
|
-
x = 17
|
|
9
|
-
(x -= 11).should == 6
|
|
10
|
-
x.should == 6
|
|
11
|
-
|
|
12
|
-
x = 2
|
|
13
|
-
(x *= 5).should == 10
|
|
14
|
-
x.should == 10
|
|
15
|
-
|
|
16
|
-
# x = 36
|
|
17
|
-
# (x /= 9).should == 4
|
|
18
|
-
# x.should == 4
|
|
19
|
-
|
|
20
|
-
# x = 23
|
|
21
|
-
# (x %= 5).should == 3
|
|
22
|
-
# x.should == 3
|
|
23
|
-
# (x %= 3).should == 0
|
|
24
|
-
# x.should == 0
|
|
25
|
-
|
|
26
|
-
# x = 2
|
|
27
|
-
# (x **= 3).should == 8
|
|
28
|
-
# x.should == 8
|
|
29
|
-
|
|
30
|
-
# x = 4
|
|
31
|
-
# (x |= 3).should == 7
|
|
32
|
-
# x.should == 7
|
|
33
|
-
# (x |= 4).should == 7
|
|
34
|
-
# x.should == 7
|
|
35
|
-
|
|
36
|
-
# x = 6
|
|
37
|
-
# (x &= 3).should == 2
|
|
38
|
-
# x.should == 2
|
|
39
|
-
# (x &= 4).should == 0
|
|
40
|
-
# x.should == 0
|
|
41
|
-
|
|
42
|
-
# x = 2
|
|
43
|
-
# (x ^= 3).should == 1
|
|
44
|
-
# x.should == 1
|
|
45
|
-
# (x ^= 4).should == 5
|
|
46
|
-
# x.should == 5
|
|
47
|
-
|
|
48
|
-
# x = 17
|
|
49
|
-
# (x <<= 3).should == 136
|
|
50
|
-
# x.should == 136
|
|
51
|
-
|
|
52
|
-
# x = 5
|
|
53
|
-
# (x >>= 1).should == 2
|
|
54
|
-
# x.should == 2
|
|
55
|
-
|
|
56
|
-
x = nil
|
|
57
|
-
(x ||= 17).should == 17
|
|
58
|
-
x.should == 17
|
|
59
|
-
(x ||= 2).should == 17
|
|
60
|
-
x.should == 17
|
|
61
|
-
|
|
62
|
-
# x = false
|
|
63
|
-
# (x &&= true).should == false
|
|
64
|
-
# x.should == false
|
|
65
|
-
# (x &&= false).should == false
|
|
66
|
-
# x.should == false
|
|
67
|
-
# x = true
|
|
68
|
-
# (x &&= true).should == true
|
|
69
|
-
# x.should == true
|
|
70
|
-
# (x &&= false).should == false
|
|
71
|
-
# x.should == false
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
describe "Operator assignment 'obj[idx] op= expr'" do
|
|
76
|
-
it "is equivalent to 'obj[idx] = obj[idx] op expr'" do
|
|
77
|
-
x = [2, 13, 7]
|
|
78
|
-
(x[1] += 5).should == 18
|
|
79
|
-
x.should == [2, 18, 7]
|
|
80
|
-
|
|
81
|
-
x = [17, 6]
|
|
82
|
-
(x[0] -= 11).should == 6
|
|
83
|
-
x.should == [6, 6]
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
describe "Single assignment" do
|
|
88
|
-
it "Assignment does not modify the lhs, it reassigns its reference" do
|
|
89
|
-
a = 'Foobar'
|
|
90
|
-
b = a
|
|
91
|
-
b = 'Bazquux'
|
|
92
|
-
a.should == 'Foobar'
|
|
93
|
-
b.should == 'Bazquux'
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
it "Assignment does not copy the object being assigned, just creates a new reference to it" do
|
|
97
|
-
a = []
|
|
98
|
-
b = a
|
|
99
|
-
b << 1
|
|
100
|
-
a.should == [1]
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
it "If rhs has multiple arguments, lhs becomes an Array of them" do
|
|
104
|
-
a = 1, 2, 3
|
|
105
|
-
a.should == [1, 2, 3]
|
|
106
|
-
|
|
107
|
-
a = 1, (), 3
|
|
108
|
-
a.should == [1, nil, 3]
|
|
109
|
-
end
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
describe "Multiple assignment without grouping or splatting" do
|
|
113
|
-
it "an equal number of arguments on lhs and rhs assigns positionally" do
|
|
114
|
-
a, b, c, d = 1, 2, 3, 4
|
|
115
|
-
a.should == 1
|
|
116
|
-
b.should == 2
|
|
117
|
-
c.should == 3
|
|
118
|
-
d.should == 4
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
it "If rhs has too few arguments, the missing ones on lhs are assigned nil" do
|
|
122
|
-
a, b, c = 1, 2
|
|
123
|
-
a.should == 1
|
|
124
|
-
b.should == 2
|
|
125
|
-
c.should == nil
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
it "If rhs has too many arguments, the extra ones are silently not assigned anywhere" do
|
|
129
|
-
a, b = 1, 2, 3
|
|
130
|
-
a.should == 1
|
|
131
|
-
b.should == 2
|
|
132
|
-
end
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
describe "Multiple assignments with splats" do
|
|
136
|
-
it "* on the lhs collects all parameters from its position onwards as an Array or an empty array" do
|
|
137
|
-
a, *b = 1, 2
|
|
138
|
-
c, *d = 1
|
|
139
|
-
e, *f = 1, 2, 3
|
|
140
|
-
g, *h = 1, [2, 3]
|
|
141
|
-
# i
|
|
142
|
-
# j
|
|
143
|
-
# k
|
|
144
|
-
|
|
145
|
-
a.should == 1
|
|
146
|
-
b.should == [2]
|
|
147
|
-
c.should == 1
|
|
148
|
-
d.should == []
|
|
149
|
-
e.should == 1
|
|
150
|
-
f.should == [2, 3]
|
|
151
|
-
g.should == 1
|
|
152
|
-
h.should == [[2, 3]]
|
|
153
|
-
end
|
|
154
|
-
end
|
|
155
|
-
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
describe "The while expression" do
|
|
3
|
-
it "runs while the expression is true" do
|
|
4
|
-
i = 0
|
|
5
|
-
while i < 3
|
|
6
|
-
i = i + 1
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
i.should == 3
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
it "optionally takes a 'do' after the expression" do
|
|
13
|
-
i = 0
|
|
14
|
-
while i < 3 do
|
|
15
|
-
i = i + 1
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
i.should == 3
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
it "allows body begin on the same line if do is used" do
|
|
22
|
-
i = 0
|
|
23
|
-
while i < 3 do i = i + 1
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
i.should == 3
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
it "executes code in containing variable scope" do
|
|
30
|
-
i = 0
|
|
31
|
-
while i != 1
|
|
32
|
-
a = 123
|
|
33
|
-
i = 1
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
a.should == 123
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
it "executes code in containing variable scope with 'do'" do
|
|
40
|
-
i = 0
|
|
41
|
-
while i != 1 do
|
|
42
|
-
a = 123
|
|
43
|
-
i = 1
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
a.should == 123
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
it "returns nil if ended when condition became false" do
|
|
50
|
-
i = 0
|
|
51
|
-
while i < 3
|
|
52
|
-
i = i + 1
|
|
53
|
-
end.should == nil
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
it "does not evaluate the body if expression is empty" do
|
|
57
|
-
a = []
|
|
58
|
-
while ()
|
|
59
|
-
a << :body_evaluated
|
|
60
|
-
end
|
|
61
|
-
a.should == []
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
it "stops running body if interrupted by break" do
|
|
65
|
-
i = 0
|
|
66
|
-
while i < 10
|
|
67
|
-
i = i + 1
|
|
68
|
-
break if i > 5
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
i.should == 6
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
it "returns value passed to break if interrupted by break" do
|
|
75
|
-
while true
|
|
76
|
-
break 123
|
|
77
|
-
end.should == 123
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
it "returns nil if interrupted by break with no arguments" do
|
|
81
|
-
while true
|
|
82
|
-
break
|
|
83
|
-
end.should == nil
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
it "skips to end of body with next" do
|
|
87
|
-
a = []
|
|
88
|
-
i = 0
|
|
89
|
-
while (i = i + 1) < 5
|
|
90
|
-
next if i == 3
|
|
91
|
-
a << i
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
a.should == [1, 2, 4]
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
it "restarts the current iteration without reevaluating condition with redo" do
|
|
98
|
-
a = []
|
|
99
|
-
i = 0
|
|
100
|
-
j = 0
|
|
101
|
-
while (i = i + 1) < 3
|
|
102
|
-
a << i
|
|
103
|
-
j = j + 1
|
|
104
|
-
# redo if j < 3
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
a.should == [1, 1, 1, 2]
|
|
108
|
-
end
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
describe "The while modifier" do
|
|
112
|
-
it "runs preceding statement while the condition is true" do
|
|
113
|
-
i = 0
|
|
114
|
-
i = i + 1 while i < 3
|
|
115
|
-
i.should == 3
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
it "evaluates condition before statement execution" do
|
|
119
|
-
a = []
|
|
120
|
-
i = 0
|
|
121
|
-
a << i while (i = i + 1) < 3
|
|
122
|
-
a.should == [1, 2]
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
it "does not run preceding statement if the condition is false" do
|
|
126
|
-
i = 0
|
|
127
|
-
i = i + 1 while false
|
|
128
|
-
i.should == 0
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
it "does not run preceding statement if the condition is empty" do
|
|
132
|
-
i = 0
|
|
133
|
-
i = i + 1 while ()
|
|
134
|
-
i.should == 0
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
it "returns nil if ended when condition became false" do
|
|
138
|
-
i = 0
|
|
139
|
-
(i = i + 1 while i < 10).should == nil
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
it "returns value passed to break if interrupetd by break" do
|
|
143
|
-
(break 123 while true).should == 123
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
it "returns nil if interrupted by break with no arguments" do
|
|
147
|
-
(break while true).should == nil
|
|
148
|
-
end
|
|
149
|
-
|
|
150
|
-
it "skips to end of body with next" do
|
|
151
|
-
i = 0
|
|
152
|
-
j = 0
|
|
153
|
-
(( i = i + 1) == 3 ? next : j = j + i) while i <= 10
|
|
154
|
-
j.should == 63
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
it "restarts the current iteration without reevaluating condition with redo" do
|
|
158
|
-
i = 0
|
|
159
|
-
j = 0
|
|
160
|
-
# (i = i + 1) == 4 ? redo : j = j + i while (i = i + 1) <= 10
|
|
161
|
-
j.should == 34
|
|
162
|
-
end
|
|
163
|
-
end
|
data/gems/core_fs/README.md
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
Opals' Ruby Filesystem
|
|
2
|
-
======================
|
|
3
|
-
|
|
4
|
-
This gem provides the additional methods for File and Dir to support
|
|
5
|
-
full reading and writing. Core only contains the most basic methods
|
|
6
|
-
from File and Dir because Opal in the browser has no means of actually
|
|
7
|
-
reading or writing to disk. This gem is only meant to be used by the
|
|
8
|
-
gem context, which runs ontop of therubyracer. This gem will
|
|
9
|
-
automatically be loaded by the Context class, so it will be immediately
|
|
10
|
-
available for use.
|
|
11
|
-
|
|
12
|
-
Implementation
|
|
13
|
-
--------------
|
|
14
|
-
|
|
15
|
-
The Context class in the Opal build tools exposes/fixes the `.fs` property
|
|
16
|
-
on the `opal` object in the javascript context to expose a lot of the
|
|
17
|
-
native functionality directly. This is backed by the `FileSystem` class
|
|
18
|
-
in the Opal build tools.
|
|
19
|
-
|
data/gems/dev/Rakefile
DELETED
data/gems/dev/lib/dev.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
console.log("in opal dev, boom!");
|
|
2
|
-
|
|
3
|
-
/*
|
|
4
|
-
* Browser dev wraps all the dev tools, for compiling etc, but adds some functionality
|
|
5
|
-
* in-browser. It will automatically pick out text/ruby script tags and execute their
|
|
6
|
-
* content. opal.js does not do this as the compiler is required. opal_dev.js should
|
|
7
|
-
* only be used in development mode, so overhead in checking/compiling ruby code
|
|
8
|
-
* in the browser will not affect production level environments.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
var dev_tools = require('opal_dev/parser');
|
|
12
|
-
|
|
13
|
-
for (var prop in dev_tools) {
|
|
14
|
-
exports[prop] = dev_tools[prop];
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
Exposes an on screen repl session.
|
|
19
|
-
*/
|
|
20
|
-
exports.browser_repl = function() {
|
|
21
|
-
browser_register_ready_listener(function() {
|
|
22
|
-
// wrapping div
|
|
23
|
-
var repl_element = document.createElement('div');
|
|
24
|
-
|
|
25
|
-
// text input
|
|
26
|
-
var input = document.createElement('input');
|
|
27
|
-
input.type = 'text';
|
|
28
|
-
repl_element.appendChild(input);
|
|
29
|
-
|
|
30
|
-
document.body.appendChild(repl_element);
|
|
31
|
-
|
|
32
|
-
input.onkeydown = function() {
|
|
33
|
-
console.log("key down..");
|
|
34
|
-
};
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
/*
|
|
39
|
-
* Document ready listener can take callbacks that are fired when the document
|
|
40
|
-
* and/or window are ready to run. If already loaded then the callback is just
|
|
41
|
-
* called immediately.
|
|
42
|
-
*/
|
|
43
|
-
var browser_register_ready_listener = function(callback) {
|
|
44
|
-
if (browser_is_ready) return callback();
|
|
45
|
-
|
|
46
|
-
(function() {
|
|
47
|
-
// w3c - chrome, safari, ff
|
|
48
|
-
if (document.addEventListener) {
|
|
49
|
-
document.addEventListener('DOMContentLoaded', callback, false);
|
|
50
|
-
}
|
|
51
|
-
// IE
|
|
52
|
-
else {
|
|
53
|
-
(function() {
|
|
54
|
-
try {
|
|
55
|
-
document.documentElement.doScroll('left');
|
|
56
|
-
} catch (e) {
|
|
57
|
-
setTimeout(arguments.callee, 0);
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
callback();
|
|
61
|
-
})();
|
|
62
|
-
}
|
|
63
|
-
})();
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
/*
|
|
67
|
-
* Document is not ready yet...
|
|
68
|
-
*/
|
|
69
|
-
var browser_is_ready = false;
|
|
70
|
-
|
|
71
|
-
/*
|
|
72
|
-
* Find all script tags and run them.
|
|
73
|
-
*/
|
|
74
|
-
browser_register_ready_listener(function() {
|
|
75
|
-
browser_is_ready = true;
|
|
76
|
-
|
|
77
|
-
var tags = document.getElementsByTagName('script'), tag;
|
|
78
|
-
|
|
79
|
-
for (var i = 0; i < tags.length; i++) {
|
|
80
|
-
tag = tags[i];
|
|
81
|
-
|
|
82
|
-
if (tag.type == 'text/ruby') {
|
|
83
|
-
// src property - load by ajax, then run
|
|
84
|
-
if (tag.src) {
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
// no src, so just run inner contents
|
|
88
|
-
else {
|
|
89
|
-
console.log('need to run content:');
|
|
90
|
-
console.log(tag.innerHTML);
|
|
91
|
-
var result = Opal.compile(tag.innerHTML);
|
|
92
|
-
console.log(result);
|
|
93
|
-
eval(result);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
|