opal 0.8.1 → 0.9.0.beta1
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.
- checksums.yaml +4 -4
- data/.gitignore +2 -2
- data/.gitmodules +3 -3
- data/.jshintrc +17 -20
- data/.travis.yml +22 -11
- data/CHANGELOG.md +51 -1
- data/CODE_OF_CONDUCT.md +15 -0
- data/CONTRIBUTING.md +125 -9
- data/Gemfile +1 -1
- data/Guardfile +2 -2
- data/README.md +95 -29
- data/Rakefile +1 -1
- data/benchmark/benchmarks +103 -0
- data/benchmark/bm_array_flatten.rb +9 -0
- data/benchmark/bm_array_intersection_numbers.rb +7 -0
- data/benchmark/bm_array_intersection_objects.rb +7 -0
- data/benchmark/bm_array_intersection_strings.rb +7 -0
- data/benchmark/bm_array_join_ary.rb +9 -0
- data/benchmark/bm_array_minus_numbers.rb +7 -0
- data/benchmark/bm_array_minus_objects.rb +7 -0
- data/benchmark/bm_array_minus_strings.rb +7 -0
- data/benchmark/bm_array_union_numbers.rb +7 -0
- data/benchmark/bm_array_union_objects.rb +7 -0
- data/benchmark/bm_array_union_strings.rb +7 -0
- data/benchmark/bm_array_uniq_bang_numbers.rb +5 -0
- data/benchmark/bm_array_uniq_bang_objects.rb +5 -0
- data/benchmark/bm_array_uniq_bang_strings.rb +5 -0
- data/benchmark/bm_array_uniq_numbers.rb +5 -0
- data/benchmark/bm_array_uniq_objects.rb +5 -0
- data/benchmark/bm_array_uniq_strings.rb +5 -0
- data/benchmark/bm_dispatch_bind_table.rb +57 -0
- data/benchmark/bm_dispatch_code_gen.rb +65 -0
- data/benchmark/bm_dispatch_code_gen_if.rb +64 -0
- data/benchmark/bm_dispatch_hardcoded.rb +44 -0
- data/benchmark/bm_dispatch_send.rb +38 -0
- data/benchmark/bm_dispatch_send_table.rb +57 -0
- data/benchmark/bm_hash_assoc_object.rb +11 -0
- data/benchmark/bm_hash_assoc_string.rb +9 -0
- data/benchmark/bm_hash_clone_object.rb +9 -0
- data/benchmark/bm_hash_clone_string.rb +9 -0
- data/benchmark/bm_hash_delete_object.rb +11 -0
- data/benchmark/bm_hash_delete_string.rb +9 -0
- data/benchmark/bm_hash_each_key_object.rb +9 -0
- data/benchmark/bm_hash_each_key_string.rb +9 -0
- data/benchmark/bm_hash_each_object.rb +9 -0
- data/benchmark/bm_hash_each_string.rb +9 -0
- data/benchmark/bm_hash_each_value_object.rb +9 -0
- data/benchmark/bm_hash_each_value_string.rb +9 -0
- data/benchmark/bm_hash_element_reference_object.rb +11 -0
- data/benchmark/bm_hash_element_reference_string.rb +9 -0
- data/benchmark/bm_hash_element_set_object.rb +5 -0
- data/benchmark/bm_hash_element_set_string.rb +5 -0
- data/benchmark/bm_hash_equal_value_object.rb +14 -0
- data/benchmark/bm_hash_equal_value_string.rb +11 -0
- data/benchmark/bm_hash_fetch_object.rb +11 -0
- data/benchmark/bm_hash_fetch_string.rb +9 -0
- data/benchmark/bm_hash_flatten_object.rb +9 -0
- data/benchmark/bm_hash_flatten_string.rb +9 -0
- data/benchmark/bm_hash_has_key_object.rb +11 -0
- data/benchmark/bm_hash_has_key_string.rb +9 -0
- data/benchmark/bm_hash_has_value_object.rb +9 -0
- data/benchmark/bm_hash_has_value_string.rb +9 -0
- data/benchmark/bm_hash_hash_object.rb +9 -0
- data/benchmark/bm_hash_hash_string.rb +9 -0
- data/benchmark/bm_hash_inspect_object.rb +9 -0
- data/benchmark/bm_hash_inspect_string.rb +9 -0
- data/benchmark/bm_hash_invert_object.rb +9 -0
- data/benchmark/bm_hash_invert_string.rb +9 -0
- data/benchmark/bm_hash_keep_if_object.rb +9 -0
- data/benchmark/bm_hash_keep_if_string.rb +9 -0
- data/benchmark/bm_hash_key_object.rb +9 -0
- data/benchmark/bm_hash_key_string.rb +9 -0
- data/benchmark/bm_hash_keys_object.rb +9 -0
- data/benchmark/bm_hash_keys_string.rb +9 -0
- data/benchmark/bm_hash_literal_mixed_large.rb +3 -0
- data/benchmark/bm_hash_literal_mixed_small.rb +3 -0
- data/benchmark/bm_hash_literal_object_large.rb +4 -0
- data/benchmark/bm_hash_literal_object_small.rb +3 -0
- data/benchmark/bm_hash_literal_string_large.rb +4 -0
- data/benchmark/bm_hash_literal_string_small.rb +3 -0
- data/benchmark/bm_hash_merge_object.rb +22 -0
- data/benchmark/bm_hash_merge_string.rb +18 -0
- data/benchmark/bm_hash_rassoc_object.rb +9 -0
- data/benchmark/bm_hash_rassoc_string.rb +9 -0
- data/benchmark/bm_hash_rehash_object.rb +9 -0
- data/benchmark/bm_hash_rehash_string.rb +9 -0
- data/benchmark/bm_hash_reject_bang_object.rb +9 -0
- data/benchmark/bm_hash_reject_bang_string.rb +9 -0
- data/benchmark/bm_hash_reject_object.rb +9 -0
- data/benchmark/bm_hash_reject_string.rb +9 -0
- data/benchmark/bm_hash_replace_object.rb +18 -0
- data/benchmark/bm_hash_replace_string.rb +14 -0
- data/benchmark/bm_hash_select_bang_object.rb +9 -0
- data/benchmark/bm_hash_select_bang_string.rb +9 -0
- data/benchmark/bm_hash_select_object.rb +9 -0
- data/benchmark/bm_hash_select_string.rb +9 -0
- data/benchmark/bm_hash_shift_object.rb +10 -0
- data/benchmark/bm_hash_shift_string.rb +10 -0
- data/benchmark/bm_hash_to_a_object.rb +9 -0
- data/benchmark/bm_hash_to_a_string.rb +9 -0
- data/benchmark/bm_hash_to_h_object.rb +10 -0
- data/benchmark/bm_hash_to_h_string.rb +10 -0
- data/benchmark/bm_hash_values_object.rb +9 -0
- data/benchmark/bm_hash_values_string.rb +9 -0
- data/benchmark/run.rb +48 -0
- data/bin/opal-mspec +1 -1
- data/bin/opal-repl +4 -4
- data/docs/compiled_ruby.md +214 -56
- data/docs/configuring_gems.md +2 -2
- data/docs/faq.md +2 -2
- data/docs/getting_started.md +19 -2
- data/docs/jquery.md +5 -5
- data/docs/opal_parser.md +53 -0
- data/docs/unsupported_features.md +2 -2
- data/docs/upgrading.md +22 -0
- data/docs/using_sprockets.md +15 -0
- data/examples/rack/config.ru +13 -0
- data/examples/sinatra/config.ru +4 -5
- data/lib/mspec/opal/runner.rb +54 -11
- data/lib/opal.rb +1 -1
- data/lib/opal/builder.rb +1 -1
- data/lib/opal/builder_processors.rb +1 -1
- data/lib/opal/cli.rb +17 -13
- data/lib/opal/cli_options.rb +1 -1
- data/lib/opal/compiler.rb +12 -0
- data/lib/opal/config.rb +4 -0
- data/lib/opal/nodes/arglist.rb +5 -7
- data/lib/opal/nodes/call.rb +6 -1
- data/lib/opal/nodes/call_special.rb +74 -0
- data/lib/opal/nodes/def.rb +35 -28
- data/lib/opal/nodes/definitions.rb +3 -5
- data/lib/opal/nodes/for.rb +13 -0
- data/lib/opal/nodes/helpers.rb +15 -1
- data/lib/opal/nodes/if.rb +5 -5
- data/lib/opal/nodes/iter.rb +6 -1
- data/lib/opal/nodes/literal.rb +1 -1
- data/lib/opal/nodes/logic.rb +2 -2
- data/lib/opal/nodes/masgn.rb +1 -2
- data/lib/opal/nodes/module.rb +2 -1
- data/lib/opal/nodes/rescue.rb +10 -1
- data/lib/opal/nodes/scope.rb +8 -2
- data/lib/opal/nodes/singleton_class.rb +1 -1
- data/lib/opal/nodes/top.rb +11 -0
- data/lib/opal/nodes/variables.rb +4 -4
- data/lib/opal/parser.rb +21 -3
- data/lib/opal/parser/grammar.rb +3115 -2961
- data/lib/opal/parser/grammar.y +29 -6
- data/lib/opal/parser/lexer.rb +18 -8
- data/lib/opal/sprockets.rb +85 -0
- data/lib/opal/sprockets/processor.rb +11 -35
- data/lib/opal/sprockets/server.rb +3 -15
- data/lib/opal/version.rb +2 -2
- data/opal.gemspec +4 -4
- data/opal/README.md +9 -0
- data/opal/corelib/array.rb +433 -181
- data/opal/corelib/basic_object.rb +48 -4
- data/opal/corelib/boolean.rb +15 -6
- data/opal/corelib/class.rb +6 -5
- data/opal/corelib/comparable.rb +12 -0
- data/opal/corelib/complex.rb +282 -0
- data/opal/corelib/constants.rb +9 -0
- data/opal/corelib/enumerable.rb +83 -34
- data/opal/corelib/enumerator.rb +3 -1
- data/opal/corelib/error.rb +49 -10
- data/opal/corelib/file.rb +1 -0
- data/opal/corelib/hash.rb +353 -577
- data/opal/corelib/helpers.rb +20 -0
- data/opal/corelib/kernel.rb +114 -59
- data/opal/corelib/math.rb +470 -0
- data/opal/corelib/method.rb +11 -2
- data/opal/corelib/module.rb +96 -96
- data/opal/corelib/{nil_class.rb → nil.rb} +20 -1
- data/opal/corelib/number.rb +751 -0
- data/opal/corelib/numeric.rb +77 -437
- data/opal/corelib/proc.rb +81 -1
- data/opal/corelib/process.rb +27 -0
- data/opal/corelib/rational.rb +358 -0
- data/opal/corelib/regexp.rb +156 -27
- data/opal/corelib/runtime.js +724 -335
- data/opal/corelib/string.rb +93 -104
- data/opal/corelib/string/encoding.rb +177 -0
- data/opal/corelib/string/inheritance.rb +2 -0
- data/opal/corelib/struct.rb +105 -18
- data/opal/corelib/time.rb +267 -146
- data/opal/corelib/unsupported.rb +216 -0
- data/opal/corelib/variables.rb +0 -6
- data/opal/opal.rb +8 -22
- data/opal/opal/base.rb +9 -0
- data/opal/opal/mini.rb +17 -0
- data/spec/README.md +1 -1
- data/spec/filters/bugs/array.rb +38 -136
- data/spec/filters/bugs/{basic_object.rb → basicobject.rb} +14 -15
- data/spec/filters/bugs/class.rb +6 -12
- data/spec/filters/bugs/complex.rb +3 -0
- data/spec/filters/bugs/date.rb +162 -10
- data/spec/filters/bugs/enumerable.rb +31 -58
- data/spec/filters/bugs/enumerator.rb +42 -0
- data/spec/filters/bugs/exception.rb +66 -10
- data/spec/filters/bugs/float.rb +17 -0
- data/spec/filters/bugs/hash.rb +11 -97
- data/spec/filters/bugs/inheritance.rb +5 -0
- data/spec/filters/bugs/integer.rb +28 -0
- data/spec/filters/bugs/kernel.rb +304 -12
- data/spec/filters/bugs/language.rb +133 -399
- data/spec/filters/bugs/language_opal.rb +88 -0
- data/spec/filters/bugs/module.rb +203 -62
- data/spec/filters/bugs/numeric.rb +32 -0
- data/spec/filters/bugs/proc.rb +39 -0
- data/spec/filters/bugs/range.rb +148 -0
- data/spec/filters/bugs/regexp.rb +168 -0
- data/spec/filters/bugs/set.rb +46 -3
- data/spec/filters/bugs/singleton.rb +1 -2
- data/spec/filters/bugs/string.rb +59 -90
- data/spec/filters/bugs/strscan.rb +80 -0
- data/spec/filters/bugs/struct.rb +10 -20
- data/spec/filters/bugs/time.rb +17 -184
- data/spec/filters/bugs/unboundmethod.rb +22 -0
- data/spec/filters/unsupported/array.rb +163 -0
- data/spec/filters/unsupported/basicobject.rb +14 -0
- data/spec/filters/unsupported/bignum.rb +46 -0
- data/spec/filters/unsupported/class.rb +4 -0
- data/spec/filters/unsupported/delegator.rb +5 -0
- data/spec/filters/unsupported/enumerable.rb +11 -0
- data/spec/filters/unsupported/enumerator.rb +8 -9
- data/spec/filters/unsupported/fixnum.rb +14 -0
- data/spec/filters/unsupported/float.rb +41 -7
- data/spec/filters/unsupported/freeze.rb +45 -0
- data/spec/filters/unsupported/hash.rb +50 -0
- data/spec/filters/unsupported/integer.rb +3 -0
- data/spec/filters/unsupported/kernel.rb +31 -0
- data/spec/filters/unsupported/language.rb +17 -0
- data/spec/filters/unsupported/matchdata.rb +30 -0
- data/spec/filters/unsupported/math.rb +3 -0
- data/spec/filters/unsupported/module.rb +5 -3
- data/spec/filters/unsupported/pathname.rb +3 -0
- data/spec/filters/unsupported/privacy.rb +136 -0
- data/spec/filters/unsupported/proc.rb +3 -0
- data/spec/filters/unsupported/regexp.rb +59 -0
- data/spec/filters/unsupported/set.rb +4 -0
- data/spec/filters/unsupported/{marshal.rb → singleton.rb} +4 -2
- data/spec/filters/unsupported/{mutable_strings.rb → string.rb} +456 -336
- data/spec/filters/unsupported/struct.rb +3 -0
- data/spec/filters/unsupported/symbol.rb +5 -0
- data/spec/filters/unsupported/taint.rb +16 -0
- data/spec/filters/unsupported/thread.rb +5 -0
- data/spec/filters/unsupported/time.rb +197 -16
- data/spec/lib/cli_spec.rb +14 -4
- data/spec/lib/compiler_spec.rb +9 -1
- data/spec/lib/parser/call_spec.rb +18 -0
- data/spec/lib/parser/not_spec.rb +2 -8
- data/spec/lib/sprockets_spec.rb +24 -0
- data/spec/opal/core/array/intersection_spec.rb +38 -0
- data/spec/opal/core/array/minus_spec.rb +38 -0
- data/spec/opal/core/array/union_spec.rb +38 -0
- data/spec/opal/core/array/uniq_spec.rb +49 -0
- data/spec/opal/core/exception_spec.rb +7 -0
- data/spec/opal/core/fixtures/require_tree_with_dot/file 1.rb +1 -0
- data/spec/opal/core/fixtures/require_tree_with_dot/file 2.rb +1 -0
- data/spec/opal/core/fixtures/require_tree_with_dot/file 3.rb +1 -0
- data/spec/opal/core/fixtures/require_tree_with_dot/index.rb +3 -0
- data/spec/opal/core/hash/internals_spec.rb +332 -0
- data/spec/opal/core/helpers_spec.rb +14 -0
- data/spec/opal/core/kernel/freeze_spec.rb +1 -1
- data/spec/opal/core/kernel/raise_spec.rb +13 -0
- data/spec/opal/core/kernel/require_tree_spec.rb +9 -0
- data/spec/opal/core/language/class_spec.rb +55 -0
- data/spec/opal/core/language/fixtures/send.rb +1 -0
- data/spec/opal/core/language/keyword_arguments_spec.rb +11 -0
- data/spec/opal/core/language/send_spec.rb +5 -0
- data/spec/opal/core/method/to_proc_spec.rb +28 -0
- data/spec/opal/core/module/name_spec.rb +0 -17
- data/spec/opal/core/runtime/bridged_classes_spec.rb +2 -2
- data/spec/opal/core/runtime/eval_spec.rb +1 -1
- data/spec/opal/core/runtime/method_missing_spec.rb +6 -0
- data/spec/opal/core/runtime_spec.rb +51 -0
- data/spec/opal/stdlib/js_spec.rb +66 -0
- data/spec/opal/stdlib/native/hash_spec.rb +36 -0
- data/spec/rubyspecs +152 -273
- data/spec/spec_helper.rb +10 -11
- data/stdlib/base64.rb +9 -9
- data/stdlib/benchmark.rb +551 -4
- data/stdlib/console.rb +94 -0
- data/stdlib/date.rb +1 -1
- data/stdlib/encoding.rb +1 -170
- data/stdlib/js.rb +56 -0
- data/stdlib/json.rb +9 -14
- data/stdlib/math.rb +1 -370
- data/stdlib/native.rb +133 -63
- data/stdlib/nodejs/file.rb +5 -0
- data/stdlib/nodejs/fileutils.rb +13 -6
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/README.md +1 -1
- data/stdlib/opal-parser.rb +1 -2
- data/stdlib/ostruct.rb +65 -6
- data/stdlib/pp.rb +2 -4
- data/stdlib/rbconfig.rb +1 -3
- data/stdlib/strscan.rb +164 -28
- data/tasks/benchmarking.rake +88 -0
- data/tasks/testing.rake +181 -55
- data/{lib/mspec/opal/special_calls.rb → tasks/testing/mspec_special_calls.rb} +1 -1
- data/{lib/mspec/opal/sprockets.js → tasks/testing/phantomjs1-sprockets.js} +17 -6
- data/test/opal/test_keyword.rb +590 -0
- data/vendored-minitest/minitest.rb +2 -2
- data/vendored-minitest/test/unit.rb +5 -0
- metadata +229 -62
- data/benchmarks/operators.rb +0 -11
- data/benchmarks/prova.js.rb +0 -13
- data/docs/libraries.md +0 -36
- data/lib/mspec/opal/new.html.erb +0 -1
- data/lib/mspec/opal/rake_task.rb +0 -248
- data/opal/corelib/match_data.rb +0 -128
- data/spec/filters/bugs/math.rb +0 -95
- data/spec/filters/bugs/nil.rb +0 -7
- data/spec/filters/bugs/opal.rb +0 -9
- data/spec/filters/bugs/regular_expressions.rb +0 -41
- data/spec/filters/bugs/stringscanner.rb +0 -33
- data/spec/filters/unsupported/encoding.rb +0 -102
- data/spec/filters/unsupported/frozen.rb +0 -92
- data/spec/filters/unsupported/hash_compare_by_identity.rb +0 -16
- data/spec/filters/unsupported/integer_size.rb +0 -59
- data/spec/filters/unsupported/method_added.rb +0 -10
- data/spec/filters/unsupported/private_constants.rb +0 -30
- data/spec/filters/unsupported/private_methods.rb +0 -55
- data/spec/filters/unsupported/random.rb +0 -4
- data/spec/filters/unsupported/rational_numbers.rb +0 -4
- data/spec/filters/unsupported/regular_expressions.rb +0 -137
- data/spec/filters/unsupported/ruby_exe.rb +0 -5
- data/spec/filters/unsupported/symbols.rb +0 -17
- data/spec/filters/unsupported/tainted.rb +0 -180
- data/spec/filters/unsupported/trusted.rb +0 -88
- data/stdlib/process.rb +0 -10
- data/tasks/documenting.rake +0 -37
@@ -0,0 +1,216 @@
|
|
1
|
+
%x{
|
2
|
+
var warnings = {};
|
3
|
+
|
4
|
+
function warn(string) {
|
5
|
+
if (warnings[string]) {
|
6
|
+
return;
|
7
|
+
}
|
8
|
+
|
9
|
+
warnings[string] = true;
|
10
|
+
#{warn(`string`)};
|
11
|
+
}
|
12
|
+
}
|
13
|
+
|
14
|
+
class String
|
15
|
+
`var ERROR = "String#%s not supported. Mutable String methods are not supported in Opal.";`
|
16
|
+
|
17
|
+
def <<(*)
|
18
|
+
raise NotImplementedError, `ERROR` % '<<'
|
19
|
+
end
|
20
|
+
|
21
|
+
def capitalize!(*)
|
22
|
+
raise NotImplementedError, `ERROR` % 'capitalize!'
|
23
|
+
end
|
24
|
+
|
25
|
+
def chomp!(*)
|
26
|
+
raise NotImplementedError, `ERROR` % 'chomp!'
|
27
|
+
end
|
28
|
+
|
29
|
+
def chop!(*)
|
30
|
+
raise NotImplementedError, `ERROR` % 'chop!'
|
31
|
+
end
|
32
|
+
|
33
|
+
def downcase!(*)
|
34
|
+
raise NotImplementedError, `ERROR` % 'downcase!'
|
35
|
+
end
|
36
|
+
|
37
|
+
def gsub!(*)
|
38
|
+
raise NotImplementedError, `ERROR` % 'gsub!'
|
39
|
+
end
|
40
|
+
|
41
|
+
def lstrip!(*)
|
42
|
+
raise NotImplementedError, `ERROR` % 'lstrip!'
|
43
|
+
end
|
44
|
+
|
45
|
+
def next!(*)
|
46
|
+
raise NotImplementedError, `ERROR` % 'next!'
|
47
|
+
end
|
48
|
+
|
49
|
+
def reverse!(*)
|
50
|
+
raise NotImplementedError, `ERROR` % 'reverse!'
|
51
|
+
end
|
52
|
+
|
53
|
+
def slice!(*)
|
54
|
+
raise NotImplementedError, `ERROR` % 'slice!'
|
55
|
+
end
|
56
|
+
|
57
|
+
def squeeze!(*)
|
58
|
+
raise NotImplementedError, `ERROR` % 'squeeze!'
|
59
|
+
end
|
60
|
+
|
61
|
+
def strip!(*)
|
62
|
+
raise NotImplementedError, `ERROR` % 'strip!'
|
63
|
+
end
|
64
|
+
|
65
|
+
def sub!(*)
|
66
|
+
raise NotImplementedError, `ERROR` % 'sub!'
|
67
|
+
end
|
68
|
+
|
69
|
+
def succ!(*)
|
70
|
+
raise NotImplementedError, `ERROR` % 'succ!'
|
71
|
+
end
|
72
|
+
|
73
|
+
def swapcase!(*)
|
74
|
+
raise NotImplementedError, `ERROR` % 'swapcase!'
|
75
|
+
end
|
76
|
+
|
77
|
+
def tr!(*)
|
78
|
+
raise NotImplementedError, `ERROR` % 'tr!'
|
79
|
+
end
|
80
|
+
|
81
|
+
def tr_s!(*)
|
82
|
+
raise NotImplementedError, `ERROR` % 'tr_s!'
|
83
|
+
end
|
84
|
+
|
85
|
+
def upcase!(*)
|
86
|
+
raise NotImplementedError, `ERROR` % 'upcase!'
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
module Kernel
|
91
|
+
`var ERROR = "Object freezing is not supported by Opal";`
|
92
|
+
|
93
|
+
def freeze
|
94
|
+
if `OPAL_CONFIG.freezing`
|
95
|
+
`warn(ERROR)`
|
96
|
+
else
|
97
|
+
raise NotImplementedError, `ERROR`
|
98
|
+
end
|
99
|
+
|
100
|
+
self
|
101
|
+
end
|
102
|
+
|
103
|
+
def frozen?
|
104
|
+
if `OPAL_CONFIG.freezing`
|
105
|
+
`warn(ERROR)`
|
106
|
+
else
|
107
|
+
raise NotImplementedError, `ERROR`
|
108
|
+
end
|
109
|
+
|
110
|
+
false
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
module Kernel
|
115
|
+
`var ERROR = "Object tainting is not supported by Opal";`
|
116
|
+
|
117
|
+
def taint
|
118
|
+
if `OPAL_CONFIG.tainting`
|
119
|
+
`warn(ERROR)`
|
120
|
+
else
|
121
|
+
raise NotImplementedError, `ERROR`
|
122
|
+
end
|
123
|
+
|
124
|
+
self
|
125
|
+
end
|
126
|
+
|
127
|
+
def untaint
|
128
|
+
if `OPAL_CONFIG.tainting`
|
129
|
+
`warn(ERROR)`
|
130
|
+
else
|
131
|
+
raise NotImplementedError, `ERROR`
|
132
|
+
end
|
133
|
+
|
134
|
+
self
|
135
|
+
end
|
136
|
+
|
137
|
+
def tainted?
|
138
|
+
if `OPAL_CONFIG.tainting`
|
139
|
+
`warn(ERROR)`
|
140
|
+
else
|
141
|
+
raise NotImplementedError, `ERROR`
|
142
|
+
end
|
143
|
+
|
144
|
+
false
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
module Marshal
|
149
|
+
`var ERROR = "Marshalling is not supported by Opal";`
|
150
|
+
|
151
|
+
module_function
|
152
|
+
|
153
|
+
def dump(*)
|
154
|
+
raise NotImplementedError, `ERROR`
|
155
|
+
end
|
156
|
+
|
157
|
+
def load(*)
|
158
|
+
raise NotImplementedError, `ERROR`
|
159
|
+
end
|
160
|
+
|
161
|
+
def restore(*)
|
162
|
+
raise NotImplementedError, `ERROR`
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
class Module
|
167
|
+
def public(*methods)
|
168
|
+
%x{
|
169
|
+
if (methods.length === 0) {
|
170
|
+
self.$$module_function = false;
|
171
|
+
}
|
172
|
+
|
173
|
+
return nil;
|
174
|
+
}
|
175
|
+
end
|
176
|
+
|
177
|
+
alias private public
|
178
|
+
|
179
|
+
alias protected public
|
180
|
+
|
181
|
+
alias nesting public
|
182
|
+
|
183
|
+
def private_class_method(name)
|
184
|
+
`self['$' + name] || nil`
|
185
|
+
end
|
186
|
+
|
187
|
+
alias public_class_method private_class_method
|
188
|
+
|
189
|
+
def private_method_defined?(obj)
|
190
|
+
false
|
191
|
+
end
|
192
|
+
|
193
|
+
def private_constant(*)
|
194
|
+
end
|
195
|
+
|
196
|
+
alias protected_method_defined? private_method_defined?
|
197
|
+
|
198
|
+
alias public_instance_methods instance_methods
|
199
|
+
|
200
|
+
alias public_method_defined? method_defined?
|
201
|
+
end
|
202
|
+
|
203
|
+
module Kernel
|
204
|
+
def private_methods(*)
|
205
|
+
[]
|
206
|
+
end
|
207
|
+
|
208
|
+
alias private_instance_methods private_methods
|
209
|
+
end
|
210
|
+
|
211
|
+
module Kernel
|
212
|
+
def eval(*)
|
213
|
+
raise NotImplementedError, "To use Kernel#eval, you must first require 'opal-parser'. "\
|
214
|
+
"See https://github.com/opal/opal/blob/#{RUBY_ENGINE_VERSION}/docs/opal_parser.md for details."
|
215
|
+
end
|
216
|
+
end
|
data/opal/corelib/variables.rb
CHANGED
data/opal/opal.rb
CHANGED
@@ -1,32 +1,18 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
3
|
-
|
4
|
-
require 'corelib/class'
|
5
|
-
require 'corelib/basic_object'
|
6
|
-
require 'corelib/kernel'
|
7
|
-
require 'corelib/nil_class'
|
8
|
-
require 'corelib/boolean'
|
9
|
-
require 'corelib/error'
|
10
|
-
require 'corelib/regexp'
|
11
|
-
require 'corelib/comparable'
|
12
|
-
require 'corelib/enumerable'
|
13
|
-
require 'corelib/enumerator'
|
14
|
-
require 'corelib/array'
|
1
|
+
require 'opal/base'
|
2
|
+
require 'opal/mini'
|
3
|
+
|
15
4
|
require 'corelib/array/inheritance'
|
16
|
-
require 'corelib/hash'
|
17
|
-
require 'corelib/string'
|
18
5
|
require 'corelib/string/inheritance'
|
19
|
-
require 'corelib/
|
20
|
-
require 'corelib/
|
6
|
+
require 'corelib/string/encoding'
|
7
|
+
require 'corelib/math'
|
21
8
|
require 'corelib/complex'
|
22
9
|
require 'corelib/rational'
|
23
|
-
require 'corelib/proc'
|
24
|
-
require 'corelib/method'
|
25
|
-
require 'corelib/range'
|
26
10
|
require 'corelib/time'
|
27
11
|
require 'corelib/struct'
|
28
12
|
require 'corelib/io'
|
29
13
|
require 'corelib/main'
|
30
|
-
require 'corelib/variables'
|
31
14
|
require 'corelib/dir'
|
32
15
|
require 'corelib/file'
|
16
|
+
require 'corelib/process'
|
17
|
+
|
18
|
+
require 'corelib/unsupported'
|
data/opal/opal/base.rb
ADDED
data/opal/opal/mini.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'opal/base'
|
2
|
+
|
3
|
+
require 'corelib/nil'
|
4
|
+
require 'corelib/boolean'
|
5
|
+
require 'corelib/string'
|
6
|
+
require 'corelib/comparable'
|
7
|
+
require 'corelib/enumerable'
|
8
|
+
require 'corelib/enumerator'
|
9
|
+
require 'corelib/array'
|
10
|
+
require 'corelib/hash'
|
11
|
+
require 'corelib/number'
|
12
|
+
require 'corelib/range'
|
13
|
+
require 'corelib/proc'
|
14
|
+
require 'corelib/method'
|
15
|
+
require 'corelib/regexp'
|
16
|
+
|
17
|
+
require 'corelib/variables'
|
data/spec/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Opal specs overview
|
2
2
|
|
3
3
|
* **rubyspecs** (file) a whitelist of RubySpec files to be ran
|
4
|
-
* **
|
4
|
+
* **rubyspec** RubySpec examples (submodule)
|
5
5
|
* **stdlib** `rubysl-*` examples (submodules)
|
6
6
|
* **filters** The list of MSpec/RubySpec examples that are either bugs or unsupported
|
7
7
|
* **opal** opal additions/special behaviour in the runtime/corelib
|
data/spec/filters/bugs/array.rb
CHANGED
@@ -1,157 +1,59 @@
|
|
1
1
|
opal_filter "Array" do
|
2
|
-
fails "Array#
|
3
|
-
|
4
|
-
fails "Array
|
5
|
-
fails "Array
|
6
|
-
fails "Array
|
7
|
-
fails "Array
|
8
|
-
fails "Array
|
9
|
-
|
10
|
-
fails "Array
|
11
|
-
|
12
|
-
fails "Array#
|
13
|
-
|
14
|
-
fails "Array#
|
15
|
-
fails "Array#initialize with (size, object=nil) returns the value passed to break"
|
16
|
-
fails "Array#initialize with (size, object=nil) uses the block value instead of using the default value"
|
17
|
-
fails "Array#initialize with (size, object=nil) yields the index of the element and sets the element to the value of the block"
|
18
|
-
fails "Array#initialize with (size, object=nil) raises a TypeError if the size argument is not an Integer type"
|
19
|
-
fails "Array#initialize with (size, object=nil) calls #to_int to convert the size argument to an Integer when object is not given"
|
20
|
-
fails "Array#initialize with (size, object=nil) calls #to_int to convert the size argument to an Integer when object is given"
|
21
|
-
fails "Array#initialize with (size, object=nil) raises an ArgumentError if size is too large"
|
22
|
-
fails "Array#initialize with (size, object=nil) sets the array to size and fills with the object"
|
23
|
-
fails "Array#initialize with (array) calls #to_ary to convert the value to an array"
|
24
|
-
fails "Array#initialize preserves the object's identity even when changing its value"
|
25
|
-
|
26
|
-
fails "Array#& determines equivalence between elements in the sense of eql?"
|
27
|
-
|
28
|
-
fails "Array#- removes an identical item even when its #eql? isn't reflexive"
|
29
|
-
fails "Array#- doesn't remove an item with the same hash but not #eql?"
|
30
|
-
fails "Array#- removes an item identified as equivalent via #hash and #eql?"
|
31
|
-
|
32
|
-
fails "Array#* raises a TypeError is the passed argument is nil"
|
33
|
-
fails "Array#* converts the passed argument to a String rather than an Integer"
|
34
|
-
fails "Array#* raises a TypeError if the argument can neither be converted to a string nor an integer"
|
35
|
-
fails "Array#* tires to convert the passed argument to an Integer using #to_int"
|
36
|
-
fails "Array#* tries to convert the passed argument to a String using #to_str"
|
37
|
-
fails "Array#* with a string uses the same separator with nested arrays"
|
38
|
-
fails "Array#* with a string returns a string formed by concatenating each element.to_str separated by separator"
|
39
|
-
|
40
|
-
fails "Array.new with (size, object=nil) raises an ArgumentError if size is too large"
|
41
|
-
fails "Array.new with (array) calls #to_ary to convert the value to an array"
|
42
|
-
fails "Array.new with (size, object=nil) calls #to_int to convert the size argument to an Integer when object is given"
|
43
|
-
fails "Array.new with (size, object=nil) calls #to_int to convert the size argument to an Integer when object is not given"
|
44
|
-
fails "Array.new with (size, object=nil) raises a TypeError if the size argument is not an Integer type"
|
45
|
-
|
46
|
-
fails "Array#permutation generates from a defensive copy, ignoring mutations"
|
47
|
-
fails "Array#permutation returns an Enumerator which works as expected even when the array was modified"
|
48
|
-
fails "Array#permutation truncates Float arguments"
|
49
|
-
fails "Array#permutation handles nested Arrays correctly"
|
50
|
-
fails "Array#permutation handles duplicate elements correctly"
|
51
|
-
fails "Array#permutation returns no permutations when the given length has no permutations"
|
52
|
-
fails "Array#permutation returns the empty permutation([]) when called on an empty Array"
|
53
|
-
fails "Array#permutation returns the empty permutation ([[]]) when the given length is 0"
|
54
|
-
fails "Array#permutation yields all permutations of given length to the block then returns self when called with block and argument"
|
55
|
-
fails "Array#permutation yields all permutations to the block then returns self when called with block but no arguments"
|
56
|
-
fails "Array#permutation returns an Enumerator of permutations of given length when called with an argument but no block"
|
57
|
-
fails "Array#permutation returns an Enumerator of all permutations when called without a block or arguments"
|
58
|
-
|
59
|
-
fails "Array#rassoc does not check the last element in each contained but speficically the second"
|
60
|
-
fails "Array#rassoc calls elem == obj on the second element of each contained array"
|
61
|
-
|
62
|
-
fails "Array#repeated_combination generates from a defensive copy, ignoring mutations"
|
2
|
+
fails "Array#flatten performs respond_to? and method_missing-aware checks when coercing elements to array"
|
3
|
+
fails "Array#flatten with a non-Array object in the Array calls #method_missing if defined"
|
4
|
+
fails "Array#flatten with a non-Array object in the Array calls #to_ary if not defined when #respond_to_missing? returns true"
|
5
|
+
fails "Array#flatten with a non-Array object in the Array does not call #to_ary if not defined when #respond_to_missing? returns false"
|
6
|
+
fails "Array#join raises a NoMethodError if an element does not respond to #to_str, #to_ary, or #to_s"
|
7
|
+
fails "Array#partition returns in the left array values for which the block evaluates to true"
|
8
|
+
fails "Array#permutation when no block is given returned Enumerator size with an array size greater than 0 returns the descending factorial of array size and given length"
|
9
|
+
fails "Array#permutation when no block is given returned Enumerator size with an array size greater than 0 returns the descending factorial of array size with array size when there's no param"
|
10
|
+
fails "Array#permutation when no block is given returned Enumerator size with an empty array returns 1 when the given length is 0"
|
11
|
+
fails "Array#permutation when no block is given returned Enumerator size with an empty array returns 1 when there's param"
|
12
|
+
fails "Array#pop passed a number n as an argument raises an ArgumentError if more arguments are passed" #Arity issue?
|
13
|
+
fails "Array#rassoc calls elem == obj on the second element of each contained array" #Spec assumes string and symbols are not equal.
|
14
|
+
fails "Array#rassoc does not check the last element in each contained but speficically the second" #Spec assumes string and symbols are not equal.
|
63
15
|
fails "Array#repeated_combination accepts sizes larger than the original array"
|
16
|
+
fails "Array#repeated_combination generates from a defensive copy, ignoring mutations"
|
17
|
+
fails "Array#repeated_combination returns an enumerator when no block is provided"
|
18
|
+
fails "Array#repeated_combination returns self when a block is given"
|
19
|
+
fails "Array#repeated_combination when no block is given returned Enumerator size returns 0 when the combination_size is < 0"
|
20
|
+
fails "Array#repeated_combination when no block is given returned Enumerator size returns 1 when the combination_size is 0"
|
21
|
+
fails "Array#repeated_combination when no block is given returned Enumerator size returns the binomial coeficient between combination_size and array size + combination_size -1"
|
64
22
|
fails "Array#repeated_combination yields a partition consisting of only singletons"
|
23
|
+
fails "Array#repeated_combination yields nothing for negative length and return self"
|
65
24
|
fails "Array#repeated_combination yields nothing when the array is empty and num is non zero"
|
66
|
-
fails "Array#repeated_combination yields [] when length is 0"
|
67
25
|
fails "Array#repeated_combination yields the expected repeated_combinations"
|
68
|
-
fails "Array#repeated_combination yields
|
69
|
-
fails "Array#repeated_combination returns self when a block is given"
|
70
|
-
fails "Array#repeated_combination returns an enumerator when no block is provided"
|
71
|
-
|
72
|
-
fails "Array#repeated_permutation generates from a defensive copy, ignoring mutations"
|
26
|
+
fails "Array#repeated_combination yields [] when length is 0"
|
73
27
|
fails "Array#repeated_permutation allows permutations larger than the number of elements"
|
28
|
+
fails "Array#repeated_permutation does not yield when called on an empty Array with a nonzero argument"
|
29
|
+
fails "Array#repeated_permutation generates from a defensive copy, ignoring mutations"
|
30
|
+
fails "Array#repeated_permutation handles duplicate elements correctly"
|
31
|
+
fails "Array#repeated_permutation returns an Enumerator of all repeated permutations of given length when called without a block"
|
74
32
|
fails "Array#repeated_permutation returns an Enumerator which works as expected even when the array was modified"
|
75
33
|
fails "Array#repeated_permutation truncates Float arguments"
|
76
|
-
fails "Array#repeated_permutation
|
77
|
-
fails "Array#repeated_permutation
|
78
|
-
fails "Array#repeated_permutation yields the empty repeated_permutation ([[]]) when the given length is 0"
|
34
|
+
fails "Array#repeated_permutation when no block is given returned Enumerator size returns 0 when combination_size is < 0"
|
35
|
+
fails "Array#repeated_permutation when no block is given returned Enumerator size returns array size ** combination_size"
|
79
36
|
fails "Array#repeated_permutation yields all repeated_permutations to the block then returns self when called with block but no arguments"
|
80
|
-
fails "Array#repeated_permutation
|
81
|
-
|
82
|
-
fails "Array#
|
83
|
-
|
84
|
-
fails "Array#sample calls #rand on the Object passed by the :random key in the arguments Hash"
|
85
|
-
fails "Array#sample calls #to_hash to convert the passed Object"
|
86
|
-
fails "Array#sample calls #to_int on the Object returned by #rand"
|
87
|
-
fails "Array#sample calls #to_int on the first argument and #to_hash on the second when passed Objects"
|
88
|
-
fails "Array#sample calls #to_int to convert the count when passed an Object"
|
89
|
-
fails "Array#sample does not return the same value if the Array has unique values"
|
90
|
-
fails "Array#sample ignores an Object passed for the RNG if it does not define #rand"
|
91
|
-
fails "Array#sample raises ArgumentError when passed a negative count"
|
92
|
-
fails "Array#sample raises a RangeError if the value is equal to the Array size"
|
93
|
-
fails "Array#sample raises a RangeError if the value is less than zero"
|
94
|
-
fails "Array#sample returns at most the number of elements in the Array"
|
95
|
-
fails "Array#sample when the object returned by #rand is not a Fixnum but responds to #to_int calls #to_int on the Object"
|
96
|
-
fails "Array#sample when the object returned by #rand is not a Fixnum but responds to #to_int raises a RangeError if the value is equal to the Array size"
|
97
|
-
fails "Array#sample when the object returned by #rand is not a Fixnum but responds to #to_int raises a RangeError if the value is less than zero"
|
98
|
-
fails "Array#sample with options calls #rand on the Object passed by the :random key in the arguments Hash"
|
99
|
-
fails "Array#sample with options calls #to_hash to convert the passed Object"
|
100
|
-
fails "Array#sample with options calls #to_int on the first argument and #to_hash on the second when passed Objects"
|
101
|
-
fails "Array#sample with options ignores an Object passed for the RNG if it does not define #rand"
|
102
|
-
fails "Array#sample with options when the object returned by #rand is a Fixnum raises a RangeError if the value is equal to the Array size"
|
103
|
-
fails "Array#sample with options when the object returned by #rand is a Fixnum raises a RangeError if the value is less than zero"
|
104
|
-
fails "Array#sample with options when the object returned by #rand is a Fixnum uses the fixnum as index"
|
105
|
-
|
106
|
-
fails "Array#select returns a new array of elements for which block is true"
|
107
|
-
|
108
|
-
fails "Array#shuffle attempts coercion via #to_hash"
|
109
|
-
fails "Array#shuffle is not destructive"
|
110
|
-
fails "Array#shuffle returns the same values, in a usually different order"
|
111
|
-
fails "Array#shuffle calls #rand on the Object passed by the :random key in the arguments Hash"
|
112
|
-
fails "Array#shuffle ignores an Object passed for the RNG if it does not define #rand"
|
113
|
-
fails "Array#shuffle accepts a Float for the value returned by #rand"
|
114
|
-
fails "Array#shuffle calls #to_int on the Object returned by #rand"
|
115
|
-
fails "Array#shuffle raises a RangeError if the value is less than zero"
|
116
|
-
fails "Array#shuffle raises a RangeError if the value is equal to one"
|
117
|
-
|
118
|
-
fails "Array#shuffle! returns the same values, in a usually different order"
|
119
|
-
|
37
|
+
fails "Array#repeated_permutation yields the empty repeated_permutation ([[]]) when the given length is 0"
|
38
|
+
fails "Array#select returns a new array of elements for which block is true" #Spec assumes integer division
|
39
|
+
fails "Array#shift passed a number n as an argument raises an ArgumentError if more arguments are passed" #Arity issue?
|
120
40
|
fails "Array#slice! calls to_int on range arguments"
|
121
41
|
fails "Array#slice! calls to_int on start and length arguments"
|
122
42
|
fails "Array#slice! does not expand array with indices out of bounds"
|
123
43
|
fails "Array#slice! does not expand array with negative indices out of bounds"
|
124
44
|
fails "Array#slice! removes and return elements in range"
|
125
45
|
fails "Array#slice! removes and returns elements in end-exclusive ranges"
|
126
|
-
|
46
|
+
fails "Array#slice! returns nil if length is negative"
|
47
|
+
fails "Array#sort_by! completes when supplied a block that always returns the same result"
|
127
48
|
fails "Array#sort_by! makes some modification even if finished sorting when it would break in the given block"
|
128
|
-
fails "Array#sort_by! returns the specified value when it would break in the given block"
|
129
|
-
fails "Array#sort_by! raises a RuntimeError on an empty frozen array"
|
130
49
|
fails "Array#sort_by! raises a RuntimeError on a frozen array"
|
131
|
-
fails "Array#sort_by!
|
50
|
+
fails "Array#sort_by! raises a RuntimeError on an empty frozen array"
|
132
51
|
fails "Array#sort_by! returns an Enumerator if not given a block"
|
52
|
+
fails "Array#sort_by! returns the specified value when it would break in the given block"
|
133
53
|
fails "Array#sort_by! sorts array in place by passing each element to the given block"
|
134
|
-
|
135
|
-
fails "Array#uniq compares elements based on the value returned from the block"
|
136
|
-
fails "Array#uniq compares elements with matching hash codes with #eql?"
|
137
|
-
fails "Array#uniq handles nil and false like any other values"
|
138
|
-
fails "Array#uniq uses eql? semantics"
|
139
|
-
fails "Array#uniq yields items in order"
|
140
|
-
|
141
|
-
fails "Array#uniq! compares elements based on the value returned from the block"
|
142
|
-
|
143
|
-
fails "Array#hash returns the same fixnum for arrays with the same content"
|
144
|
-
|
145
|
-
fails "Array#partition returns in the left array values for which the block evaluates to true"
|
146
|
-
|
147
|
-
fails "Array#| acts as if using an intermediate hash to collect values"
|
148
|
-
|
149
|
-
# recursive arrays
|
54
|
+
fails "Array#sort_by! when no block is given returned Enumerator size returns the enumerable size"
|
150
55
|
fails "Array#uniq! properly handles recursive arrays"
|
151
|
-
fails "Array
|
152
|
-
fails "Array#
|
153
|
-
fails "Array
|
154
|
-
|
155
|
-
fails "Array#first raises a RangeError when count is a Bignum"
|
156
|
-
fails "Array#hash calls to_int on result of calling hash on each element"
|
56
|
+
fails "Array#zip fills nil when the given enumereator is shorter than self"
|
57
|
+
fails "Array#zip stops at own size when given an infinite enumerator"
|
58
|
+
fails "Array.[] can unpack 2 or more nested referenced array"
|
157
59
|
end
|