opal 0.4.3 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +3 -0
- data/.travis.yml +0 -4
- data/README.md +6 -0
- data/Rakefile +30 -6
- data/bin/opal +6 -82
- data/corelib/{opal/array.rb → array.rb} +40 -56
- data/corelib/{opal/basic_object.rb → basic_object.rb} +2 -2
- data/corelib/{opal/boolean.rb → boolean.rb} +0 -8
- data/corelib/class.rb +47 -0
- data/corelib/{opal/comparable.rb → comparable.rb} +0 -0
- data/corelib/{opal/enumerable.rb → enumerable.rb} +208 -141
- data/corelib/{opal/enumerator.rb → enumerator.rb} +3 -3
- data/corelib/{opal/error.rb → error.rb} +1 -0
- data/corelib/{opal/hash.rb → hash.rb} +67 -56
- data/corelib/io.rb +39 -0
- data/corelib/{opal/kernel.rb → kernel.rb} +35 -31
- data/corelib/{opal/class.rb → module.rb} +29 -57
- data/corelib/native.rb +148 -0
- data/corelib/{opal/nil_class.rb → nil_class.rb} +2 -10
- data/corelib/{opal/numeric.rb → numeric.rb} +39 -14
- data/corelib/opal.rb +42 -25
- data/corelib/{opal/proc.rb → proc.rb} +3 -3
- data/corelib/{opal/range.rb → range.rb} +5 -1
- data/corelib/{opal/regexp.rb → regexp.rb} +0 -0
- data/corelib/{opal/runtime.js → runtime.js} +96 -188
- data/corelib/{opal/string.rb → string.rb} +20 -15
- data/corelib/struct.rb +139 -0
- data/corelib/{opal/time.rb → time.rb} +0 -0
- data/lib/opal.rb +4 -0
- data/lib/opal/cli.rb +79 -32
- data/lib/opal/cli_options.rb +91 -0
- data/lib/opal/erb.rb +41 -8
- data/lib/opal/grammar.rb +24 -10
- data/lib/opal/grammar.y +15 -4
- data/lib/opal/grammar_helpers.rb +4 -0
- data/lib/opal/lexer.rb +214 -143
- data/lib/opal/parser.rb +596 -562
- data/lib/opal/require_parser.rb +1 -1
- data/lib/opal/source_map.rb +15 -30
- data/lib/opal/target_scope.rb +24 -5
- data/lib/opal/version.rb +1 -1
- data/mri_spec/cli_spec.rb +18 -0
- data/mri_spec/fixtures/opal_file.rb +2 -0
- data/mri_spec/spec_helper.rb +17 -0
- data/opal.gemspec +5 -2
- data/spec/{rubyspec/filters → filters}/bugs/alias.rb +0 -0
- data/spec/{rubyspec/filters → filters}/bugs/ancestors.rb +0 -0
- data/spec/{rubyspec/filters → filters}/bugs/array.rb +0 -0
- data/spec/filters/bugs/array/combination.rb +11 -0
- data/spec/filters/bugs/array/count.rb +3 -0
- data/spec/filters/bugs/array/delete_if.rb +3 -0
- data/spec/filters/bugs/array/drop.rb +3 -0
- data/spec/filters/bugs/array/drop_while.rb +5 -0
- data/spec/filters/bugs/array/eql.rb +3 -0
- data/spec/filters/bugs/array/flatten.rb +9 -0
- data/spec/filters/bugs/array/minus.rb +5 -0
- data/spec/filters/bugs/array/multipliy.rb +9 -0
- data/spec/filters/bugs/array/new.rb +3 -0
- data/spec/filters/bugs/array/pop.rb +6 -0
- data/spec/filters/bugs/array/rassoc.rb +4 -0
- data/spec/filters/bugs/array/rindex.rb +6 -0
- data/spec/filters/bugs/array/select.rb +3 -0
- data/spec/filters/bugs/array/shift.rb +7 -0
- data/spec/filters/bugs/array/shuffle.rb +11 -0
- data/spec/filters/bugs/array/slice.rb +7 -0
- data/spec/filters/bugs/array/take.rb +3 -0
- data/spec/filters/bugs/array/to_a.rb +3 -0
- data/spec/filters/bugs/array/try_convert.rb +7 -0
- data/spec/filters/bugs/array/uniq.rb +10 -0
- data/spec/filters/bugs/array/zip.rb +4 -0
- data/spec/{rubyspec/filters → filters}/bugs/array_delete.rb +1 -0
- data/spec/{rubyspec/filters → filters}/bugs/array_fetch.rb +0 -0
- data/spec/{rubyspec/filters → filters}/bugs/array_first.rb +0 -0
- data/spec/{rubyspec/filters → filters}/bugs/array_flatten.rb +0 -0
- data/spec/{rubyspec/filters → filters}/bugs/array_intersection.rb +0 -0
- data/spec/{rubyspec/filters → filters}/bugs/array_join.rb +0 -0
- data/spec/{rubyspec/filters → filters}/bugs/break.rb +0 -0
- data/spec/filters/bugs/case.rb +4 -0
- data/spec/{rubyspec/filters → filters}/bugs/coerce_integer.rb +0 -0
- data/spec/filters/bugs/enumerable_sort_by.rb +3 -0
- data/spec/{rubyspec/filters → filters}/bugs/kernel/instance_variables.rb +0 -0
- data/spec/filters/bugs/kernel/rand.rb +4 -0
- data/spec/filters/bugs/language/array.rb +3 -0
- data/spec/filters/bugs/language/block.rb +6 -0
- data/spec/filters/bugs/language/break.rb +3 -0
- data/spec/{rubyspec/filters → filters}/bugs/language/class.rb +3 -0
- data/spec/{rubyspec/filters → filters}/bugs/language/class_variables.rb +0 -0
- data/spec/filters/bugs/language/def.rb +27 -0
- data/spec/filters/bugs/language/defined.rb +3 -0
- data/spec/filters/bugs/language/ensure.rb +4 -0
- data/spec/filters/bugs/language/execution.rb +4 -0
- data/spec/filters/bugs/language/for.rb +18 -0
- data/spec/filters/bugs/language/if.rb +13 -0
- data/spec/filters/bugs/language/loop.rb +4 -0
- data/spec/filters/bugs/language/metaclass.rb +14 -0
- data/spec/filters/bugs/language/module.rb +6 -0
- data/spec/filters/bugs/language/next.rb +3 -0
- data/spec/filters/bugs/language/or.rb +3 -0
- data/spec/filters/bugs/language/order.rb +4 -0
- data/spec/filters/bugs/language/precedence.rb +10 -0
- data/spec/filters/bugs/language/proc.rb +24 -0
- data/spec/filters/bugs/language/redo.rb +5 -0
- data/spec/filters/bugs/language/rescue.rb +9 -0
- data/spec/filters/bugs/language/retry.rb +5 -0
- data/spec/filters/bugs/language/send.rb +10 -0
- data/spec/filters/bugs/language/super.rb +9 -0
- data/spec/filters/bugs/language/until.rb +8 -0
- data/spec/filters/bugs/language/variables.rb +37 -0
- data/spec/filters/bugs/language/while.rb +6 -0
- data/spec/filters/bugs/language/yield.rb +5 -0
- data/spec/{rubyspec/filters → filters}/bugs/module/class_variables.rb +0 -0
- data/spec/filters/bugs/module/method_defined.rb +6 -0
- data/spec/filters/bugs/parser.rb +10 -0
- data/spec/{rubyspec/filters → filters}/bugs/public_methods.rb +1 -0
- data/spec/filters/bugs/return.rb +7 -0
- data/spec/filters/bugs/singleton/instance.rb +4 -0
- data/spec/filters/bugs/source_map.rb +3 -0
- data/spec/filters/bugs/string/center.rb +4 -0
- data/spec/filters/bugs/string/lines.rb +3 -0
- data/spec/{rubyspec/filters → filters}/mspec/mocks.rb +0 -0
- data/spec/{rubyspec/filters → filters}/mspec/ruby_exe.rb +0 -0
- data/spec/{rubyspec/filters → filters}/mspec/should_receive.rb +0 -0
- data/spec/{rubyspec/filters → filters}/parser/block_args.rb +0 -0
- data/spec/{rubyspec/filters → filters}/unsupported/array_subclasses.rb +1 -0
- data/spec/filters/unsupported/frozen.rb +32 -0
- data/spec/filters/unsupported/immutable_strings.rb +3 -0
- data/spec/filters/unsupported/tainted.rb +17 -0
- data/spec/filters/unsupported/trusted.rb +15 -0
- data/spec/opal/class/constants_spec.rb +7 -0
- data/spec/opal/erb/erb_spec.rb +7 -1
- data/spec/opal/erb/inline_block.opalerb +3 -0
- data/spec/opal/hash/allocate_spec.rb +16 -0
- data/spec/opal/hash/new_spec.rb +10 -0
- data/spec/opal/hash/to_s_spec.rb +9 -0
- data/spec/opal/kernel/instance_variable_defined_spec.rb +15 -0
- data/spec/opal/kernel/rand_spec.rb +5 -5
- data/spec/opal/kernel/respond_to_spec.rb +14 -1
- data/spec/opal/language/block_spec.rb +13 -0
- data/spec/opal/language/rescue_spec.rb +27 -0
- data/spec/opal/language/return_spec.rb +38 -0
- data/spec/opal/language/singleton_class_spec.rb +13 -0
- data/spec/opal/language/super_spec.rb +99 -0
- data/spec/opal/language/variables_spec.rb +20 -0
- data/spec/opal/module/attr_accessor_spec.rb +8 -0
- data/spec/opal/module/constants_spec.rb +2 -2
- data/spec/opal/native/alias_native_spec.rb +18 -0
- data/spec/opal/native/each_spec.rb +14 -0
- data/spec/opal/native/element_reference_spec.rb +14 -0
- data/spec/opal/native/method_missing_spec.rb +39 -0
- data/spec/opal/native/new_spec.rb +19 -0
- data/spec/opal/native/nil_spec.rb +14 -0
- data/spec/opal/runtime2/class_hierarchy_spec.rb +2 -2
- data/spec/opal/source_map_spec.rb +3 -7
- data/spec/ospec/main.rb.erb +2 -5
- data/spec/parser/alias_spec.rb +4 -4
- data/spec/parser/and_spec.rb +2 -2
- data/spec/parser/array_spec.rb +6 -6
- data/spec/parser/attrasgn_spec.rb +8 -8
- data/spec/parser/begin_spec.rb +11 -11
- data/spec/parser/block_spec.rb +3 -3
- data/spec/parser/break_spec.rb +4 -4
- data/spec/parser/call_spec.rb +50 -48
- data/spec/parser/class_spec.rb +2 -2
- data/spec/parser/const_spec.rb +1 -1
- data/spec/parser/cvar_spec.rb +1 -1
- data/spec/parser/def_spec.rb +5 -5
- data/spec/parser/gvar_spec.rb +2 -2
- data/spec/parser/hash_spec.rb +4 -4
- data/spec/parser/iasgn_spec.rb +3 -3
- data/spec/parser/if_spec.rb +6 -6
- data/spec/parser/iter_spec.rb +6 -6
- data/spec/parser/lambda_spec.rb +5 -5
- data/spec/parser/lasgn_spec.rb +2 -2
- data/spec/parser/line_spec.rb +2 -2
- data/spec/parser/lvar_spec.rb +5 -5
- data/spec/parser/masgn_spec.rb +1 -1
- data/spec/parser/module_spec.rb +2 -2
- data/spec/parser/not_spec.rb +4 -4
- data/spec/parser/op_asgn1_spec.rb +2 -2
- data/spec/parser/op_asgn2_spec.rb +2 -2
- data/spec/parser/or_spec.rb +2 -2
- data/spec/parser/parse_spec.rb +66 -0
- data/spec/parser/parser_spec.rb +32 -38
- data/spec/parser/regexp_spec.rb +4 -4
- data/spec/parser/return_spec.rb +4 -4
- data/spec/parser/sclass_spec.rb +4 -4
- data/spec/parser/str_spec.rb +3 -3
- data/spec/parser/super_spec.rb +6 -6
- data/spec/parser/undef_spec.rb +3 -3
- data/spec/parser/unless_spec.rb +4 -4
- data/spec/parser/while_spec.rb +3 -3
- data/spec/parser/xstr_spec.rb +3 -3
- data/spec/parser/yield_spec.rb +6 -6
- data/spec/rubyspec/core/array/drop_spec.rb +1 -1
- data/spec/rubyspec/core/array/keep_if_spec.rb +1 -3
- data/spec/rubyspec/core/array/length_spec.rb +1 -3
- data/spec/rubyspec/core/array/map_spec.rb +2 -6
- data/spec/rubyspec/core/array/minus_spec.rb +3 -3
- data/spec/rubyspec/core/array/multiply_spec.rb +14 -16
- data/spec/rubyspec/core/array/new_spec.rb +3 -5
- data/spec/rubyspec/core/array/plus_spec.rb +2 -2
- data/spec/rubyspec/core/array/pop_spec.rb +4 -4
- data/spec/rubyspec/core/array/rassoc_spec.rb +2 -2
- data/spec/rubyspec/core/array/reject_spec.rb +2 -6
- data/spec/rubyspec/core/array/replace_spec.rb +1 -3
- data/spec/rubyspec/core/array/reverse_each_spec.rb +1 -3
- data/spec/rubyspec/core/array/reverse_spec.rb +4 -4
- data/spec/rubyspec/core/array/rindex_spec.rb +1 -1
- data/spec/rubyspec/core/array/select_spec.rb +3 -7
- data/spec/rubyspec/core/array/shared/collect.rb +7 -0
- data/spec/rubyspec/core/array/shared/index.rb +1 -1
- data/spec/rubyspec/core/array/shared/keep_if.rb +3 -0
- data/spec/rubyspec/core/array/shared/length.rb +3 -0
- data/spec/rubyspec/core/array/shared/replace.rb +3 -0
- data/spec/rubyspec/core/array/shared/slice.rb +3 -0
- data/spec/rubyspec/core/array/shuffle_spec.rb +1 -1
- data/spec/rubyspec/core/array/size_spec.rb +1 -3
- data/spec/rubyspec/core/array/slice_spec.rb +4 -6
- data/spec/rubyspec/core/array/sort_spec.rb +2 -2
- data/spec/rubyspec/core/array/to_a_spec.rb +1 -1
- data/spec/rubyspec/core/array/try_convert_spec.rb +7 -7
- data/spec/rubyspec/core/array/uniq_spec.rb +7 -7
- data/spec/rubyspec/core/array/zip_spec.rb +1 -1
- data/spec/rubyspec/core/enumerable/collect_spec.rb +24 -0
- data/spec/rubyspec/core/enumerable/count_spec.rb +35 -19
- data/spec/rubyspec/core/enumerable/find_spec.rb +5 -0
- data/spec/rubyspec/core/hash/each_pair_spec.rb +7 -7
- data/spec/rubyspec/core/hash/each_spec.rb +13 -7
- data/spec/rubyspec/core/module/method_defined_spec.rb +4 -4
- data/spec/rubyspec/core/module/public_method_defined_spec.rb +19 -0
- data/spec/rubyspec/core/module/remove_const_spec.rb +23 -0
- data/spec/rubyspec/core/numeric/step_spec.rb +14 -0
- data/spec/rubyspec/core/string/center_spec.rb +43 -65
- data/spec/rubyspec/core/string/lines_spec.rb +1 -1
- data/spec/rubyspec/core/string/ljust_spec.rb +25 -9
- data/spec/rubyspec/core/string/rjust_spec.rb +26 -10
- data/spec/rubyspec/core/struct/fixtures/classes.rb +26 -0
- data/spec/rubyspec/core/struct/initialize_spec.rb +11 -0
- data/spec/rubyspec/core/struct/new_spec.rb +24 -0
- data/spec/rubyspec/fixtures/constants.rb +7 -0
- data/spec/rubyspec/language/break_spec.rb +1 -1
- data/spec/rubyspec/language/case_spec.rb +30 -30
- data/spec/rubyspec/language/def_spec.rb +34 -34
- data/spec/rubyspec/language/defined_spec.rb +2 -2
- data/spec/rubyspec/language/ensure_spec.rb +2 -2
- data/spec/rubyspec/language/execution_spec.rb +2 -2
- data/spec/rubyspec/language/for_spec.rb +17 -17
- data/spec/rubyspec/language/hash_spec.rb +3 -3
- data/spec/rubyspec/language/if_spec.rb +11 -11
- data/spec/rubyspec/language/loop_spec.rb +3 -3
- data/spec/rubyspec/language/metaclass_spec.rb +14 -14
- data/spec/rubyspec/language/module_spec.rb +6 -6
- data/spec/rubyspec/language/next_spec.rb +5 -5
- data/spec/rubyspec/language/not_spec.rb +1 -1
- data/spec/rubyspec/language/or_spec.rb +1 -1
- data/spec/rubyspec/language/order_spec.rb +3 -5
- data/spec/rubyspec/language/precedence_spec.rb +19 -19
- data/spec/rubyspec/language/proc_spec.rb +29 -29
- data/spec/rubyspec/language/redo_spec.rb +3 -5
- data/spec/rubyspec/language/rescue_spec.rb +7 -7
- data/spec/rubyspec/language/retry_spec.rb +2 -2
- data/spec/rubyspec/language/return_spec.rb +12 -12
- data/spec/rubyspec/language/send_spec.rb +9 -9
- data/spec/rubyspec/language/singleton_class_spec.rb +3 -4
- data/spec/rubyspec/language/super_spec.rb +7 -11
- data/spec/rubyspec/language/until_spec.rb +10 -10
- data/spec/rubyspec/language/variables_spec.rb +59 -67
- data/spec/rubyspec/language/versions/array_1.9.rb +1 -1
- data/spec/rubyspec/language/versions/block_1.9.rb +0 -0
- data/spec/rubyspec/language/versions/break_1.9.rb +0 -0
- data/spec/rubyspec/language/versions/literal_lambda_1.9.rb +12 -12
- data/spec/rubyspec/language/versions/send_1.9.rb +23 -23
- data/spec/rubyspec/language/versions/symbol_1.9.rb +2 -2
- data/spec/rubyspec/language/versions/variables_1.9.rb +1 -1
- data/spec/rubyspec/language/while_spec.rb +4 -4
- data/spec/rubyspec/language/yield_spec.rb +3 -3
- data/spec/rubyspec/library/erb/util/html_escape_spec.rb +10 -0
- data/spec/rubyspec/library/singleton/clone_spec.rb +8 -0
- data/spec/rubyspec/library/singleton/dup_spec.rb +8 -0
- data/spec/rubyspec/library/singleton/fixtures/classes.rb +18 -0
- data/spec/rubyspec/library/singleton/instance_spec.rb +30 -0
- data/spec/spec_helper.rb +214 -0
- data/stdlib/buffer.rb +40 -0
- data/stdlib/buffer/array.rb +66 -0
- data/stdlib/buffer/view.rb +70 -0
- data/stdlib/erb.rb +11 -20
- data/stdlib/forwardable.rb +71 -0
- data/stdlib/json.rb +78 -0
- data/stdlib/ostruct.rb +69 -0
- data/stdlib/rbconfig.rb +1 -0
- data/stdlib/singleton.rb +40 -0
- data/stdlib/stringio.rb +173 -0
- data/stdlib/template.rb +44 -0
- metadata +285 -79
- data/corelib/opal/native.rb +0 -31
- data/spec/opal/class/bridge_class_spec.rb +0 -39
- data/spec/opal/native_spec.rb +0 -209
- data/spec/ospec/runner.rb +0 -223
- data/spec/rubyspec/filters/bugs/block_args.rb +0 -3
- data/spec/rubyspec/filters/bugs/case.rb +0 -8
- data/spec/rubyspec/filters/bugs/language/module.rb +0 -3
- data/spec/rubyspec/filters/unsupported/frozen.rb +0 -4
- data/spec/rubyspec/filters/unsupported/tainted.rb +0 -7
data/lib/opal/require_parser.rb
CHANGED
data/lib/opal/source_map.rb
CHANGED
@@ -3,45 +3,31 @@ require 'source_map'
|
|
3
3
|
|
4
4
|
module Opal
|
5
5
|
class SourceMap
|
6
|
-
|
7
|
-
|
6
|
+
attr_reader :fragments
|
7
|
+
attr_reader :file
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
def initialize generated, file
|
12
|
-
@generated = generated
|
9
|
+
def initialize(fragments, file)
|
10
|
+
@fragments = fragments
|
13
11
|
@file = file
|
14
12
|
end
|
15
13
|
|
16
14
|
def map
|
17
15
|
@map ||= ::SourceMap.new.tap do |map|
|
18
|
-
|
19
|
-
generated.lines.each_with_index do |line, index|
|
20
|
-
generated_line = index+1
|
21
|
-
if line =~ FILE_REGEXP
|
22
|
-
source_file = "file://#{$1}"
|
23
|
-
map.add_mapping(
|
24
|
-
:generated_line => generated_line,
|
25
|
-
:generated_col => 0,
|
26
|
-
:source_line => 1,
|
27
|
-
:source_col => 0,
|
28
|
-
:source => source_file
|
29
|
-
)
|
30
|
-
end
|
16
|
+
line, column = 1, 0
|
31
17
|
|
32
|
-
|
33
|
-
|
34
|
-
pos += $~.size
|
35
|
-
source_line = $1.to_i + 1
|
36
|
-
source_col = 0 # until column info will be available
|
37
|
-
generated_col = pos
|
18
|
+
@fragments.each do |fragment|
|
19
|
+
if source_line = fragment.line
|
38
20
|
map.add_mapping(
|
39
|
-
:generated_line =>
|
40
|
-
:generated_col =>
|
21
|
+
:generated_line => line,
|
22
|
+
:generated_col => column,
|
41
23
|
:source_line => source_line,
|
42
|
-
:source_col =>
|
43
|
-
:source =>
|
24
|
+
:source_col => 0,
|
25
|
+
:source => file
|
44
26
|
)
|
27
|
+
|
28
|
+
new_lines = fragment.code.count "\n"
|
29
|
+
line += new_lines
|
30
|
+
column = 0
|
45
31
|
end
|
46
32
|
end
|
47
33
|
end
|
@@ -59,5 +45,4 @@ module Opal
|
|
59
45
|
"\n//@ sourceMappingURL=file://#{map_path}"
|
60
46
|
end
|
61
47
|
end
|
62
|
-
|
63
48
|
end
|
data/lib/opal/target_scope.rb
CHANGED
@@ -33,6 +33,9 @@ module Opal
|
|
33
33
|
|
34
34
|
# uses parents super method
|
35
35
|
attr_accessor :uses_super
|
36
|
+
attr_accessor :uses_zuper
|
37
|
+
|
38
|
+
attr_accessor :catch_return
|
36
39
|
|
37
40
|
# @param [Symbol] type the scope type (:class, :module, :iter, :def, :top)
|
38
41
|
# @param [Opal::Parser] parser a parser instance used to create this scope
|
@@ -88,6 +91,10 @@ module Opal
|
|
88
91
|
@type == :iter
|
89
92
|
end
|
90
93
|
|
94
|
+
def def?
|
95
|
+
@type == :def
|
96
|
+
end
|
97
|
+
|
91
98
|
# Is this a normal def method directly inside a class? This is
|
92
99
|
# used for optimizing ivars as we can set them to nil in the
|
93
100
|
# class body
|
@@ -133,19 +140,19 @@ module Opal
|
|
133
140
|
result = str
|
134
141
|
end
|
135
142
|
|
136
|
-
|
143
|
+
f(result)
|
137
144
|
end
|
138
145
|
|
139
|
-
def
|
140
|
-
@parser.
|
146
|
+
def f(code, sexp = nil)
|
147
|
+
@parser.f code
|
141
148
|
end
|
142
149
|
|
143
150
|
# Generates code for this module to donate methods
|
144
151
|
def to_donate_methods
|
145
152
|
if should_donate? and !@methods.empty?
|
146
|
-
|
153
|
+
f("%s;$opal.donate(#{@name}, [%s]);" % [@parser.parser_indent, @methods.map(&:inspect).join(', ')])
|
147
154
|
else
|
148
|
-
|
155
|
+
f("")
|
149
156
|
end
|
150
157
|
end
|
151
158
|
|
@@ -163,6 +170,7 @@ module Opal
|
|
163
170
|
|
164
171
|
def add_arg(arg)
|
165
172
|
@args << arg unless @args.include? arg
|
173
|
+
arg
|
166
174
|
end
|
167
175
|
|
168
176
|
def add_local(local)
|
@@ -235,6 +243,17 @@ module Opal
|
|
235
243
|
@identity
|
236
244
|
end
|
237
245
|
|
246
|
+
def find_parent_def
|
247
|
+
scope = self
|
248
|
+
while scope = scope.parent
|
249
|
+
if scope.def?
|
250
|
+
return scope
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
nil
|
255
|
+
end
|
256
|
+
|
238
257
|
def get_super_chain
|
239
258
|
chain, scope, defn, mid = [], self, 'null', 'null'
|
240
259
|
|
data/lib/opal/version.rb
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.expand_path('../spec_helper', __FILE__)
|
2
|
+
require 'opal/cli'
|
3
|
+
require 'stringio'
|
4
|
+
|
5
|
+
describe Opal::CLI do
|
6
|
+
let(:output) { StringIO.new }
|
7
|
+
|
8
|
+
context 'with a file' do
|
9
|
+
let(:file) { File.expand_path('../fixtures/opal_file.rb', __FILE__) }
|
10
|
+
subject(:cli) { described_class.new(file, :output => output) }
|
11
|
+
|
12
|
+
it 'runs the file' do
|
13
|
+
cli.run
|
14
|
+
output.rewind
|
15
|
+
expect(output.read).to eq("hi from opal!\n")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
4
|
+
# loaded once.
|
5
|
+
#
|
6
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
7
|
+
RSpec.configure do |config|
|
8
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
9
|
+
config.run_all_when_everything_filtered = true
|
10
|
+
config.filter_run :focus
|
11
|
+
|
12
|
+
# Run specs in random order to surface order dependencies. If you find an
|
13
|
+
# order dependency and want to debug it, you can fix the order by providing
|
14
|
+
# the seed, which is printed after each run.
|
15
|
+
# --seed 1234
|
16
|
+
config.order = 'random'
|
17
|
+
end
|
data/opal.gemspec
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'opal/version'
|
3
5
|
|
4
6
|
Gem::Specification.new do |s|
|
5
7
|
s.name = 'opal'
|
@@ -22,4 +24,5 @@ Gem::Specification.new do |s|
|
|
22
24
|
s.add_development_dependency 'rake'
|
23
25
|
s.add_development_dependency 'racc'
|
24
26
|
s.add_development_dependency 'opal-sprockets', '~> 0.1.1'
|
27
|
+
s.add_development_dependency 'rspec', '~> 2.14'
|
25
28
|
end
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,11 @@
|
|
1
|
+
opal_filter "Array#combination" do
|
2
|
+
fails "Array#combination generates from a defensive copy, ignoring mutations"
|
3
|
+
fails "Array#combination yields a partition consisting of only singletons"
|
4
|
+
fails "Array#combination yields [] when length is 0"
|
5
|
+
fails "Array#combination yields a copy of self if the argument is the size of the receiver"
|
6
|
+
fails "Array#combination yields nothing if the argument is out of bounds"
|
7
|
+
fails "Array#combination yields the expected combinations"
|
8
|
+
fails "Array#combination yields nothing for out of bounds length and return self"
|
9
|
+
fails "Array#combination returns self when a block is given"
|
10
|
+
fails "Array#combination returns an enumerator when no block is provided"
|
11
|
+
end
|
@@ -0,0 +1,5 @@
|
|
1
|
+
opal_filter "Array#drop_while" do
|
2
|
+
fails "Array#drop_while removes elements from the start of the array until the block returns false"
|
3
|
+
fails "Array#drop_while removes elements from the start of the array until the block returns nil"
|
4
|
+
fails "Array#drop_while removes elements from the start of the array while the block evaluates to true"
|
5
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
opal_filter "Array#flatten" do
|
2
|
+
fails "Array#flatten raises a TypeError when the passed Object can't be converted to an Integer"
|
3
|
+
fails "Array#flatten tries to convert passed Objects to Integers using #to_int"
|
4
|
+
end
|
5
|
+
|
6
|
+
opal_filter "Array#flatten!" do
|
7
|
+
fails "Array#flatten! raises a TypeError when the passed Object can't be converted to an Integer"
|
8
|
+
fails "Array#flatten! tries to convert passed Objects to Integers using #to_int"
|
9
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
opal_filter "Array#*" do
|
2
|
+
fails "Array#* with an integer with a subclass of Array returns a subclass instance"
|
3
|
+
fails "Array#* with an integer raises an ArgumentError when passed a negative integer"
|
4
|
+
fails "Array#* raises a TypeError is the passed argument is nil"
|
5
|
+
fails "Array#* converts the passed argument to a String rather than an Integer"
|
6
|
+
fails "Array#* raises a TypeError if the argument can neither be converted to a string nor an integer"
|
7
|
+
fails "Array#* tires to convert the passed argument to an Integer using #to_int"
|
8
|
+
fails "Array#* tries to convert the passed argument to a String using #to_str"
|
9
|
+
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
opal_filter "Array#pop" do
|
2
|
+
fails "Array#pop passed a number n as an argument raises an ArgumentError if more arguments are passed"
|
3
|
+
fails "Array#pop passed a number n as an argument raises a TypeError when the passed n can be coerced to Integer"
|
4
|
+
fails "Array#pop passed a number n as an argument tries to convert n to an Integer using #to_int"
|
5
|
+
fails "Array#pop passed a number n as an argument raises an ArgumentError if n is negative"
|
6
|
+
end
|
@@ -0,0 +1,6 @@
|
|
1
|
+
opal_filter "Array#rindex" do
|
2
|
+
fails "Array#rindex given no argument and no block produces an Enumerator"
|
3
|
+
fails "Array#rindex rechecks the array size during iteration"
|
4
|
+
fails "Array#rindex ignore the block if there is an argument"
|
5
|
+
fails "Array#rindex returns the first index backwards from the end where element == to object"
|
6
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
opal_filter "Array#shift" do
|
2
|
+
fails "Array#shift passed a number n as an argument raises an ArgumentError if more arguments are passed"
|
3
|
+
fails "Array#shift passed a number n as an argument raises a TypeError when the passed n can be coerced to Integer"
|
4
|
+
fails "Array#shift passed a number n as an argument tries to convert n to an Integer using #to_int"
|
5
|
+
fails "Array#shift passed a number n as an argument raises an ArgumentError if n is negative"
|
6
|
+
fails "Array#shift passed a number n as an argument returns a new empty array if there are no more elements"
|
7
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
opal_filter "Array#shuffle" do
|
2
|
+
fails "Array#shuffle uses given random generator"
|
3
|
+
fails "Array#shuffle uses default random generator"
|
4
|
+
fails "Array#shuffle attempts coercion via #to_hash"
|
5
|
+
fails "Array#shuffle is not destructive"
|
6
|
+
fails "Array#shuffle returns the same values, in a usually different order"
|
7
|
+
end
|
8
|
+
|
9
|
+
opal_filter "Array#shuffle!" do
|
10
|
+
fails "Array#shuffle! returns the same values, in a usually different order"
|
11
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
opal_filter "Array#slice!" do
|
2
|
+
fails "Array#slice! does not expand array with negative indices out of bounds"
|
3
|
+
fails "Array#slice! does not expand array with indices out of bounds"
|
4
|
+
fails "Array#slice! calls to_int on range arguments"
|
5
|
+
fails "Array#slice! removes and return elements in range"
|
6
|
+
fails "Array#slice! calls to_int on start and length arguments"
|
7
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
opal_filter "Array.try_convert" do
|
2
|
+
fails "Array.try_convert does not rescue exceptions raised by #to_ary"
|
3
|
+
fails "Array.try_convert sends #to_ary to the argument and raises TypeError if it's not a kind of Array"
|
4
|
+
fails "Array.try_convert sends #to_ary to the argument and returns the result if it's a kind of Array"
|
5
|
+
fails "Array.try_convert sends #to_ary to the argument and returns the result if it's an Array"
|
6
|
+
fails "Array.try_convert sends #to_ary to the argument and returns the result if it's nil"
|
7
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
opal_filter "Array#uniq" do
|
2
|
+
fails "Array#uniq compares elements based on the value returned from the block"
|
3
|
+
fails "Array#uniq compares elements with matching hash codes with #eql?"
|
4
|
+
fails "Array#uniq uses eql? semantics"
|
5
|
+
end
|
6
|
+
|
7
|
+
opal_filter "Array#uniq!" do
|
8
|
+
fails "Array#uniq! compares elements based on the value returned from the block"
|
9
|
+
fails "Array#uniq! properly handles recursive arrays"
|
10
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|