opal 0.4.4 → 0.5.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.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/.gitmodules +3 -0
- data/.travis.yml +8 -0
- data/CONTRIBUTING.md +46 -2
- data/Gemfile +17 -0
- data/README.md +13 -4
- data/Rakefile +22 -119
- data/bin/opal +11 -2
- data/bin/opal-repl +71 -0
- data/corelib/array.rb +554 -356
- data/corelib/basic_object.rb +22 -18
- data/corelib/boolean.rb +15 -6
- data/corelib/class.rb +12 -6
- data/corelib/comparable.rb +40 -9
- data/corelib/encoding.rb +164 -0
- data/corelib/enumerable.rb +532 -300
- data/corelib/enumerator.rb +31 -6
- data/corelib/error.rb +14 -3
- data/corelib/hash.rb +108 -97
- data/corelib/io.rb +30 -0
- data/corelib/kernel.rb +151 -82
- data/corelib/main.rb +7 -0
- data/corelib/match_data.rb +118 -0
- data/corelib/method.rb +58 -0
- data/corelib/module.rb +145 -77
- data/corelib/native.rb +144 -22
- data/corelib/nil_class.rb +2 -0
- data/corelib/numeric.rb +259 -61
- data/corelib/opal.rb +43 -28
- data/corelib/proc.rb +21 -9
- data/corelib/range.rb +42 -23
- data/corelib/regexp.rb +51 -9
- data/corelib/runtime.js +470 -129
- data/corelib/string.rb +170 -246
- data/corelib/struct.rb +13 -1
- data/corelib/time.rb +414 -43
- data/doc/compiler.md +42 -0
- data/doc/compiler_options.md +5 -0
- data/doc/examples/node_http_server.rb +49 -0
- data/doc/external_libraries.md +9 -0
- data/doc/generated_javascript.md +272 -0
- data/doc/home.md +17 -0
- data/doc/method_missing.md +58 -0
- data/doc/static_applications.md +60 -0
- data/doc/using_ruby_from_javascript.md +18 -0
- data/doc/using_sprockets.md +65 -0
- data/lib/opal.rb +18 -15
- data/lib/opal/builder.rb +26 -9
- data/lib/opal/cli.rb +143 -90
- data/lib/opal/cli_options.rb +19 -13
- data/lib/opal/compiler.rb +307 -0
- data/lib/opal/erb.rb +3 -3
- data/lib/opal/fragment.rb +34 -0
- data/lib/opal/nodes.rb +25 -0
- data/lib/opal/nodes/arglist.rb +56 -0
- data/lib/opal/nodes/array.rb +54 -0
- data/lib/opal/nodes/base.rb +150 -0
- data/lib/opal/nodes/base_scope.rb +11 -0
- data/lib/opal/nodes/call.rb +195 -0
- data/lib/opal/nodes/call_special.rb +153 -0
- data/lib/opal/nodes/case.rb +96 -0
- data/lib/opal/nodes/class.rb +43 -0
- data/lib/opal/nodes/constants.rb +91 -0
- data/lib/opal/nodes/def.rb +157 -0
- data/lib/opal/nodes/defined.rb +113 -0
- data/lib/opal/nodes/definitions.rb +182 -0
- data/lib/opal/nodes/hash.rb +67 -0
- data/lib/opal/nodes/helpers.rb +105 -0
- data/lib/opal/nodes/if.rb +60 -0
- data/lib/opal/nodes/iter.rb +118 -0
- data/lib/opal/nodes/literal.rb +193 -0
- data/lib/opal/nodes/logic.rb +211 -0
- data/lib/opal/nodes/masgn.rb +62 -0
- data/lib/opal/nodes/module.rb +46 -0
- data/lib/opal/nodes/rescue.rb +134 -0
- data/lib/opal/nodes/singleton_class.rb +26 -0
- data/lib/opal/nodes/super.rb +97 -0
- data/lib/opal/nodes/top.rb +63 -0
- data/lib/opal/nodes/variables.rb +155 -0
- data/lib/opal/nodes/while.rb +65 -0
- data/lib/opal/nodes/yield.rb +84 -0
- data/lib/opal/parser.rb +294 -2169
- data/lib/opal/parser/grammar.rb +5326 -0
- data/lib/opal/{grammar.y → parser/grammar.y} +180 -113
- data/lib/opal/parser/keywords.rb +64 -0
- data/lib/opal/{lexer.rb → parser/lexer.rb} +278 -327
- data/lib/opal/{lexer_scope.rb → parser/parser_scope.rb} +2 -5
- data/lib/opal/parser/sexp.rb +63 -0
- data/lib/opal/source_map.rb +6 -5
- data/lib/opal/target_scope.rb +15 -17
- data/lib/opal/version.rb +1 -1
- data/mri_spec/cli_spec.rb +67 -6
- data/opal.gemspec +4 -4
- data/spec/config.ru +2 -1
- data/spec/corelib/enumerable/all_break_spec.rb +5 -0
- data/spec/corelib/enumerable/any_break_spec.rb +5 -0
- data/spec/corelib/enumerable/collect_break_spec.rb +13 -0
- data/spec/corelib/enumerable/count_break_spec.rb +5 -0
- data/spec/corelib/enumerable/detect_break_spec.rb +5 -0
- data/spec/corelib/enumerable/drop_while_break_spec.rb +5 -0
- data/spec/corelib/enumerable/each_slice_break.rb +6 -0
- data/spec/corelib/enumerable/each_with_index_break_spec.rb +5 -0
- data/spec/corelib/enumerable/each_with_object_break_spec.rb +5 -0
- data/spec/corelib/enumerable/find_all_break_spec.rb +5 -0
- data/spec/corelib/enumerable/find_index_break_spec.rb +5 -0
- data/spec/corelib/enumerable/grep_break_spec.rb +5 -0
- data/spec/corelib/enumerable/max_break_spec.rb +5 -0
- data/spec/corelib/enumerable/max_by_break_spec.rb +5 -0
- data/spec/corelib/enumerable/min_break_spec.rb +5 -0
- data/spec/corelib/enumerable/min_by_break_spec.rb +5 -0
- data/spec/corelib/enumerable/none_break_spec.rb +5 -0
- data/spec/corelib/enumerable/one_break_spec.rb +5 -0
- data/spec/corelib/enumerable/reduce_break_spec.rb +5 -0
- data/spec/corelib/enumerable/take_while_break_spec.rb +5 -0
- data/spec/{rubyspec → corelib}/fixtures/class.rb +0 -0
- data/spec/{rubyspec → corelib}/fixtures/class_variables.rb +0 -0
- data/spec/{rubyspec → corelib}/fixtures/constants.rb +0 -0
- data/spec/{rubyspec/core → corelib}/kernel/Array_spec.rb +0 -0
- data/spec/{opal → corelib}/kernel/block_given_spec.rb +0 -0
- data/spec/{opal → corelib}/kernel/class_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/kernel/define_singleton_method_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/kernel/equal_value_spec.rb +0 -0
- data/spec/{opal → corelib}/kernel/extend_spec.rb +0 -0
- data/spec/{opal → corelib}/kernel/format_spec.rb +0 -0
- data/spec/{opal → corelib}/kernel/freeze_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/kernel/instance_eval_spec.rb +0 -0
- data/spec/{opal → corelib}/kernel/instance_variable_defined_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/kernel/instance_variable_get_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/kernel/instance_variable_set_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/kernel/loop_spec.rb +0 -0
- data/spec/{opal → corelib}/kernel/match_spec.rb +0 -0
- data/spec/{opal → corelib}/kernel/method_spec.rb +0 -0
- data/spec/{opal → corelib}/kernel/methods_spec.rb +0 -0
- data/spec/{opal → corelib}/kernel/nil_spec.rb +0 -0
- data/spec/{opal → corelib}/kernel/p_spec.rb +8 -6
- data/spec/{opal → corelib}/kernel/printf_spec.rb +4 -2
- data/spec/{opal → corelib}/kernel/proc_spec.rb +0 -0
- data/spec/{opal → corelib}/kernel/rand_spec.rb +0 -0
- data/spec/{opal → corelib}/kernel/respond_to_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/kernel/send_spec.rb +0 -0
- data/spec/{opal → corelib}/kernel/sprintf_spec.rb +0 -0
- data/spec/corelib/kernel/warn_spec.rb +83 -0
- data/spec/{rubyspec → corelib}/language/block_spec.rb +17 -18
- data/spec/{rubyspec → corelib}/language/fixtures/array.rb +0 -0
- data/spec/{rubyspec → corelib}/language/fixtures/block.rb +0 -0
- data/spec/{rubyspec → corelib}/language/fixtures/break.rb +0 -0
- data/spec/{rubyspec → corelib}/language/fixtures/ensure.rb +0 -0
- data/spec/{rubyspec → corelib}/language/fixtures/literal_lambda.rb +0 -0
- data/spec/{rubyspec → corelib}/language/fixtures/metaclass.rb +0 -0
- data/spec/{rubyspec → corelib}/language/fixtures/module.rb +0 -0
- data/spec/{rubyspec → corelib}/language/fixtures/next.rb +0 -0
- data/spec/{rubyspec → corelib}/language/fixtures/return.rb +0 -0
- data/spec/{rubyspec → corelib}/language/fixtures/send.rb +1 -1
- data/spec/{rubyspec → corelib}/language/fixtures/send_1.9.rb +0 -0
- data/spec/{rubyspec → corelib}/language/fixtures/super.rb +0 -0
- data/spec/{rubyspec → corelib}/language/fixtures/variables.rb +0 -0
- data/spec/{rubyspec → corelib}/language/fixtures/yield.rb +0 -0
- data/spec/{rubyspec → corelib}/language/numbers_spec.rb +0 -2
- data/spec/{rubyspec → corelib}/language/predefined_spec.rb +0 -0
- data/spec/{rubyspec → corelib}/language/proc_spec.rb +0 -2
- data/spec/{rubyspec → corelib}/language/regexp_spec.rb +0 -0
- data/spec/{rubyspec → corelib}/language/send_spec.rb +6 -7
- data/spec/{rubyspec → corelib}/language/string_spec.rb +0 -0
- data/spec/{rubyspec → corelib}/language/symbol_spec.rb +0 -0
- data/spec/{rubyspec → corelib}/language/variables_spec.rb +1 -2
- data/spec/{rubyspec → corelib}/language/versions/array_1.9.rb +0 -0
- data/spec/{rubyspec → corelib}/language/versions/block_1.9.rb +0 -0
- data/spec/{rubyspec → corelib}/language/versions/break_1.9.rb +0 -0
- data/spec/{rubyspec → corelib}/language/versions/case_1.9.rb +0 -0
- data/spec/{rubyspec → corelib}/language/versions/hash_1.9.rb +0 -0
- data/spec/{rubyspec → corelib}/language/versions/literal_lambda_1.9.rb +0 -0
- data/spec/{rubyspec → corelib}/language/versions/not_1.9.rb +0 -0
- data/spec/{rubyspec → corelib}/language/versions/send_1.9.rb +0 -0
- data/spec/{rubyspec → corelib}/language/versions/symbol_1.9.rb +0 -0
- data/spec/{rubyspec → corelib}/language/versions/variables_1.9.rb +1 -1
- data/spec/corelib/module/alias_method_spec.rb +28 -0
- data/spec/{opal → corelib}/module/ancestors_spec.rb +0 -0
- data/spec/{opal → corelib}/module/append_features_spec.rb +0 -0
- data/spec/corelib/module/attr_accessor_spec.rb +26 -0
- data/spec/{rubyspec/core → corelib}/module/const_defined_spec.rb +1 -2
- data/spec/{rubyspec/core → corelib}/module/const_get_spec.rb +1 -2
- data/spec/{rubyspec/core → corelib}/module/const_missing_spec.rb +1 -2
- data/spec/{rubyspec/core → corelib}/module/const_set_spec.rb +1 -2
- data/spec/{opal → corelib}/module/constants_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/module/fixtures/classes.rb +0 -0
- data/spec/{rubyspec/core → corelib}/module/method_defined_spec.rb +0 -1
- data/spec/{opal → corelib}/module/module_function_spec.rb +0 -2
- data/spec/corelib/module/name_spec.rb +52 -0
- data/spec/{rubyspec/core → corelib}/module/public_method_defined_spec.rb +0 -1
- data/spec/{rubyspec/core → corelib}/module/remove_const_spec.rb +0 -1
- data/spec/{rubyspec/core → corelib}/module/undef_method_spec.rb +0 -1
- data/spec/{opal → corelib}/native/alias_native_spec.rb +7 -0
- data/spec/{opal → corelib}/native/each_spec.rb +2 -5
- data/spec/{opal → corelib}/native/element_reference_spec.rb +0 -0
- data/spec/{rubyspec/core/hash/to_native_spec.rb → corelib/native/ext_spec.rb} +0 -0
- data/spec/corelib/native/initialize_spec.rb +17 -0
- data/spec/{opal → corelib}/native/method_missing_spec.rb +0 -0
- data/spec/corelib/native/new_spec.rb +6 -0
- data/spec/{rubyspec/core → corelib}/numeric/abs_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/numeric/bit_and_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/numeric/bit_or_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/numeric/bit_xor_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/numeric/ceil_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/numeric/chr_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/numeric/comparison_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/numeric/complement_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/numeric/divide_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/numeric/downto_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/numeric/eql_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/numeric/equal_value_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/numeric/even_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/numeric/exponent_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/numeric/floor_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/numeric/gt_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/numeric/gte_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/numeric/integer_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/numeric/left_shift_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/numeric/lt_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/numeric/lte_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/numeric/magnitude_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/numeric/minus_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/numeric/modulo_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/numeric/multiply_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/numeric/next_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/numeric/odd_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/numeric/ord_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/numeric/plus_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/numeric/pred_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/numeric/right_shift_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/numeric/step_spec.rb +0 -3
- data/spec/{rubyspec/core → corelib}/numeric/succ_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/numeric/times_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/numeric/to_f_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/numeric/to_i_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/numeric/to_json_spec.rb +0 -0
- data/spec/corelib/numeric/to_s_spec.rb +26 -0
- data/spec/{rubyspec/core → corelib}/numeric/uminus_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/numeric/upto_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/numeric/zero_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/proc/call_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/proc/element_reference_spec.rb +0 -0
- data/spec/{opal → corelib}/proc/proc_tricks_spec.rb +0 -0
- data/spec/corelib/runtime/begin_spec.rb +39 -0
- data/spec/{opal → corelib}/runtime/block_send_spec.rb +0 -0
- data/spec/{opal/language → corelib/runtime}/block_spec.rb +10 -0
- data/spec/corelib/runtime/bridged_classes_spec.rb +64 -0
- data/spec/{opal → corelib/runtime}/constants_spec.rb +0 -0
- data/spec/{opal → corelib}/runtime/eval_spec.rb +0 -0
- data/spec/{opal → corelib}/runtime/main_methods_spec.rb +0 -0
- data/spec/{opal → corelib/runtime}/method_missing_spec.rb +0 -0
- data/spec/corelib/runtime/method_spec.rb +31 -0
- data/spec/corelib/runtime/paren_spec.rb +14 -0
- data/spec/{opal/language → corelib/runtime}/rescue_spec.rb +11 -0
- data/spec/{opal/language → corelib/runtime}/return_spec.rb +0 -0
- data/spec/{opal → corelib}/runtime/send_spec.rb +0 -0
- data/spec/{opal/language → corelib/runtime}/singleton_class_spec.rb +0 -0
- data/spec/{opal/language → corelib/runtime}/super_spec.rb +113 -0
- data/spec/{opal/language → corelib/runtime}/variables_spec.rb +0 -0
- data/spec/{opal → corelib}/source_map_spec.rb +3 -3
- data/spec/{rubyspec/core → corelib}/string/chop_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/string/chr_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/string/clone_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/string/comparison_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/string/dup_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/string/element_reference_spec.rb +0 -1
- data/spec/{rubyspec/core → corelib}/string/fixtures/classes.rb +0 -0
- data/spec/{rubyspec/core → corelib}/string/format_spec.rb +0 -0
- data/spec/{opal → corelib}/string/freeze_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/string/gsub_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/string/lines_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/string/ljust_spec.rb +0 -1
- data/spec/{rubyspec/core → corelib}/string/lstrip_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/string/match_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/string/next_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/string/ord_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/string/partition_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/string/rindex_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/string/rjust_spec.rb +0 -1
- data/spec/{rubyspec/core → corelib}/string/rstrip_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/string/scan_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/string/slice_spec.rb +1 -2
- data/spec/{rubyspec/core → corelib}/string/split_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/string/strip_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/string/sub_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/string/succ_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/string/sum_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/string/to_f_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/string/to_i_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/string/tr_s_spec.rb +0 -0
- data/spec/{rubyspec/core → corelib}/string/tr_spec.rb +0 -0
- data/spec/filters/bugs/array.rb +236 -4
- data/spec/filters/bugs/basic_object.rb +4 -0
- data/spec/filters/bugs/class.rb +4 -0
- data/spec/filters/bugs/enumerable.rb +58 -0
- data/spec/filters/bugs/enumerator.rb +6 -0
- data/spec/filters/bugs/hash.rb +146 -0
- data/spec/filters/bugs/kernel.rb +10 -0
- data/spec/filters/bugs/language.rb +366 -0
- data/spec/filters/bugs/module.rb +14 -0
- data/spec/filters/bugs/regexp.rb +7 -0
- data/spec/filters/bugs/set.rb +7 -0
- data/spec/filters/bugs/{singleton/instance.rb → singleton.rb} +3 -1
- data/spec/filters/bugs/string.rb +37 -0
- data/spec/filters/bugs/stringscanner.rb +18 -0
- data/spec/filters/bugs/struct.rb +11 -0
- data/spec/filters/bugs/symbol.rb +5 -0
- data/spec/filters/bugs/time.rb +28 -0
- data/spec/filters/bugs/unknown.rb +11 -0
- data/spec/filters/unsupported/array_subclasses.rb +32 -0
- data/spec/filters/unsupported/encoding.rb +14 -0
- data/spec/filters/unsupported/float.rb +4 -0
- data/spec/filters/unsupported/frozen.rb +57 -0
- data/spec/filters/unsupported/hash_compare_by_identity.rb +16 -0
- data/spec/filters/unsupported/immutable_strings.rb +6 -0
- data/spec/filters/unsupported/mutable_strings.rb +49 -0
- data/spec/filters/unsupported/private_methods.rb +26 -0
- data/spec/filters/{mspec → unsupported}/ruby_exe.rb +0 -0
- data/spec/filters/unsupported/string_subclasses.rb +8 -0
- data/spec/filters/unsupported/tainted.rb +46 -0
- data/spec/filters/unsupported/time.rb +21 -0
- data/spec/filters/unsupported/trusted.rb +26 -0
- data/spec/opal/{parser → compiler}/irb_spec.rb +9 -9
- data/spec/{parser → opal/parser}/alias_spec.rb +0 -0
- data/spec/{parser → opal/parser}/and_spec.rb +0 -0
- data/spec/{parser → opal/parser}/array_spec.rb +0 -0
- data/spec/{parser → opal/parser}/attrasgn_spec.rb +0 -0
- data/spec/{parser → opal/parser}/begin_spec.rb +0 -0
- data/spec/{parser → opal/parser}/block_spec.rb +0 -0
- data/spec/{parser → opal/parser}/break_spec.rb +0 -0
- data/spec/{parser → opal/parser}/call_spec.rb +33 -8
- data/spec/{parser → opal/parser}/class_spec.rb +0 -0
- data/spec/{parser → opal/parser}/const_spec.rb +0 -0
- data/spec/{parser → opal/parser}/cvar_spec.rb +0 -0
- data/spec/{parser → opal/parser}/def_spec.rb +17 -17
- data/spec/{parser → opal/parser}/false_spec.rb +0 -0
- data/spec/{parser → opal/parser}/file_spec.rb +0 -0
- data/spec/{parser → opal/parser}/gvar_spec.rb +0 -0
- data/spec/{parser → opal/parser}/hash_spec.rb +0 -0
- data/spec/opal/parser/heredoc_spec.rb +30 -0
- data/spec/{parser → opal/parser}/iasgn_spec.rb +0 -0
- data/spec/{parser → opal/parser}/if_spec.rb +0 -0
- data/spec/{parser → opal/parser}/int_spec.rb +0 -0
- data/spec/opal/parser/iter_spec.rb +59 -0
- data/spec/{parser → opal/parser}/ivar_spec.rb +0 -0
- data/spec/opal/parser/lambda_spec.rb +64 -0
- data/spec/{parser → opal/parser}/lasgn_spec.rb +0 -0
- data/spec/{parser → opal/parser}/line_spec.rb +0 -0
- data/spec/{parser → opal/parser}/lvar_spec.rb +6 -6
- data/spec/{parser → opal/parser}/masgn_spec.rb +0 -0
- data/spec/{parser → opal/parser}/module_spec.rb +0 -0
- data/spec/{parser → opal/parser}/nil_spec.rb +0 -0
- data/spec/{parser → opal/parser}/not_spec.rb +0 -0
- data/spec/{parser → opal/parser}/nth_ref_spec.rb +0 -0
- data/spec/{parser → opal/parser}/op_asgn1_spec.rb +0 -0
- data/spec/{parser → opal/parser}/op_asgn2_spec.rb +0 -0
- data/spec/{parser → opal/parser}/or_spec.rb +0 -0
- data/spec/{parser → opal/parser}/parse_spec.rb +17 -17
- data/spec/{parser → opal/parser}/regexp_spec.rb +0 -0
- data/spec/{parser → opal/parser}/return_spec.rb +0 -0
- data/spec/{parser → opal/parser}/sclass_spec.rb +0 -0
- data/spec/{parser → opal/parser}/self_spec.rb +0 -0
- data/spec/{parser → opal/parser}/str_spec.rb +1 -12
- data/spec/{parser → opal/parser}/string_spec.rb +0 -0
- data/spec/opal/parser/super_spec.rb +20 -0
- data/spec/{parser → opal/parser}/true_spec.rb +0 -0
- data/spec/{parser → opal/parser}/undef_spec.rb +0 -0
- data/spec/{parser → opal/parser}/unless_spec.rb +0 -0
- data/spec/{parser → opal/parser}/while_spec.rb +0 -0
- data/spec/{parser → opal/parser}/xstr_spec.rb +2 -2
- data/spec/{parser → opal/parser}/yield_spec.rb +0 -0
- data/spec/ospec/main.rb.erb +1 -13
- data/spec/ospec/mspec_fixes.rb +87 -0
- data/spec/ospec/runner.rb +188 -0
- data/spec/rubyspecs +351 -0
- data/spec/spec_helper.rb +8 -198
- data/spec/{opal → stdlib}/erb/erb_spec.rb +3 -3
- data/spec/{opal → stdlib}/erb/inline_block.opalerb +0 -0
- data/spec/{opal → stdlib}/erb/quoted.opalerb +0 -0
- data/spec/{opal → stdlib}/erb/simple.opalerb +0 -0
- data/spec/stdlib/json/ext_spec.rb +48 -0
- data/spec/{opal → stdlib}/json/parse_spec.rb +0 -0
- data/spec/stdlib/template/paths_spec.rb +10 -0
- data/stdlib/delegate.rb +29 -0
- data/stdlib/dir.rb +5 -0
- data/stdlib/file.rb +7 -0
- data/stdlib/json.rb +82 -27
- data/stdlib/opal-parser.rb +46 -0
- data/stdlib/opal-source-maps.js.erb +1 -1
- data/stdlib/pathname.rb +31 -0
- data/stdlib/{racc.rb → racc/parser.rb} +0 -0
- data/stdlib/securerandom.rb +12 -0
- data/stdlib/set.rb +89 -0
- data/stdlib/stringio.rb +12 -4
- data/stdlib/strscan.rb +19 -0
- data/stdlib/template.rb +4 -0
- data/stdlib/thread.rb +20 -0
- data/tasks/mspec.rake +147 -0
- metadata +650 -1266
- data/lib/opal/core_ext.rb +0 -5
- data/lib/opal/grammar.rb +0 -5137
- data/lib/opal/grammar_helpers.rb +0 -364
- data/lib/opal/require_parser.rb +0 -77
- data/spec/filters/bugs/alias.rb +0 -6
- data/spec/filters/bugs/ancestors.rb +0 -4
- data/spec/filters/bugs/array/combination.rb +0 -11
- data/spec/filters/bugs/array/count.rb +0 -3
- data/spec/filters/bugs/array/delete_if.rb +0 -3
- data/spec/filters/bugs/array/drop.rb +0 -3
- data/spec/filters/bugs/array/drop_while.rb +0 -5
- data/spec/filters/bugs/array/eql.rb +0 -3
- data/spec/filters/bugs/array/flatten.rb +0 -9
- data/spec/filters/bugs/array/minus.rb +0 -5
- data/spec/filters/bugs/array/multipliy.rb +0 -9
- data/spec/filters/bugs/array/new.rb +0 -3
- data/spec/filters/bugs/array/pop.rb +0 -6
- data/spec/filters/bugs/array/rassoc.rb +0 -4
- data/spec/filters/bugs/array/rindex.rb +0 -6
- data/spec/filters/bugs/array/select.rb +0 -3
- data/spec/filters/bugs/array/shift.rb +0 -7
- data/spec/filters/bugs/array/shuffle.rb +0 -11
- data/spec/filters/bugs/array/slice.rb +0 -7
- data/spec/filters/bugs/array/take.rb +0 -3
- data/spec/filters/bugs/array/to_a.rb +0 -3
- data/spec/filters/bugs/array/try_convert.rb +0 -7
- data/spec/filters/bugs/array/uniq.rb +0 -10
- data/spec/filters/bugs/array/zip.rb +0 -4
- data/spec/filters/bugs/array_delete.rb +0 -4
- data/spec/filters/bugs/array_fetch.rb +0 -3
- data/spec/filters/bugs/array_first.rb +0 -3
- data/spec/filters/bugs/array_flatten.rb +0 -14
- data/spec/filters/bugs/array_intersection.rb +0 -5
- data/spec/filters/bugs/array_join.rb +0 -6
- data/spec/filters/bugs/break.rb +0 -10
- data/spec/filters/bugs/case.rb +0 -4
- data/spec/filters/bugs/coerce_integer.rb +0 -9
- data/spec/filters/bugs/enumerable_sort_by.rb +0 -3
- data/spec/filters/bugs/kernel/instance_variables.rb +0 -3
- data/spec/filters/bugs/kernel/rand.rb +0 -4
- data/spec/filters/bugs/language/array.rb +0 -3
- data/spec/filters/bugs/language/block.rb +0 -6
- data/spec/filters/bugs/language/break.rb +0 -3
- data/spec/filters/bugs/language/class.rb +0 -12
- data/spec/filters/bugs/language/class_variables.rb +0 -12
- data/spec/filters/bugs/language/def.rb +0 -27
- data/spec/filters/bugs/language/defined.rb +0 -3
- data/spec/filters/bugs/language/ensure.rb +0 -4
- data/spec/filters/bugs/language/execution.rb +0 -4
- data/spec/filters/bugs/language/for.rb +0 -18
- data/spec/filters/bugs/language/if.rb +0 -13
- data/spec/filters/bugs/language/loop.rb +0 -4
- data/spec/filters/bugs/language/metaclass.rb +0 -14
- data/spec/filters/bugs/language/module.rb +0 -6
- data/spec/filters/bugs/language/next.rb +0 -3
- data/spec/filters/bugs/language/or.rb +0 -3
- data/spec/filters/bugs/language/order.rb +0 -4
- data/spec/filters/bugs/language/precedence.rb +0 -10
- data/spec/filters/bugs/language/proc.rb +0 -24
- data/spec/filters/bugs/language/redo.rb +0 -5
- data/spec/filters/bugs/language/rescue.rb +0 -9
- data/spec/filters/bugs/language/retry.rb +0 -5
- data/spec/filters/bugs/language/send.rb +0 -10
- data/spec/filters/bugs/language/super.rb +0 -9
- data/spec/filters/bugs/language/until.rb +0 -8
- data/spec/filters/bugs/language/variables.rb +0 -37
- data/spec/filters/bugs/language/while.rb +0 -6
- data/spec/filters/bugs/language/yield.rb +0 -5
- data/spec/filters/bugs/module/class_variables.rb +0 -6
- data/spec/filters/bugs/module/method_defined.rb +0 -6
- data/spec/filters/bugs/public_methods.rb +0 -4
- data/spec/filters/bugs/return.rb +0 -7
- data/spec/filters/bugs/source_map.rb +0 -3
- data/spec/filters/bugs/string/center.rb +0 -4
- data/spec/filters/bugs/string/lines.rb +0 -3
- data/spec/filters/mspec/mocks.rb +0 -3
- data/spec/filters/mspec/should_receive.rb +0 -5
- data/spec/filters/parser/block_args.rb +0 -51
- data/spec/mspec/guards/block_device.rb +0 -0
- data/spec/mspec/guards/endian.rb +0 -0
- data/spec/mspec/helpers/environment.rb +0 -0
- data/spec/mspec/helpers/language_version.rb +0 -0
- data/spec/mspec/helpers/tmp.rb +0 -0
- data/spec/opal/array/element_reference_spec.rb +0 -206
- data/spec/opal/array/equal_value_spec.rb +0 -19
- data/spec/opal/array/fill_spec.rb +0 -26
- data/spec/opal/array/reduce_spec.rb +0 -31
- data/spec/opal/array/to_json_spec.rb +0 -9
- data/spec/opal/basic_object/send_spec.rb +0 -28
- data/spec/opal/boolean/singleton_class_spec.rb +0 -9
- data/spec/opal/boolean/to_json_spec.rb +0 -11
- data/spec/opal/browser/local_storage_spec.rb +0 -55
- data/spec/opal/class/constants_spec.rb +0 -7
- data/spec/opal/class/extend_spec.rb +0 -47
- data/spec/opal/class/instance_methods_spec.rb +0 -13
- data/spec/opal/class/last_value_spec.rb +0 -67
- data/spec/opal/class/proc_methods_spec.rb +0 -23
- data/spec/opal/class/singleton_methods_spec.rb +0 -41
- data/spec/opal/hash/allocate_spec.rb +0 -16
- data/spec/opal/hash/new_spec.rb +0 -10
- data/spec/opal/hash/to_s_spec.rb +0 -9
- data/spec/opal/kernel/to_json_spec.rb +0 -7
- data/spec/opal/module/alias_method_spec.rb +0 -10
- data/spec/opal/module/attr_accessor_spec.rb +0 -8
- data/spec/opal/native/new_spec.rb +0 -19
- data/spec/opal/native/nil_spec.rb +0 -14
- data/spec/opal/nil/to_json_spec.rb +0 -7
- data/spec/opal/numeric/equal_spec.rb +0 -9
- data/spec/opal/runtime2/call_spec.rb +0 -16
- data/spec/opal/runtime2/class_hierarchy_spec.rb +0 -21
- data/spec/opal/runtime2/defined_spec.rb +0 -11
- data/spec/opal/runtime2/super_spec.rb +0 -16
- data/spec/opal/string/to_json_spec.rb +0 -8
- data/spec/parser/iter_spec.rb +0 -59
- data/spec/parser/lambda_spec.rb +0 -64
- data/spec/parser/parser_spec.rb +0 -41
- data/spec/parser/strscan/check_spec.rb +0 -13
- data/spec/parser/strscan/get_byte_spec.rb +0 -29
- data/spec/parser/strscan/scan_spec.rb +0 -33
- data/spec/parser/strscan/skip_spec.rb +0 -40
- data/spec/parser/super_spec.rb +0 -20
- data/spec/rubyspec/core/array/allocate_spec.rb +0 -19
- data/spec/rubyspec/core/array/append_spec.rb +0 -43
- data/spec/rubyspec/core/array/array_spec.rb +0 -7
- data/spec/rubyspec/core/array/assoc_spec.rb +0 -40
- data/spec/rubyspec/core/array/at_spec.rb +0 -56
- data/spec/rubyspec/core/array/choice_spec.rb +0 -20
- data/spec/rubyspec/core/array/clear_spec.rb +0 -61
- data/spec/rubyspec/core/array/clone_spec.rb +0 -15
- data/spec/rubyspec/core/array/collect_spec.rb +0 -53
- data/spec/rubyspec/core/array/combination_spec.rb +0 -55
- data/spec/rubyspec/core/array/compact_spec.rb +0 -111
- data/spec/rubyspec/core/array/comparison_spec.rb +0 -16
- data/spec/rubyspec/core/array/concat_spec.rb +0 -19
- data/spec/rubyspec/core/array/constructor_spec.rb +0 -24
- data/spec/rubyspec/core/array/count_spec.rb +0 -17
- data/spec/rubyspec/core/array/delete_at_spec.rb +0 -71
- data/spec/rubyspec/core/array/delete_if_spec.rb +0 -71
- data/spec/rubyspec/core/array/delete_spec.rb +0 -104
- data/spec/rubyspec/core/array/drop_spec.rb +0 -29
- data/spec/rubyspec/core/array/drop_while_spec.rb +0 -17
- data/spec/rubyspec/core/array/dup_spec.rb +0 -15
- data/spec/rubyspec/core/array/each_index_spec.rb +0 -40
- data/spec/rubyspec/core/array/each_spec.rb +0 -30
- data/spec/rubyspec/core/array/empty_spec.rb +0 -10
- data/spec/rubyspec/core/array/eql_spec.rb +0 -14
- data/spec/rubyspec/core/array/fetch_spec.rb +0 -52
- data/spec/rubyspec/core/array/find_index_spec.rb +0 -8
- data/spec/rubyspec/core/array/first_spec.rb +0 -89
- data/spec/rubyspec/core/array/fixtures/classes.rb +0 -538
- data/spec/rubyspec/core/array/flatten_spec.rb +0 -232
- data/spec/rubyspec/core/array/frozen_spec.rb +0 -32
- data/spec/rubyspec/core/array/include_spec.rb +0 -33
- data/spec/rubyspec/core/array/index_spec.rb +0 -6
- data/spec/rubyspec/core/array/insert_spec.rb +0 -90
- data/spec/rubyspec/core/array/inspect_spec.rb +0 -7
- data/spec/rubyspec/core/array/intersection_spec.rb +0 -78
- data/spec/rubyspec/core/array/join_spec.rb +0 -34
- data/spec/rubyspec/core/array/keep_if_spec.rb +0 -12
- data/spec/rubyspec/core/array/last_spec.rb +0 -88
- data/spec/rubyspec/core/array/length_spec.rb +0 -7
- data/spec/rubyspec/core/array/map_spec.rb +0 -11
- data/spec/rubyspec/core/array/max_spec.rb +0 -32
- data/spec/rubyspec/core/array/min_spec.rb +0 -32
- data/spec/rubyspec/core/array/minus_spec.rb +0 -89
- data/spec/rubyspec/core/array/multiply_spec.rb +0 -143
- data/spec/rubyspec/core/array/new_spec.rb +0 -137
- data/spec/rubyspec/core/array/ntimes_spec.rb +0 -26
- data/spec/rubyspec/core/array/plus_spec.rb +0 -64
- data/spec/rubyspec/core/array/pop_spec.rb +0 -196
- data/spec/rubyspec/core/array/push_spec.rb +0 -44
- data/spec/rubyspec/core/array/rassoc_spec.rb +0 -38
- data/spec/rubyspec/core/array/reject_spec.rb +0 -134
- data/spec/rubyspec/core/array/replace_spec.rb +0 -7
- data/spec/rubyspec/core/array/reverse_each_spec.rb +0 -37
- data/spec/rubyspec/core/array/reverse_spec.rb +0 -58
- data/spec/rubyspec/core/array/rindex_spec.rb +0 -71
- data/spec/rubyspec/core/array/select_spec.rb +0 -36
- data/spec/rubyspec/core/array/shared/collect.rb +0 -7
- data/spec/rubyspec/core/array/shared/enumeratorize.rb +0 -12
- data/spec/rubyspec/core/array/shared/eql.rb +0 -95
- data/spec/rubyspec/core/array/shared/index.rb +0 -37
- data/spec/rubyspec/core/array/shared/inspect.rb +0 -3
- data/spec/rubyspec/core/array/shared/join.rb +0 -7
- data/spec/rubyspec/core/array/shared/keep_if.rb +0 -3
- data/spec/rubyspec/core/array/shared/length.rb +0 -3
- data/spec/rubyspec/core/array/shared/replace.rb +0 -3
- data/spec/rubyspec/core/array/shared/slice.rb +0 -3
- data/spec/rubyspec/core/array/shift_spec.rb +0 -160
- data/spec/rubyspec/core/array/shuffle_spec.rb +0 -87
- data/spec/rubyspec/core/array/size_spec.rb +0 -7
- data/spec/rubyspec/core/array/slice_spec.rb +0 -166
- data/spec/rubyspec/core/array/sort_spec.rb +0 -271
- data/spec/rubyspec/core/array/take_spec.rb +0 -29
- data/spec/rubyspec/core/array/take_while_spec.rb +0 -17
- data/spec/rubyspec/core/array/to_a_spec.rb +0 -24
- data/spec/rubyspec/core/array/to_ary_spec.rb +0 -20
- data/spec/rubyspec/core/array/try_convert_spec.rb +0 -52
- data/spec/rubyspec/core/array/uniq_spec.rb +0 -167
- data/spec/rubyspec/core/array/unshift_spec.rb +0 -64
- data/spec/rubyspec/core/array/zip_spec.rb +0 -55
- data/spec/rubyspec/core/class/fixtures/classes.rb +0 -9
- data/spec/rubyspec/core/class/new_spec.rb +0 -113
- data/spec/rubyspec/core/enumerable/all_spec.rb +0 -130
- data/spec/rubyspec/core/enumerable/any_spec.rb +0 -150
- data/spec/rubyspec/core/enumerable/collect_spec.rb +0 -39
- data/spec/rubyspec/core/enumerable/count_spec.rb +0 -45
- data/spec/rubyspec/core/enumerable/detect_spec.rb +0 -48
- data/spec/rubyspec/core/enumerable/drop_spec.rb +0 -20
- data/spec/rubyspec/core/enumerable/drop_while_spec.rb +0 -18
- data/spec/rubyspec/core/enumerable/each_slice_spec.rb +0 -25
- data/spec/rubyspec/core/enumerable/each_with_index_spec.rb +0 -14
- data/spec/rubyspec/core/enumerable/each_with_object_spec.rb +0 -20
- data/spec/rubyspec/core/enumerable/entries_spec.rb +0 -9
- data/spec/rubyspec/core/enumerable/find_all_spec.rb +0 -16
- data/spec/rubyspec/core/enumerable/find_index_spec.rb +0 -44
- data/spec/rubyspec/core/enumerable/find_spec.rb +0 -56
- data/spec/rubyspec/core/enumerable/first_spec.rb +0 -43
- data/spec/rubyspec/core/enumerable/fixtures/classes.rb +0 -240
- data/spec/rubyspec/core/enumerable/grep_spec.rb +0 -24
- data/spec/rubyspec/core/enumerable/group_by_spec.rb +0 -16
- data/spec/rubyspec/core/enumerable/none_spec.rb +0 -68
- data/spec/rubyspec/core/enumerable/select_spec.rb +0 -16
- data/spec/rubyspec/core/enumerable/sort_by_spec.rb +0 -31
- data/spec/rubyspec/core/enumerable/take_spec.rb +0 -43
- data/spec/rubyspec/core/enumerable/to_a_spec.rb +0 -9
- data/spec/rubyspec/core/enumerator/each_spec.rb +0 -11
- data/spec/rubyspec/core/enumerator/new_spec.rb +0 -17
- data/spec/rubyspec/core/enumerator/next_spec.rb +0 -25
- data/spec/rubyspec/core/enumerator/rewind_spec.rb +0 -28
- data/spec/rubyspec/core/false/and_spec.rb +0 -11
- data/spec/rubyspec/core/false/inspect_spec.rb +0 -7
- data/spec/rubyspec/core/false/or_spec.rb +0 -11
- data/spec/rubyspec/core/false/to_s_spec.rb +0 -7
- data/spec/rubyspec/core/false/xor_spec.rb +0 -11
- data/spec/rubyspec/core/hash/allocate_spec.rb +0 -13
- data/spec/rubyspec/core/hash/assoc_spec.rb +0 -25
- data/spec/rubyspec/core/hash/clear_spec.rb +0 -19
- data/spec/rubyspec/core/hash/clone_spec.rb +0 -10
- data/spec/rubyspec/core/hash/constructor_spec.rb +0 -13
- data/spec/rubyspec/core/hash/default_proc_spec.rb +0 -20
- data/spec/rubyspec/core/hash/default_spec.rb +0 -17
- data/spec/rubyspec/core/hash/delete_if_spec.rb +0 -13
- data/spec/rubyspec/core/hash/delete_spec.rb +0 -11
- data/spec/rubyspec/core/hash/dup_spec.rb +0 -10
- data/spec/rubyspec/core/hash/each_key_spec.rb +0 -15
- data/spec/rubyspec/core/hash/each_pair_spec.rb +0 -30
- data/spec/rubyspec/core/hash/each_spec.rb +0 -36
- data/spec/rubyspec/core/hash/each_value_spec.rb +0 -15
- data/spec/rubyspec/core/hash/element_reference_spec.rb +0 -41
- data/spec/rubyspec/core/hash/element_set_spec.rb +0 -7
- data/spec/rubyspec/core/hash/empty_spec.rb +0 -10
- data/spec/rubyspec/core/hash/fetch_spec.rb +0 -24
- data/spec/rubyspec/core/hash/flatten_spec.rb +0 -46
- data/spec/rubyspec/core/hash/has_key_spec.rb +0 -24
- data/spec/rubyspec/core/hash/has_value_spec.rb +0 -12
- data/spec/rubyspec/core/hash/include_spec.rb +0 -24
- data/spec/rubyspec/core/hash/index_spec.rb +0 -13
- data/spec/rubyspec/core/hash/indexes_spec.rb +0 -9
- data/spec/rubyspec/core/hash/indices_spec.rb +0 -9
- data/spec/rubyspec/core/hash/invert_spec.rb +0 -12
- data/spec/rubyspec/core/hash/keep_if_spec.rb +0 -18
- data/spec/rubyspec/core/hash/key_spec.rb +0 -24
- data/spec/rubyspec/core/hash/keys_spec.rb +0 -10
- data/spec/rubyspec/core/hash/length_spec.rb +0 -10
- data/spec/rubyspec/core/hash/member_spec.rb +0 -24
- data/spec/rubyspec/core/hash/merge_spec.rb +0 -37
- data/spec/rubyspec/core/hash/new_spec.rb +0 -19
- data/spec/rubyspec/core/hash/rassoc_spec.rb +0 -34
- data/spec/rubyspec/core/hash/reject_spec.rb +0 -18
- data/spec/rubyspec/core/hash/replace_spec.rb +0 -7
- data/spec/rubyspec/core/hash/select_spec.rb +0 -52
- data/spec/rubyspec/core/hash/shift_spec.rb +0 -19
- data/spec/rubyspec/core/hash/size_spec.rb +0 -10
- data/spec/rubyspec/core/hash/to_a_spec.rb +0 -13
- data/spec/rubyspec/core/hash/to_json_spec.rb +0 -11
- data/spec/rubyspec/core/hash/update_spec.rb +0 -17
- data/spec/rubyspec/core/hash/value_spec.rb +0 -12
- data/spec/rubyspec/core/hash/values_at_spec.rb +0 -9
- data/spec/rubyspec/core/hash/values_spec.rb +0 -7
- data/spec/rubyspec/core/kernel/eql_spec.rb +0 -15
- data/spec/rubyspec/core/kernel/equal_spec.rb +0 -12
- data/spec/rubyspec/core/kernel/tap_spec.rb +0 -10
- data/spec/rubyspec/core/kernel/to_s_spec.rb +0 -5
- data/spec/rubyspec/core/matchdata/to_a_spec.rb +0 -5
- data/spec/rubyspec/core/nil/and_spec.rb +0 -11
- data/spec/rubyspec/core/nil/dup_spec.rb +0 -7
- data/spec/rubyspec/core/nil/inspect_spec.rb +0 -7
- data/spec/rubyspec/core/nil/nil_spec.rb +0 -7
- data/spec/rubyspec/core/nil/or_spec.rb +0 -11
- data/spec/rubyspec/core/nil/to_a_spec.rb +0 -7
- data/spec/rubyspec/core/nil/to_f_spec.rb +0 -11
- data/spec/rubyspec/core/nil/to_h_spec.rb +0 -10
- data/spec/rubyspec/core/nil/to_i_spec.rb +0 -11
- data/spec/rubyspec/core/nil/to_s_spec.rb +0 -7
- data/spec/rubyspec/core/nil/xor_spec.rb +0 -11
- data/spec/rubyspec/core/numeric/to_s_spec.rb +0 -8
- data/spec/rubyspec/core/range/begin_spec.rb +0 -9
- data/spec/rubyspec/core/range/case_compare_spec.rb +0 -15
- data/spec/rubyspec/core/range/end_spec.rb +0 -9
- data/spec/rubyspec/core/regexp/match_spec.rb +0 -95
- data/spec/rubyspec/core/string/capitalize_spec.rb +0 -10
- data/spec/rubyspec/core/string/casecmp_spec.rb +0 -16
- data/spec/rubyspec/core/string/center_spec.rb +0 -49
- data/spec/rubyspec/core/string/chomp_spec.rb +0 -48
- data/spec/rubyspec/core/string/downcase_spec.rb +0 -6
- data/spec/rubyspec/core/string/empty_spec.rb +0 -7
- data/spec/rubyspec/core/string/end_with_spec.rb +0 -16
- data/spec/rubyspec/core/string/include_spec.rb +0 -6
- data/spec/rubyspec/core/string/index_spec.rb +0 -405
- data/spec/rubyspec/core/string/intern_spec.rb +0 -9
- data/spec/rubyspec/core/string/length_spec.rb +0 -9
- data/spec/rubyspec/core/string/reverse_spec.rb +0 -7
- data/spec/rubyspec/core/string/size_spec.rb +0 -9
- data/spec/rubyspec/core/string/start_with_spec.rb +0 -12
- data/spec/rubyspec/core/string/swapcase_spec.rb +0 -13
- data/spec/rubyspec/core/string/to_a_spec.rb +0 -9
- data/spec/rubyspec/core/string/to_s_spec.rb +0 -6
- data/spec/rubyspec/core/string/to_str_spec.rb +0 -6
- data/spec/rubyspec/core/string/to_sym_spec.rb +0 -9
- data/spec/rubyspec/core/string/upcase_spec.rb +0 -6
- data/spec/rubyspec/core/struct/fixtures/classes.rb +0 -26
- data/spec/rubyspec/core/struct/initialize_spec.rb +0 -11
- data/spec/rubyspec/core/struct/new_spec.rb +0 -24
- data/spec/rubyspec/core/symbol/to_proc_spec.rb +0 -12
- data/spec/rubyspec/core/time/at_spec.rb +0 -7
- data/spec/rubyspec/core/time/day_spec.rb +0 -5
- data/spec/rubyspec/core/time/friday_spec.rb +0 -9
- data/spec/rubyspec/core/time/hour_spec.rb +0 -5
- data/spec/rubyspec/core/time/min_spec.rb +0 -5
- data/spec/rubyspec/core/time/monday_spec.rb +0 -9
- data/spec/rubyspec/core/time/month_spec.rb +0 -5
- data/spec/rubyspec/core/time/now_spec.rb +0 -5
- data/spec/rubyspec/core/time/saturday_spec.rb +0 -9
- data/spec/rubyspec/core/true/and_spec.rb +0 -11
- data/spec/rubyspec/core/true/inspect_spec.rb +0 -7
- data/spec/rubyspec/core/true/or_spec.rb +0 -11
- data/spec/rubyspec/core/true/to_s_spec.rb +0 -7
- data/spec/rubyspec/core/true/xor_spec.rb +0 -11
- data/spec/rubyspec/language/alias_spec.rb +0 -160
- data/spec/rubyspec/language/and_spec.rb +0 -66
- data/spec/rubyspec/language/array_spec.rb +0 -117
- data/spec/rubyspec/language/break_spec.rb +0 -332
- data/spec/rubyspec/language/case_spec.rb +0 -310
- data/spec/rubyspec/language/class_spec.rb +0 -190
- data/spec/rubyspec/language/class_variable_spec.rb +0 -56
- data/spec/rubyspec/language/def_spec.rb +0 -551
- data/spec/rubyspec/language/defined_spec.rb +0 -107
- data/spec/rubyspec/language/ensure_spec.rb +0 -104
- data/spec/rubyspec/language/execution_spec.rb +0 -15
- data/spec/rubyspec/language/for_spec.rb +0 -192
- data/spec/rubyspec/language/hash_spec.rb +0 -65
- data/spec/rubyspec/language/if_spec.rb +0 -356
- data/spec/rubyspec/language/literal_lambda_spec.rb +0 -1
- data/spec/rubyspec/language/loop_spec.rb +0 -67
- data/spec/rubyspec/language/metaclass_spec.rb +0 -159
- data/spec/rubyspec/language/module_spec.rb +0 -56
- data/spec/rubyspec/language/next_spec.rb +0 -469
- data/spec/rubyspec/language/not_spec.rb +0 -55
- data/spec/rubyspec/language/or_spec.rb +0 -90
- data/spec/rubyspec/language/order_spec.rb +0 -77
- data/spec/rubyspec/language/precedence_spec.rb +0 -483
- data/spec/rubyspec/language/redo_spec.rb +0 -65
- data/spec/rubyspec/language/rescue_spec.rb +0 -121
- data/spec/rubyspec/language/retry_spec.rb +0 -56
- data/spec/rubyspec/language/return_spec.rb +0 -281
- data/spec/rubyspec/language/singleton_class_spec.rb +0 -32
- data/spec/rubyspec/language/super_spec.rb +0 -284
- data/spec/rubyspec/language/undef_spec.rb +0 -16
- data/spec/rubyspec/language/unless_spec.rb +0 -45
- data/spec/rubyspec/language/until_spec.rb +0 -234
- data/spec/rubyspec/language/while_spec.rb +0 -238
- data/spec/rubyspec/language/yield_spec.rb +0 -128
- data/spec/rubyspec/library/date/new_spec.rb +0 -10
- data/spec/rubyspec/library/date/to_s_spec.rb +0 -7
- data/spec/rubyspec/library/date/today_spec.rb +0 -7
- data/spec/rubyspec/library/erb/util/html_escape_spec.rb +0 -10
- data/spec/rubyspec/library/observer/add_observer_spec.rb +0 -31
- data/spec/rubyspec/library/observer/count_observers_spec.rb +0 -33
- data/spec/rubyspec/library/observer/delete_observer_spec.rb +0 -19
- data/spec/rubyspec/library/observer/delete_observers_spec.rb +0 -19
- data/spec/rubyspec/library/observer/fixtures/classes.rb +0 -25
- data/spec/rubyspec/library/observer/notify_observers_spec.rb +0 -31
- data/spec/rubyspec/library/rbconfig/config_spec.rb +0 -47
- data/spec/rubyspec/library/singleton/clone_spec.rb +0 -8
- data/spec/rubyspec/library/singleton/dup_spec.rb +0 -8
- data/spec/rubyspec/library/singleton/fixtures/classes.rb +0 -18
- data/spec/rubyspec/library/singleton/instance_spec.rb +0 -30
- data/spec/rubyspec/library/stringscanner/element_reference_spec.rb +0 -29
- data/spec/rubyspec/library/stringscanner/pos_spec.rb +0 -20
- data/spec/rubyspec/spec_helper.rb +0 -96
- data/stdlib/fileutils.rb +0 -0
- data/stdlib/iconv.rb +0 -0
- data/stdlib/opal-browser/local_storage.rb +0 -27
- data/stdlib/opal-browser/script_loader.rb +0 -35
- data/stdlib/opal-parser.js.erb +0 -13
- data/stdlib/yaml.rb +0 -0
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
require File.expand_path('../../spec_helper', __FILE__)
|
|
2
|
-
|
|
3
|
-
describe "The not keyword" do
|
|
4
|
-
it "negates a `true' value" do
|
|
5
|
-
(not true).should be_false
|
|
6
|
-
(not 'true').should be_false
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
it "negates a `false' value" do
|
|
10
|
-
(not false).should be_true
|
|
11
|
-
(not nil).should be_true
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
it "accepts an argument" do
|
|
15
|
-
lambda do
|
|
16
|
-
not(true)
|
|
17
|
-
end.should_not raise_error(SyntaxError)
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it "returns false if the argument is true" do
|
|
21
|
-
(not(true)).should be_false
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
it "returns true if the argument is false" do
|
|
25
|
-
(not(false)).should be_true
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
it "returns true if the argument is nil" do
|
|
29
|
-
(not(nil)).should be_true
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
language_version __FILE__, "not"
|
|
34
|
-
|
|
35
|
-
describe "The `!' keyword" do
|
|
36
|
-
it "negates a `true' value" do
|
|
37
|
-
(!true).should be_false
|
|
38
|
-
(!'true').should be_false
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
it "negates a `false' value" do
|
|
42
|
-
(!false).should be_true
|
|
43
|
-
(!nil).should be_true
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
it "turns a truthful object into `true'" do
|
|
47
|
-
(!!true).should be_true
|
|
48
|
-
(!!'true').should be_true
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
it "turns a not truthful object into `false'" do
|
|
52
|
-
(!!false).should be_false
|
|
53
|
-
(!!nil).should be_false
|
|
54
|
-
end
|
|
55
|
-
end
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
require File.expand_path('../../spec_helper', __FILE__)
|
|
2
|
-
|
|
3
|
-
describe "The || operator" do
|
|
4
|
-
it "evaluates to true if any of its operands are true" do
|
|
5
|
-
if false || true || nil
|
|
6
|
-
x = true
|
|
7
|
-
end
|
|
8
|
-
x.should == true
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
it "evaluated to false if all of its operands are false" do
|
|
12
|
-
if false || nil
|
|
13
|
-
x = true
|
|
14
|
-
end
|
|
15
|
-
x.should == nil
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
it "is evaluated before assignment operators" do
|
|
19
|
-
x = nil || true
|
|
20
|
-
x.should == true
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
it "has a lower precedence than the && operator" do
|
|
24
|
-
x = 1 || false && x = 2
|
|
25
|
-
x.should == 1
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
it "treats empty expressions as nil" do
|
|
29
|
-
(() || true).should be_true
|
|
30
|
-
(() || false).should be_false
|
|
31
|
-
(true || ()).should be_true
|
|
32
|
-
(false || ()).should be_nil
|
|
33
|
-
(() || ()).should be_nil
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
it "has a higher precedence than 'break' in 'break true || false'" do
|
|
37
|
-
# see also 'break true or false' below
|
|
38
|
-
lambda { break false || true }.call.should be_true
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
it "has a higher precedence than 'next' in 'next true || false'" do
|
|
42
|
-
lambda { next false || true }.call.should be_true
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
it "has a higher precedence than 'return' in 'return true || false'" do
|
|
46
|
-
lambda { return false || true }.call.should be_true
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
describe "The or operator" do
|
|
51
|
-
it "evaluates to true if any of its operands are true" do
|
|
52
|
-
x = nil
|
|
53
|
-
if false or true
|
|
54
|
-
x = true
|
|
55
|
-
end
|
|
56
|
-
x.should == true
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
it "is evaluated after variables are assigned" do
|
|
60
|
-
x = nil or true
|
|
61
|
-
x.should == nil
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
it "has a lower precedence than the || operator" do
|
|
65
|
-
x,y = nil
|
|
66
|
-
x = true || false or y = 1
|
|
67
|
-
y.should == nil
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
it "treats empty expressions as nil" do
|
|
71
|
-
(() or true).should be_true
|
|
72
|
-
(() or false).should be_false
|
|
73
|
-
(true or ()).should be_true
|
|
74
|
-
(false or ()).should be_nil
|
|
75
|
-
(() or ()).should be_nil
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
it "has a lower precedence than 'break' in 'break true or false'" do
|
|
79
|
-
# see also 'break true || false' above
|
|
80
|
-
lambda { eval "break true or false" }.should raise_error(SyntaxError, /void value expression/)
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
it "has a lower precedence than 'next' in 'next true or false'" do
|
|
84
|
-
lambda { eval "next true or false" }.should raise_error(SyntaxError, /void value expression/)
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
it "has a lower precedence than 'return' in 'return true or false'" do
|
|
88
|
-
lambda { eval "return true or false" }.should raise_error(SyntaxError, /void value expression/)
|
|
89
|
-
end
|
|
90
|
-
end
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
require File.expand_path('../../spec_helper', __FILE__)
|
|
2
|
-
|
|
3
|
-
describe "A method call" do
|
|
4
|
-
before :each do
|
|
5
|
-
@obj = Object.new
|
|
6
|
-
def @obj.foo0(&a)
|
|
7
|
-
[a ? a.call : nil]
|
|
8
|
-
end
|
|
9
|
-
def @obj.foo1(a, &b)
|
|
10
|
-
[a, b ? b.call : nil]
|
|
11
|
-
end
|
|
12
|
-
def @obj.foo2(a, b, &c)
|
|
13
|
-
[a, b, c ? c.call : nil]
|
|
14
|
-
end
|
|
15
|
-
def @obj.foo3(a, b, c, &d)
|
|
16
|
-
[a, b, c, d ? d.call : nil]
|
|
17
|
-
end
|
|
18
|
-
def @obj.foo4(a, b, c, d, &e)
|
|
19
|
-
[a, b, c, d, e ? e.call : nil]
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
it "evaluates the receiver first" do
|
|
24
|
-
(obj = @obj).foo1(obj = nil).should == [nil, nil]
|
|
25
|
-
(obj = @obj).foo2(obj = nil, obj = nil).should == [nil, nil, nil]
|
|
26
|
-
(obj = @obj).foo3(obj = nil, obj = nil, obj = nil).should == [nil, nil, nil, nil]
|
|
27
|
-
(obj = @obj).foo4(obj = nil, obj = nil, obj = nil, obj = nil).should == [nil, nil, nil, nil, nil]
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
it "evaluates arguments after receiver" do
|
|
31
|
-
a = 0
|
|
32
|
-
# (a += 1; @obj).foo1(a).should == [1, nil]
|
|
33
|
-
# (a += 1; @obj).foo2(a, a).should == [2, 2, nil]
|
|
34
|
-
# (a += 1; @obj).foo3(a, a, a).should == [3, 3, 3, nil]
|
|
35
|
-
# (a += 1; @obj).foo4(a, a, a, a).should == [4, 4, 4, 4, nil]
|
|
36
|
-
a.should == 4
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
it "evaluates arguments left-to-right" do
|
|
40
|
-
a = 0
|
|
41
|
-
@obj.foo1(a += 1).should == [1, nil]
|
|
42
|
-
@obj.foo2(a += 1, a += 1).should == [2, 3, nil]
|
|
43
|
-
@obj.foo3(a += 1, a += 1, a += 1).should == [4, 5, 6, nil]
|
|
44
|
-
@obj.foo4(a += 1, a += 1, a += 1, a += 1).should == [7, 8, 9, 10, nil]
|
|
45
|
-
a.should == 10
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
ruby_bug "redmine #1034", "1.8" do
|
|
49
|
-
it "evaluates block pass after arguments" do
|
|
50
|
-
a = 0
|
|
51
|
-
p = proc {true}
|
|
52
|
-
# @obj.foo1(a += 1, &(a += 1; p)).should == [1, true]
|
|
53
|
-
# @obj.foo2(a += 1, a += 1, &(a += 1; p)).should == [3, 4, true]
|
|
54
|
-
# @obj.foo3(a += 1, a += 1, a += 1, &(a += 1; p)).should == [6, 7, 8, true]
|
|
55
|
-
# @obj.foo4(a += 1, a += 1, a += 1, a += 1, &(a += 1; p)).should == [10, 11, 12, 13, true]
|
|
56
|
-
a.should == 14
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
it "evaluates block pass after receiver" do
|
|
60
|
-
p1 = proc {true}
|
|
61
|
-
p2 = proc {false}
|
|
62
|
-
p1.should_not == p2
|
|
63
|
-
|
|
64
|
-
p = p1
|
|
65
|
-
# (p = p2; @obj).foo0(&p).should == [false]
|
|
66
|
-
p = p1
|
|
67
|
-
# (p = p2; @obj).foo1(1, &p).should == [1, false]
|
|
68
|
-
p = p1
|
|
69
|
-
# (p = p2; @obj).foo2(1, 1, &p).should == [1, 1, false]
|
|
70
|
-
p = p1
|
|
71
|
-
# (p = p2; @obj).foo3(1, 1, 1, &p).should == [1, 1, 1, false]
|
|
72
|
-
p = p1
|
|
73
|
-
# (p = p2; @obj).foo4(1, 1, 1, 1, &p).should == [1, 1, 1, 1, false]
|
|
74
|
-
p = p1
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
end
|
|
@@ -1,483 +0,0 @@
|
|
|
1
|
-
require File.expand_path('../../spec_helper', __FILE__)
|
|
2
|
-
|
|
3
|
-
# Specifying the behavior of operators in combination could
|
|
4
|
-
# lead to combinatorial explosion. A better way seems to be
|
|
5
|
-
# to use a technique from formal proofs that involve a set of
|
|
6
|
-
# equivalent statements. Suppose you have statements A, B, C.
|
|
7
|
-
# If they are claimed to be equivalent, this can be shown by
|
|
8
|
-
# proving that A implies B, B implies C, and C implies A.
|
|
9
|
-
# (Actually any closed circuit of implications.)
|
|
10
|
-
#
|
|
11
|
-
# Here, we can use a similar technique where we show starting
|
|
12
|
-
# at the top that each level of operator has precedence over
|
|
13
|
-
# the level below (as well as showing associativity within
|
|
14
|
-
# the precedence level).
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
# Excerpted from 'Programming Ruby: The Pragmatic Programmer's Guide'
|
|
18
|
-
# Second Edition by Dave Thomas, Chad Fowler, and Andy Hunt, page 324
|
|
19
|
-
|
|
20
|
-
# Table 22.4. Ruby operators (high to low precedence)
|
|
21
|
-
# Method Operator Description
|
|
22
|
-
# -----------------------------------------------------------------------
|
|
23
|
-
# :: .
|
|
24
|
-
# x* [ ] [ ]= Element reference, element set
|
|
25
|
-
# x ** Exponentiation
|
|
26
|
-
# x ! ~ + - Not, complement, unary plus and minus
|
|
27
|
-
# (method names for the last two are +@ and -@)
|
|
28
|
-
# x * / % Multiply, divide, and modulo
|
|
29
|
-
# x + - Plus and minus
|
|
30
|
-
# x >> << Right and left shift
|
|
31
|
-
# x & “And” (bitwise for integers)
|
|
32
|
-
# x ^ | Exclusive “or” and regular “or” (bitwise for integers)
|
|
33
|
-
# x <= < > >= Comparison operators
|
|
34
|
-
# x <=> == === != =~ !~ Equality and pattern match operators (!=
|
|
35
|
-
# and !~ may not be defined as methods)
|
|
36
|
-
# && Logical “and”
|
|
37
|
-
# || Logical “or”
|
|
38
|
-
# .. ... Range (inclusive and exclusive)
|
|
39
|
-
# ? : Ternary if-then-else
|
|
40
|
-
# = %= /= -= += |= &= Assignment
|
|
41
|
-
# >>= <<= *= &&= ||= **=
|
|
42
|
-
# defined? Check if symbol defined
|
|
43
|
-
# not Logical negation
|
|
44
|
-
# or and Logical composition
|
|
45
|
-
# if unless while until Expression modifiers
|
|
46
|
-
# begin/end Block expression
|
|
47
|
-
# -----------------------------------------------------------------------
|
|
48
|
-
|
|
49
|
-
# * Operators marked with 'x' in the Method column are implemented as methods
|
|
50
|
-
# and can be overridden (except != and !~ as noted). (But see the specs
|
|
51
|
-
# below for implementations that define != and !~ as methods.)
|
|
52
|
-
|
|
53
|
-
# ** These are not included in the excerpted table but are shown here for
|
|
54
|
-
# completeness.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
# -----------------------------------------------------------------------
|
|
58
|
-
# It seems that this table is not correct as of MRI 1.8.6
|
|
59
|
-
# The correct table derived from MRI's parse.y is as follows:
|
|
60
|
-
#
|
|
61
|
-
# Operator Assoc Description
|
|
62
|
-
#---------------------------------------------------------------
|
|
63
|
-
# ! ~ + > Not, complement, unary plus
|
|
64
|
-
# ** > Exponentiation
|
|
65
|
-
# - > Unary minus
|
|
66
|
-
# * / % < Multiply, divide, and modulo
|
|
67
|
-
# + - < Plus and minus
|
|
68
|
-
# >> << < Right and left shift
|
|
69
|
-
# & < “And” (bitwise for integers)
|
|
70
|
-
# ^ | < Exclusive “or” and regular “or” (bitwise for integers)
|
|
71
|
-
# <= < > >= < Comparison operators
|
|
72
|
-
# <=> == === != =~ !~ no Equality and pattern match operators (!=
|
|
73
|
-
# and !~ may not be defined as methods)
|
|
74
|
-
# && < Logical “and”
|
|
75
|
-
# || < Logical “or”
|
|
76
|
-
# .. ... no Range (inclusive and exclusive)
|
|
77
|
-
# ? : > Ternary if-then-else
|
|
78
|
-
# rescue < Rescue modifier
|
|
79
|
-
# = %= /= -= += |= &= > Assignment
|
|
80
|
-
# >>= <<= *= &&= ||= **=
|
|
81
|
-
# defined? no Check if symbol defined
|
|
82
|
-
# not > Logical negation
|
|
83
|
-
# or and < Logical composition
|
|
84
|
-
# if unless while until no Expression modifiers
|
|
85
|
-
# -----------------------------------------------------------------------
|
|
86
|
-
#
|
|
87
|
-
# [] and []= seem to fall out of here, as well as begin/end
|
|
88
|
-
#
|
|
89
|
-
|
|
90
|
-
# TODO: Resolve these two tables with actual specs. As the comment at the
|
|
91
|
-
# top suggests, these specs need to be reorganized into a single describe
|
|
92
|
-
# block for each operator. The describe block should include an example
|
|
93
|
-
# for associativity (if relevant), an example for any short circuit behavior
|
|
94
|
-
# (e.g. &&, ||, etc.) and an example block for each operator over which the
|
|
95
|
-
# instant operator has immediately higher precedence.
|
|
96
|
-
|
|
97
|
-
describe "Operators" do
|
|
98
|
-
it "! ~ + is right-associative" do
|
|
99
|
-
(!!true).should == true
|
|
100
|
-
(~~0).should == 0
|
|
101
|
-
(++2).should == 2
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
ruby_version_is "" ... "1.9" do
|
|
105
|
-
it "! ~ + have a higher precedence than **" do
|
|
106
|
-
class FalseClass; def **(a); 1000; end; end
|
|
107
|
-
(!0**2).should == 1000
|
|
108
|
-
class FalseClass; undef_method :**; end
|
|
109
|
-
|
|
110
|
-
class UnaryPlusTest; def +@; 50; end; end
|
|
111
|
-
a = UnaryPlusTest.new
|
|
112
|
-
(+a**2).should == 2500
|
|
113
|
-
|
|
114
|
-
(~0**2).should == 1
|
|
115
|
-
end
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
it "** is right-associative" do
|
|
119
|
-
(2**2**3).should == 256
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
it "** has higher precedence than unary minus" do
|
|
123
|
-
(-2**2).should == -4
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
it "unary minus is right-associative" do
|
|
127
|
-
(--2).should == 2
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
it "unary minus has higher precedence than * / %" do
|
|
131
|
-
class UnaryMinusTest; def -@; 50; end; end
|
|
132
|
-
b = UnaryMinusTest.new
|
|
133
|
-
|
|
134
|
-
(-b * 5).should == 250
|
|
135
|
-
(-b / 5).should == 10
|
|
136
|
-
(-b % 7).should == 1
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
it "* / % are left-associative" do
|
|
140
|
-
(2*1/2).should == (2*1)/2
|
|
141
|
-
# Guard against the Mathn library
|
|
142
|
-
# TODO: Make these specs not rely on specific behaviour / result values
|
|
143
|
-
# by using mocks.
|
|
144
|
-
conflicts_with :Prime do
|
|
145
|
-
(2*1/2).should_not == 2*(1/2)
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
(10/7/5).should == (10/7)/5
|
|
149
|
-
(10/7/5).should_not == 10/(7/5)
|
|
150
|
-
|
|
151
|
-
(101 % 55 % 7).should == (101 % 55) % 7
|
|
152
|
-
(101 % 55 % 7).should_not == 101 % (55 % 7)
|
|
153
|
-
|
|
154
|
-
(50*20/7%42).should == ((50*20)/7)%42
|
|
155
|
-
(50*20/7%42).should_not == 50*(20/(7%42))
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
it "* / % have higher precedence than + -" do
|
|
159
|
-
(2+2*2).should == 6
|
|
160
|
-
(1+10/5).should == 3
|
|
161
|
-
(2+10%5).should == 2
|
|
162
|
-
|
|
163
|
-
(2-2*2).should == -2
|
|
164
|
-
(1-10/5).should == -1
|
|
165
|
-
(10-10%4).should == 8
|
|
166
|
-
end
|
|
167
|
-
|
|
168
|
-
it "+ - are left-associative" do
|
|
169
|
-
(2-3-4).should == -5
|
|
170
|
-
(4-3+2).should == 3
|
|
171
|
-
|
|
172
|
-
class BinaryPlusTest < String; alias_method :plus, :+; def +(a); plus(a) + "!"; end; end
|
|
173
|
-
s = BinaryPlusTest.new("a")
|
|
174
|
-
|
|
175
|
-
(s+s+s).should == (s+s)+s
|
|
176
|
-
(s+s+s).should_not == s+(s+s)
|
|
177
|
-
end
|
|
178
|
-
|
|
179
|
-
it "+ - have higher precedence than >> <<" do
|
|
180
|
-
(2<<1+2).should == 16
|
|
181
|
-
(8>>1+2).should == 1
|
|
182
|
-
(4<<1-3).should == 1
|
|
183
|
-
(2>>1-3).should == 8
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
it ">> << are left-associative" do
|
|
187
|
-
(1 << 2 << 3).should == 32
|
|
188
|
-
(10 >> 1 >> 1).should == 2
|
|
189
|
-
(10 << 4 >> 1).should == 80
|
|
190
|
-
end
|
|
191
|
-
|
|
192
|
-
it ">> << have higher precedence than &" do
|
|
193
|
-
(4 & 2 << 1).should == 4
|
|
194
|
-
(2 & 4 >> 1).should == 2
|
|
195
|
-
end
|
|
196
|
-
|
|
197
|
-
it "& is left-associative" do
|
|
198
|
-
class BitwiseAndTest; def &(a); a+1; end; end
|
|
199
|
-
c = BitwiseAndTest.new
|
|
200
|
-
|
|
201
|
-
(c & 5 & 2).should == (c & 5) & 2
|
|
202
|
-
(c & 5 & 2).should_not == c & (5 & 2)
|
|
203
|
-
end
|
|
204
|
-
|
|
205
|
-
it "& has higher precedence than ^ |" do
|
|
206
|
-
(8 ^ 16 & 16).should == 24
|
|
207
|
-
(8 | 16 & 16).should == 24
|
|
208
|
-
end
|
|
209
|
-
|
|
210
|
-
it "^ | are left-associative" do
|
|
211
|
-
class OrAndXorTest; def ^(a); a+10; end; def |(a); a-10; end; end
|
|
212
|
-
d = OrAndXorTest.new
|
|
213
|
-
|
|
214
|
-
(d ^ 13 ^ 16).should == (d ^ 13) ^ 16
|
|
215
|
-
(d ^ 13 ^ 16).should_not == d ^ (13 ^ 16)
|
|
216
|
-
|
|
217
|
-
(d | 13 | 4).should == (d | 13) | 4
|
|
218
|
-
(d | 13 | 4).should_not == d | (13 | 4)
|
|
219
|
-
end
|
|
220
|
-
|
|
221
|
-
it "^ | have higher precedence than <= < > >=" do
|
|
222
|
-
(10 <= 7 ^ 7).should == false
|
|
223
|
-
(10 < 7 ^ 7).should == false
|
|
224
|
-
(10 > 7 ^ 7).should == true
|
|
225
|
-
(10 >= 7 ^ 7).should == true
|
|
226
|
-
(10 <= 7 | 7).should == false
|
|
227
|
-
(10 < 7 | 7).should == false
|
|
228
|
-
(10 > 7 | 7).should == true
|
|
229
|
-
(10 >= 7 | 7).should == true
|
|
230
|
-
end
|
|
231
|
-
|
|
232
|
-
it "<= < > >= are left-associative" do
|
|
233
|
-
class ComparisonTest
|
|
234
|
-
def <=(a); 0; end;
|
|
235
|
-
def <(a); 0; end;
|
|
236
|
-
def >(a); 0; end;
|
|
237
|
-
def >=(a); 0; end;
|
|
238
|
-
end
|
|
239
|
-
|
|
240
|
-
e = ComparisonTest.new
|
|
241
|
-
|
|
242
|
-
(e <= 0 <= 1).should == (e <= 0) <= 1
|
|
243
|
-
(e <= 0 <= 1).should_not == e <= (0 <= 1)
|
|
244
|
-
|
|
245
|
-
(e < 0 < 1).should == (e < 0) < 1
|
|
246
|
-
(e < 0 < 1).should_not == e < (0 < 1)
|
|
247
|
-
|
|
248
|
-
(e >= 0 >= 1).should == (e >= 0) >= 1
|
|
249
|
-
(e >= 0 >= 1).should_not == e >= (0 >= 1)
|
|
250
|
-
|
|
251
|
-
(e > 0 > 1).should == (e > 0) > 1
|
|
252
|
-
(e > 0 > 1).should_not == e > (0 > 1)
|
|
253
|
-
end
|
|
254
|
-
|
|
255
|
-
ruby_version_is "" ... "1.9" do
|
|
256
|
-
it "<= < > >= have higher precedence than <=> == === != =~ !~" do
|
|
257
|
-
(1 <=> 5 < 1).should == nil
|
|
258
|
-
(1 <=> 5 <= 1).should == nil
|
|
259
|
-
(1 <=> 5 > 1).should == nil
|
|
260
|
-
(1 <=> 5 >= 1).should == nil
|
|
261
|
-
|
|
262
|
-
(1 == 5 < 1).should == false
|
|
263
|
-
(1 == 5 <= 1).should == false
|
|
264
|
-
(1 == 5 > 1).should == false
|
|
265
|
-
(1 == 5 >= 1).should == false
|
|
266
|
-
|
|
267
|
-
(1 === 5 < 1).should == false
|
|
268
|
-
(1 === 5 <= 1).should == false
|
|
269
|
-
(1 === 5 > 1).should == false
|
|
270
|
-
(1 === 5 >= 1).should == false
|
|
271
|
-
|
|
272
|
-
(1 != 5 < 1).should == true
|
|
273
|
-
(1 != 5 <= 1).should == true
|
|
274
|
-
(1 != 5 > 1).should == true
|
|
275
|
-
(1 != 5 >= 1).should == true
|
|
276
|
-
|
|
277
|
-
(1 =~ 5 < 1).should == false
|
|
278
|
-
(1 =~ 5 <= 1).should == false
|
|
279
|
-
(1 =~ 5 > 1).should == false
|
|
280
|
-
(1 =~ 5 >= 1).should == false
|
|
281
|
-
|
|
282
|
-
(1 !~ 5 < 1).should == true
|
|
283
|
-
(1 !~ 5 <= 1).should == true
|
|
284
|
-
(1 !~ 5 > 1).should == true
|
|
285
|
-
(1 !~ 5 >= 1).should == true
|
|
286
|
-
end
|
|
287
|
-
end
|
|
288
|
-
|
|
289
|
-
it "<=> == === != =~ !~ are non-associative" do
|
|
290
|
-
lambda { eval("1 <=> 2 <=> 3") }.should raise_error(SyntaxError)
|
|
291
|
-
lambda { eval("1 == 2 == 3") }.should raise_error(SyntaxError)
|
|
292
|
-
lambda { eval("1 === 2 === 3") }.should raise_error(SyntaxError)
|
|
293
|
-
lambda { eval("1 != 2 != 3") }.should raise_error(SyntaxError)
|
|
294
|
-
lambda { eval("1 =~ 2 =~ 3") }.should raise_error(SyntaxError)
|
|
295
|
-
lambda { eval("1 !~ 2 !~ 3") }.should raise_error(SyntaxError)
|
|
296
|
-
end
|
|
297
|
-
|
|
298
|
-
it "<=> == === != =~ !~ have higher precedence than &&" do
|
|
299
|
-
(false && 2 <=> 3).should == false
|
|
300
|
-
(false && 3 == false).should == false
|
|
301
|
-
(false && 3 === false).should == false
|
|
302
|
-
(false && 3 != true).should == false
|
|
303
|
-
|
|
304
|
-
class FalseClass; def =~(o); o == false; end; end
|
|
305
|
-
(false && true =~ false).should == (false && (true =~ false))
|
|
306
|
-
(false && true =~ false).should_not == ((false && true) =~ false)
|
|
307
|
-
class FalseClass; undef_method :=~; end
|
|
308
|
-
|
|
309
|
-
(false && true !~ true).should == false
|
|
310
|
-
end
|
|
311
|
-
|
|
312
|
-
# XXX: figure out how to test it
|
|
313
|
-
# (a && b) && c equals to a && (b && c) for all a,b,c values I can imagine so far
|
|
314
|
-
it "&& is left-associative"
|
|
315
|
-
|
|
316
|
-
it "&& has higher precedence than ||" do
|
|
317
|
-
(true || false && false).should == true
|
|
318
|
-
end
|
|
319
|
-
|
|
320
|
-
# XXX: figure out how to test it
|
|
321
|
-
it "|| is left-associative"
|
|
322
|
-
|
|
323
|
-
it "|| has higher precedence than .. ..." do
|
|
324
|
-
(1..false||10).should == (1..10)
|
|
325
|
-
(1...false||10).should == (1...10)
|
|
326
|
-
end
|
|
327
|
-
|
|
328
|
-
it ".. ... are non-associative" do
|
|
329
|
-
lambda { eval("1..2..3") }.should raise_error(SyntaxError)
|
|
330
|
-
lambda { eval("1...2...3") }.should raise_error(SyntaxError)
|
|
331
|
-
end
|
|
332
|
-
|
|
333
|
-
# XXX: this is commented now due to a bug in compiler, which cannot
|
|
334
|
-
# distinguish between range and flip-flop operator so far. zenspider is
|
|
335
|
-
# currently working on a new lexer, which will be able to do that.
|
|
336
|
-
# As soon as it's done, these piece should be reenabled.
|
|
337
|
-
#
|
|
338
|
-
# it ".. ... have higher precedence than ? :" do
|
|
339
|
-
# (1..2 ? 3 : 4).should == 3
|
|
340
|
-
# (1...2 ? 3 : 4).should == 3
|
|
341
|
-
# end
|
|
342
|
-
|
|
343
|
-
it "? : is right-associative" do
|
|
344
|
-
(true ? 2 : 3 ? 4 : 5).should == 2
|
|
345
|
-
end
|
|
346
|
-
|
|
347
|
-
def oops; raise end
|
|
348
|
-
|
|
349
|
-
it "? : has higher precedence than rescue" do
|
|
350
|
-
|
|
351
|
-
(true ? oops : 0 rescue 10).should == 10
|
|
352
|
-
end
|
|
353
|
-
|
|
354
|
-
# XXX: figure how to test it (problem similar to || associativity)
|
|
355
|
-
it "rescue is left-associative"
|
|
356
|
-
|
|
357
|
-
it "rescue has higher precedence than =" do
|
|
358
|
-
# a = oops rescue 10
|
|
359
|
-
a.should == 10
|
|
360
|
-
|
|
361
|
-
# rescue doesn't have the same sense for %= /= and friends
|
|
362
|
-
end
|
|
363
|
-
|
|
364
|
-
it "= %= /= -= += |= &= >>= <<= *= &&= ||= **= are right-associative" do
|
|
365
|
-
# a = b = 10
|
|
366
|
-
# a.should == 10
|
|
367
|
-
# b.should == 10
|
|
368
|
-
|
|
369
|
-
# a = b = 10
|
|
370
|
-
# a %= b %= 3
|
|
371
|
-
# a.should == 0
|
|
372
|
-
# b.should == 1
|
|
373
|
-
|
|
374
|
-
# a = b = 10
|
|
375
|
-
# a /= b /= 2
|
|
376
|
-
# a.should == 2
|
|
377
|
-
# b.should == 5
|
|
378
|
-
|
|
379
|
-
# a = b = 10
|
|
380
|
-
# a -= b -= 2
|
|
381
|
-
# a.should == 2
|
|
382
|
-
# b.should == 8
|
|
383
|
-
|
|
384
|
-
# a = b = 10
|
|
385
|
-
# a += b += 2
|
|
386
|
-
# a.should == 22
|
|
387
|
-
# b.should == 12
|
|
388
|
-
|
|
389
|
-
# a,b = 32,64
|
|
390
|
-
# a |= b |= 2
|
|
391
|
-
# a.should == 98
|
|
392
|
-
# b.should == 66
|
|
393
|
-
|
|
394
|
-
# a,b = 25,13
|
|
395
|
-
# a &= b &= 7
|
|
396
|
-
# a.should == 1
|
|
397
|
-
# b.should == 5
|
|
398
|
-
|
|
399
|
-
# a,b=8,2
|
|
400
|
-
# a >>= b >>= 1
|
|
401
|
-
# a.should == 4
|
|
402
|
-
# b.should == 1
|
|
403
|
-
|
|
404
|
-
# a,b=8,2
|
|
405
|
-
# a <<= b <<= 1
|
|
406
|
-
# a.should == 128
|
|
407
|
-
# b.should == 4
|
|
408
|
-
|
|
409
|
-
# a,b=8,2
|
|
410
|
-
# a *= b *= 2
|
|
411
|
-
# a.should == 32
|
|
412
|
-
# b.should == 4
|
|
413
|
-
|
|
414
|
-
# a,b=10,20
|
|
415
|
-
# a &&= b &&= false
|
|
416
|
-
# a.should == false
|
|
417
|
-
# b.should == false
|
|
418
|
-
|
|
419
|
-
# a,b=nil,nil
|
|
420
|
-
# a ||= b ||= 10
|
|
421
|
-
# a.should == 10
|
|
422
|
-
# b.should == 10
|
|
423
|
-
|
|
424
|
-
# a,b=2,3
|
|
425
|
-
# a **= b **= 2
|
|
426
|
-
# a.should == 512
|
|
427
|
-
# b.should == 9
|
|
428
|
-
end
|
|
429
|
-
|
|
430
|
-
it "= %= /= -= += |= &= >>= <<= *= &&= ||= **= have higher precedence than defined? operator" do
|
|
431
|
-
# (defined? a = 10).should == "assignment"
|
|
432
|
-
# (defined? a %= 10).should == "assignment"
|
|
433
|
-
# (defined? a /= 10).should == "assignment"
|
|
434
|
-
# (defined? a -= 10).should == "assignment"
|
|
435
|
-
# (defined? a += 10).should == "assignment"
|
|
436
|
-
# (defined? a |= 10).should == "assignment"
|
|
437
|
-
# (defined? a &= 10).should == "assignment"
|
|
438
|
-
# (defined? a >>= 10).should == "assignment"
|
|
439
|
-
# (defined? a <<= 10).should == "assignment"
|
|
440
|
-
# (defined? a *= 10).should == "assignment"
|
|
441
|
-
# (defined? a &&= 10).should == "assignment"
|
|
442
|
-
# (defined? a ||= 10).should == "assignment"
|
|
443
|
-
# (defined? a **= 10).should == "assignment"
|
|
444
|
-
end
|
|
445
|
-
|
|
446
|
-
# XXX: figure out how to test it
|
|
447
|
-
it "defined? is non-associative"
|
|
448
|
-
|
|
449
|
-
it "defined? has higher precedence than not" do
|
|
450
|
-
# does it have sense?
|
|
451
|
-
(not defined? qqq).should == true
|
|
452
|
-
end
|
|
453
|
-
|
|
454
|
-
it "not is right-associative" do
|
|
455
|
-
(not not false).should == false
|
|
456
|
-
(not not 10).should == true
|
|
457
|
-
end
|
|
458
|
-
|
|
459
|
-
it "not has higher precedence than or/and" do
|
|
460
|
-
(not false and false).should == false
|
|
461
|
-
(not false or true).should == true
|
|
462
|
-
end
|
|
463
|
-
|
|
464
|
-
# XXX: figure out how to test it
|
|
465
|
-
it "or/and are left-associative"
|
|
466
|
-
|
|
467
|
-
it "or/and have higher precedence than if unless while until modifiers" do
|
|
468
|
-
(1 if 2 and 3).should == 1
|
|
469
|
-
(1 if 2 or 3).should == 1
|
|
470
|
-
|
|
471
|
-
(1 unless false and true).should == 1
|
|
472
|
-
(1 unless false or false).should == 1
|
|
473
|
-
|
|
474
|
-
(1 while true and false).should == nil # would hang upon error
|
|
475
|
-
(1 while false or false).should == nil
|
|
476
|
-
|
|
477
|
-
((raise until true and false) rescue 10).should == 10
|
|
478
|
-
(1 until false or true).should == nil # would hang upon error
|
|
479
|
-
end
|
|
480
|
-
|
|
481
|
-
# XXX: it seems to me they are right-associative
|
|
482
|
-
it "if unless while until are non-associative"
|
|
483
|
-
end
|