opal 0.4.4 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,11 +0,0 @@
|
|
1
|
-
require File.expand_path('../../../spec_helper', __FILE__)
|
2
|
-
|
3
|
-
describe "NilClass#|" do
|
4
|
-
it "returns false if other is nil or false, otherwise true" do
|
5
|
-
(nil | nil).should == false
|
6
|
-
(nil | true).should == true
|
7
|
-
(nil | false).should == false
|
8
|
-
(nil | "").should == true
|
9
|
-
(nil | mock('x')).should == true
|
10
|
-
end
|
11
|
-
end
|
@@ -1,11 +0,0 @@
|
|
1
|
-
require File.expand_path('../../../spec_helper', __FILE__)
|
2
|
-
|
3
|
-
describe "NilClass#^" do
|
4
|
-
it "returns false if other is nil or false, otherwise true" do
|
5
|
-
(nil ^ nil).should == false
|
6
|
-
(nil ^ true).should == true
|
7
|
-
(nil ^ false).should == false
|
8
|
-
(nil ^ "").should == true
|
9
|
-
(nil ^ mock('x')).should == true
|
10
|
-
end
|
11
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
describe "Range#===" do
|
2
|
-
it "returns true if other is an element of self" do
|
3
|
-
((0..5) === 2).should == true
|
4
|
-
((-5..5) === 0).should == true
|
5
|
-
((-1...1) === 10.5).should == false
|
6
|
-
((-10..-2) === -2.5).should == true
|
7
|
-
(('C'..'X') === 'M').should == true
|
8
|
-
(('C'..'X') === 'A').should == false
|
9
|
-
(('B'...'W') === 'W').should == false
|
10
|
-
(('B'...'W') === 'Q').should == true
|
11
|
-
((0.5..2.4) === 2).should == true
|
12
|
-
((0.5..2.4) === 2.5).should == false
|
13
|
-
((0.5...2.4) === 2.4).should == false
|
14
|
-
end
|
15
|
-
end
|
@@ -1,95 +0,0 @@
|
|
1
|
-
describe "Regexp#=~ on a successful match" do
|
2
|
-
it "returns the index of the first character of the matching region" do
|
3
|
-
(/(.)(.)(.)/ =~ "abc").should == 0
|
4
|
-
end
|
5
|
-
end
|
6
|
-
|
7
|
-
describe "Regexp#match on a successful match" do
|
8
|
-
it "returns a MatchData object" do
|
9
|
-
/(.)(.)(.)/.match("abc").should be_kind_of(MatchData)
|
10
|
-
end
|
11
|
-
|
12
|
-
it "resets $~ if passed nil" do
|
13
|
-
# set $~
|
14
|
-
/./.match("a")
|
15
|
-
$~.should be_kind_of(MatchData)
|
16
|
-
|
17
|
-
/1/.match(nil)
|
18
|
-
$~.should be_nil
|
19
|
-
end
|
20
|
-
|
21
|
-
it "returns a MatchData object that exposes pre_match and post_match strings for inline regexp" do
|
22
|
-
re = /note: /i
|
23
|
-
result = re.match('preamble NOTE: This is just a test.')
|
24
|
-
result.pre_match.should == 'preamble '
|
25
|
-
result.post_match.should == 'This is just a test.'
|
26
|
-
end
|
27
|
-
|
28
|
-
it "returns a MatchData object that exposes pre_match and post_match strings for constructed regexp" do
|
29
|
-
re = Regexp.new(/note: /i)
|
30
|
-
result = re.match('preamble NOTE: This is just a test.')
|
31
|
-
result.pre_match.should == 'preamble '
|
32
|
-
result.post_match.should == 'This is just a test.'
|
33
|
-
end
|
34
|
-
|
35
|
-
it "sets $` and $' variables on match" do
|
36
|
-
re = /note: /i
|
37
|
-
re.match('preamble NOTE: This is just a test.')
|
38
|
-
$`.should == 'preamble '
|
39
|
-
$'.should == 'This is just a test.'
|
40
|
-
end
|
41
|
-
|
42
|
-
it "resets $` and $' when no match" do
|
43
|
-
re = /note: /i
|
44
|
-
re.match('preamble NOTE: This is just a test.')
|
45
|
-
$`.should_not be_nil
|
46
|
-
$'.should_not be_nil
|
47
|
-
re.match(nil)
|
48
|
-
$`.should be_nil
|
49
|
-
$'.should be_nil
|
50
|
-
end
|
51
|
-
|
52
|
-
it "returns a MatchData object that exposes match array" do
|
53
|
-
re = /(note): (.*)/i
|
54
|
-
result = re.match('preamble NOTE: This is just a test.')
|
55
|
-
result.length.should == 3
|
56
|
-
result.size.should == 3
|
57
|
-
result.captures.should == ['NOTE', 'This is just a test.']
|
58
|
-
result.to_a.should == ['NOTE: This is just a test.', 'NOTE', 'This is just a test.']
|
59
|
-
result[1].should == ['NOTE']
|
60
|
-
result.values_at(1, -1).should == ['NOTE', 'This is just a test.']
|
61
|
-
result.values_at(-3, 0).should == [nil, 'NOTE: This is just a test.']
|
62
|
-
end
|
63
|
-
|
64
|
-
it "replaces undefined with nil in match array" do
|
65
|
-
re = /(a(b)c)?(def)/
|
66
|
-
result = re.match("def")
|
67
|
-
result.to_a.size.should == 4
|
68
|
-
result.to_a.should == ["def", nil, nil, "def"]
|
69
|
-
end
|
70
|
-
|
71
|
-
it "returns a MatchData object that exposes regexp and string" do
|
72
|
-
re = /(note): (.*)/i
|
73
|
-
result = re.match('preamble NOTE: This is just a test.')
|
74
|
-
result.string.should == 'preamble NOTE: This is just a test.'
|
75
|
-
result.regexp.to_s.should == re.to_s
|
76
|
-
end
|
77
|
-
|
78
|
-
it "returns a MatchData object that provides access to offset of 0th element only" do
|
79
|
-
re = /(note): (.*)/i
|
80
|
-
result = re.match('preamble NOTE: This is just a test.')
|
81
|
-
result.begin(0).should == 9
|
82
|
-
result.begin(1).should == 9
|
83
|
-
lambda { result.begin(2) }.should raise_error(ArgumentError)
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
describe :regexp_match do
|
88
|
-
it "returns nil if there is no match" do
|
89
|
-
/xyz/.match("abxyc").should be_nil
|
90
|
-
end
|
91
|
-
|
92
|
-
it "returns nil if the object is nil" do
|
93
|
-
/xyz/.match(nil).should be_nil
|
94
|
-
end
|
95
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
describe "String#capitalize" do
|
2
|
-
it "returns a copy of self with the first character converted to uppercase and the remainder to lowercase" do
|
3
|
-
"".capitalize.should == ""
|
4
|
-
"h".capitalize.should == "H"
|
5
|
-
"H".capitalize.should == "H"
|
6
|
-
"hello".capitalize.should == "Hello"
|
7
|
-
"HELLO".capitalize.should == "Hello"
|
8
|
-
"123ABC".capitalize.should == "123abc"
|
9
|
-
end
|
10
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
describe "String#casecmp" do
|
2
|
-
it "returns -1 when less than other" do
|
3
|
-
"a".casecmp("b").should == -1
|
4
|
-
"A".casecmp("b").should == -1
|
5
|
-
end
|
6
|
-
|
7
|
-
it "returns 0 when equal to other" do
|
8
|
-
"a".casecmp("a").should == 0
|
9
|
-
"A".casecmp("a").should == 0
|
10
|
-
end
|
11
|
-
|
12
|
-
it "returns 1 when greater than other" do
|
13
|
-
"b".casecmp("a").should == 1
|
14
|
-
"B".casecmp("a").should == 1
|
15
|
-
end
|
16
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
require File.expand_path('../../../spec_helper', __FILE__)
|
3
|
-
require File.expand_path('../fixtures/classes.rb', __FILE__)
|
4
|
-
|
5
|
-
describe "String#center with length, padding" do
|
6
|
-
it "returns a new string of specified length with self centered and padded with padstr" do
|
7
|
-
"one".center(9, '.').should == "...one..."
|
8
|
-
"hello".center(20, '123').should == "1231231hello12312312"
|
9
|
-
"middle".center(13, '-').should == "---middle----"
|
10
|
-
|
11
|
-
"".center(1, "abcd").should == "a"
|
12
|
-
"".center(2, "abcd").should == "aa"
|
13
|
-
"".center(3, "abcd").should == "aab"
|
14
|
-
"".center(4, "abcd").should == "abab"
|
15
|
-
"".center(6, "xy").should == "xyxxyx"
|
16
|
-
"".center(11, "12345").should == "12345123451"
|
17
|
-
|
18
|
-
"|".center(2, "abcd").should == "|a"
|
19
|
-
"|".center(3, "abcd").should == "a|a"
|
20
|
-
"|".center(4, "abcd").should == "a|ab"
|
21
|
-
"|".center(5, "abcd").should == "ab|ab"
|
22
|
-
"|".center(6, "xy").should == "xy|xyx"
|
23
|
-
"|".center(7, "xy").should == "xyx|xyx"
|
24
|
-
"|".center(11, "12345").should == "12345|12345"
|
25
|
-
"|".center(12, "12345").should == "12345|123451"
|
26
|
-
|
27
|
-
"||".center(3, "abcd").should == "||a"
|
28
|
-
"||".center(4, "abcd").should == "a||a"
|
29
|
-
"||".center(5, "abcd").should == "a||ab"
|
30
|
-
"||".center(6, "abcd").should == "ab||ab"
|
31
|
-
"||".center(8, "xy").should == "xyx||xyx"
|
32
|
-
"||".center(12, "12345").should == "12345||12345"
|
33
|
-
"||".center(13, "12345").should == "12345||123451"
|
34
|
-
end
|
35
|
-
|
36
|
-
it "pads with whitespace if no padstr is given" do
|
37
|
-
"two".center(5).should == " two "
|
38
|
-
"hello".center(20).should == " hello "
|
39
|
-
end
|
40
|
-
|
41
|
-
it "returns self if it's longer than or as long as the specified length" do
|
42
|
-
"".center(0).should == ""
|
43
|
-
"".center(-1).should == ""
|
44
|
-
"hello".center(4).should == "hello"
|
45
|
-
"hello".center(-1).should == "hello"
|
46
|
-
"this".center(3).should == "this"
|
47
|
-
"radiology".center(8, '-').should == "radiology"
|
48
|
-
end
|
49
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
describe "String#chomp with separator" do
|
2
|
-
it "returns a new string with the given record separator removed" do
|
3
|
-
"hello".chomp("llo").should == "he"
|
4
|
-
"hellollo".chomp("llo").should == "hello"
|
5
|
-
end
|
6
|
-
|
7
|
-
it "removes carriage return (except \\r) chars multiple times when separator is an empty string" do
|
8
|
-
"".chomp("").should == ""
|
9
|
-
"hello".chomp("").should == "hello"
|
10
|
-
"hello\n".chomp("").should == "hello"
|
11
|
-
"hello\nx".chomp("").should == "hello\nx"
|
12
|
-
"hello\r\n".chomp("").should == "hello"
|
13
|
-
"hello\r\n\r\n\n\n\r\n".chomp("").should == "hello"
|
14
|
-
|
15
|
-
"hello\r".chomp("").should == "hello\r"
|
16
|
-
"hello\n\r".chomp("").should == "hello\n\r"
|
17
|
-
"hello\r\r\r\n".chomp("").should == "hello\r\r"
|
18
|
-
end
|
19
|
-
|
20
|
-
it "removes carriage return chars(\\n, \\r, \\r\\n) when separator is \\n" do
|
21
|
-
"hello".chomp("\n").should == "hello"
|
22
|
-
"hello\n".chomp("\n").should == "hello"
|
23
|
-
"hello\r\n".chomp("\n").should == "hello"
|
24
|
-
"hello\n\r".chomp("\n").should == "hello\n"
|
25
|
-
"hello\r".chomp("\n").should == "hello"
|
26
|
-
"hello \n there".chomp("\n").should == "hello \n there"
|
27
|
-
"hello\r\n\r\n\n\n\r\n".chomp("\n").should == "hello\r\n\r\n\n\n"
|
28
|
-
|
29
|
-
"hello\n\r".chomp("\r").should == "hello\n"
|
30
|
-
"hello\n\r\n".chomp("\r\n").should == "hello\n"
|
31
|
-
end
|
32
|
-
|
33
|
-
it "removes separator character" do
|
34
|
-
"hello)".chomp(")").should == "hello"
|
35
|
-
"hello*)".chomp("*)").should == "hello"
|
36
|
-
end
|
37
|
-
|
38
|
-
it "returns self if the separator is nil" do
|
39
|
-
"hello\n\n".chomp(nil).should == "hello\n\n"
|
40
|
-
end
|
41
|
-
|
42
|
-
it "returns an empty string when called on an empty string" do
|
43
|
-
"".chomp("\n").should == ""
|
44
|
-
"".chomp("\r").should == ""
|
45
|
-
"".chomp("").should == ""
|
46
|
-
"".chomp(nil).should == ""
|
47
|
-
end
|
48
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
describe "String#end_with?" do
|
2
|
-
it "returns true only if ends with match" do
|
3
|
-
s = "hello"
|
4
|
-
s.end_with?('o').should be_true
|
5
|
-
s.end_with?('llo').should be_true
|
6
|
-
s.end_with?('ll').should be_false
|
7
|
-
end
|
8
|
-
|
9
|
-
it "returns true only if any ending match" do
|
10
|
-
"hello".end_with?('x', 'y', 'llo', 'z').should be_true
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should not return true if suffix length is 1 greater than string length" do
|
14
|
-
"-".end_with?(' +').should be_false
|
15
|
-
end
|
16
|
-
end
|
@@ -1,405 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
require File.expand_path('../../../spec_helper', __FILE__)
|
3
|
-
require File.expand_path('../fixtures/classes.rb', __FILE__)
|
4
|
-
|
5
|
-
describe "String#index" do
|
6
|
-
it "raises a TypeError if passed nil" do
|
7
|
-
lambda { "abc".index nil }.should raise_error(TypeError)
|
8
|
-
end
|
9
|
-
|
10
|
-
it "raises a TypeError if passed a boolean" do
|
11
|
-
lambda { "abc".index true }.should raise_error(TypeError)
|
12
|
-
end
|
13
|
-
|
14
|
-
not_compliant_on :opal do
|
15
|
-
it "raises a TypeError if passed a Symbol" do
|
16
|
-
lambda { "abc".index :a }.should raise_error(TypeError)
|
17
|
-
end
|
18
|
-
|
19
|
-
it "calls #to_str to convert the first argument" do
|
20
|
-
char = mock("string index char")
|
21
|
-
char.should_receive(:to_str).and_return("b")
|
22
|
-
"abc".index(char).should == 1
|
23
|
-
end
|
24
|
-
|
25
|
-
it "calls #to_int to convert the second argument" do
|
26
|
-
offset = mock("string index offset")
|
27
|
-
offset.should_receive(:to_int).and_return(1)
|
28
|
-
"abc".index("c", offset).should == 2
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
ruby_version_is ""..."1.9" do
|
33
|
-
it "does not call #to_int to convert the first argument" do
|
34
|
-
char = mock("string index char")
|
35
|
-
char.should_not_receive(:to_int)
|
36
|
-
lambda { "abc".index char }.should raise_error(TypeError)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
ruby_version_is "1.9" do
|
41
|
-
it "raises a TypeError if passed a Fixnum" do
|
42
|
-
lambda { "abc".index 97 }.should raise_error(TypeError)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
ruby_version_is ""..."1.9" do
|
48
|
-
describe "String#index with Fixnum" do
|
49
|
-
it "returns the index of the first occurrence of the given character" do
|
50
|
-
"hello".index(?e).should == 1
|
51
|
-
"hello".index(?l).should == 2
|
52
|
-
end
|
53
|
-
|
54
|
-
it "character values over 255 (256th ASCII character) always result in nil" do
|
55
|
-
# A naive implementation could try to use % 256
|
56
|
-
"hello".index(?e + 256 * 3).should == nil
|
57
|
-
end
|
58
|
-
|
59
|
-
it "negative character values always result in nil" do
|
60
|
-
# A naive implementation could try to use % 256
|
61
|
-
"hello".index(-(256 - ?e)).should == nil
|
62
|
-
end
|
63
|
-
|
64
|
-
it "starts the search at the given offset" do
|
65
|
-
"blablabla".index(?b, 0).should == 0
|
66
|
-
"blablabla".index(?b, 1).should == 3
|
67
|
-
"blablabla".index(?b, 2).should == 3
|
68
|
-
"blablabla".index(?b, 3).should == 3
|
69
|
-
"blablabla".index(?b, 4).should == 6
|
70
|
-
"blablabla".index(?b, 5).should == 6
|
71
|
-
"blablabla".index(?b, 6).should == 6
|
72
|
-
|
73
|
-
"blablabla".index(?a, 0).should == 2
|
74
|
-
"blablabla".index(?a, 2).should == 2
|
75
|
-
"blablabla".index(?a, 3).should == 5
|
76
|
-
"blablabla".index(?a, 4).should == 5
|
77
|
-
"blablabla".index(?a, 5).should == 5
|
78
|
-
"blablabla".index(?a, 6).should == 8
|
79
|
-
"blablabla".index(?a, 7).should == 8
|
80
|
-
"blablabla".index(?a, 8).should == 8
|
81
|
-
end
|
82
|
-
|
83
|
-
it "starts the search at offset + self.length if offset is negative" do
|
84
|
-
str = "blablabla"
|
85
|
-
|
86
|
-
[?a, ?b].each do |needle|
|
87
|
-
(-str.length .. -1).each do |offset|
|
88
|
-
p offset
|
89
|
-
str.index(needle, offset).should ==
|
90
|
-
str.index(needle, offset + str.length)
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
"blablabla".index(?b, -9).should == 0
|
95
|
-
end
|
96
|
-
|
97
|
-
it "returns nil if offset + self.length is < 0 for negative offsets" do
|
98
|
-
"blablabla".index(?b, -10).should == nil
|
99
|
-
"blablabla".index(?b, -20).should == nil
|
100
|
-
end
|
101
|
-
|
102
|
-
it "returns nil if the character isn't found" do
|
103
|
-
"hello".index(0).should == nil
|
104
|
-
|
105
|
-
"hello".index(?H).should == nil
|
106
|
-
"hello".index(?z).should == nil
|
107
|
-
"hello".index(?e, 2).should == nil
|
108
|
-
|
109
|
-
"blablabla".index(?b, 7).should == nil
|
110
|
-
"blablabla".index(?b, 10).should == nil
|
111
|
-
|
112
|
-
"blablabla".index(?a, 9).should == nil
|
113
|
-
"blablabla".index(?a, 20).should == nil
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
describe "String#index with String" do
|
119
|
-
it "behaves the same as String#index(char) for one-character strings" do
|
120
|
-
["blablabla", "hello cruel world...!"].each do |str|
|
121
|
-
str.split("").uniq.each do |str|
|
122
|
-
chr = str[0]
|
123
|
-
str.index(str).should == str.index(chr)
|
124
|
-
|
125
|
-
0.upto(str.size + 1) do |start|
|
126
|
-
str.index(str, start).should == str.index(chr, start)
|
127
|
-
end
|
128
|
-
|
129
|
-
(-str.size - 1).upto(-1) do |start|
|
130
|
-
str.index(str, start).should == str.index(chr, start)
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|
135
|
-
|
136
|
-
it "returns the index of the first occurrence of the given substring" do
|
137
|
-
"blablabla".index("").should == 0
|
138
|
-
"blablabla".index("b").should == 0
|
139
|
-
"blablabla".index("bla").should == 0
|
140
|
-
"blablabla".index("blabla").should == 0
|
141
|
-
"blablabla".index("blablabla").should == 0
|
142
|
-
|
143
|
-
"blablabla".index("l").should == 1
|
144
|
-
"blablabla".index("la").should == 1
|
145
|
-
"blablabla".index("labla").should == 1
|
146
|
-
"blablabla".index("lablabla").should == 1
|
147
|
-
|
148
|
-
"blablabla".index("a").should == 2
|
149
|
-
"blablabla".index("abla").should == 2
|
150
|
-
"blablabla".index("ablabla").should == 2
|
151
|
-
end
|
152
|
-
|
153
|
-
it "doesn't set $~" do
|
154
|
-
$~ = nil
|
155
|
-
|
156
|
-
'hello.'.index('ll')
|
157
|
-
$~.should == nil
|
158
|
-
end
|
159
|
-
|
160
|
-
it "ignores string subclasses" do
|
161
|
-
"blablabla".index(StringSpecs::MyString.new("bla")).should == 0
|
162
|
-
StringSpecs::MyString.new("blablabla").index("bla").should == 0
|
163
|
-
StringSpecs::MyString.new("blablabla").index(StringSpecs::MyString.new("bla")).should == 0
|
164
|
-
end
|
165
|
-
|
166
|
-
it "starts the search at the given offset" do
|
167
|
-
"blablabla".index("bl", 0).should == 0
|
168
|
-
"blablabla".index("bl", 1).should == 3
|
169
|
-
"blablabla".index("bl", 2).should == 3
|
170
|
-
"blablabla".index("bl", 3).should == 3
|
171
|
-
|
172
|
-
"blablabla".index("bla", 0).should == 0
|
173
|
-
"blablabla".index("bla", 1).should == 3
|
174
|
-
"blablabla".index("bla", 2).should == 3
|
175
|
-
"blablabla".index("bla", 3).should == 3
|
176
|
-
|
177
|
-
"blablabla".index("blab", 0).should == 0
|
178
|
-
"blablabla".index("blab", 1).should == 3
|
179
|
-
"blablabla".index("blab", 2).should == 3
|
180
|
-
"blablabla".index("blab", 3).should == 3
|
181
|
-
|
182
|
-
"blablabla".index("la", 1).should == 1
|
183
|
-
"blablabla".index("la", 2).should == 4
|
184
|
-
"blablabla".index("la", 3).should == 4
|
185
|
-
"blablabla".index("la", 4).should == 4
|
186
|
-
|
187
|
-
"blablabla".index("lab", 1).should == 1
|
188
|
-
"blablabla".index("lab", 2).should == 4
|
189
|
-
"blablabla".index("lab", 3).should == 4
|
190
|
-
"blablabla".index("lab", 4).should == 4
|
191
|
-
|
192
|
-
"blablabla".index("ab", 2).should == 2
|
193
|
-
"blablabla".index("ab", 3).should == 5
|
194
|
-
"blablabla".index("ab", 4).should == 5
|
195
|
-
"blablabla".index("ab", 5).should == 5
|
196
|
-
|
197
|
-
"blablabla".index("", 0).should == 0
|
198
|
-
"blablabla".index("", 1).should == 1
|
199
|
-
"blablabla".index("", 2).should == 2
|
200
|
-
"blablabla".index("", 7).should == 7
|
201
|
-
"blablabla".index("", 8).should == 8
|
202
|
-
"blablabla".index("", 9).should == 9
|
203
|
-
end
|
204
|
-
|
205
|
-
it "starts the search at offset + self.length if offset is negative" do
|
206
|
-
str = "blablabla"
|
207
|
-
|
208
|
-
["bl", "bla", "blab", "la", "lab", "ab", ""].each do |needle|
|
209
|
-
(-str.length .. -1).each do |offset|
|
210
|
-
str.index(needle, offset).should ==
|
211
|
-
str.index(needle, offset + str.length)
|
212
|
-
end
|
213
|
-
end
|
214
|
-
end
|
215
|
-
|
216
|
-
it "returns nil if the substring isn't found" do
|
217
|
-
"blablabla".index("B").should == nil
|
218
|
-
"blablabla".index("z").should == nil
|
219
|
-
"blablabla".index("BLA").should == nil
|
220
|
-
"blablabla".index("blablablabla").should == nil
|
221
|
-
"blablabla".index("", 10).should == nil
|
222
|
-
"blablabla".index("", 10).should == nil
|
223
|
-
|
224
|
-
"12345".index("", 6).should == nil
|
225
|
-
"hello".index("he", 1).should == nil
|
226
|
-
"hello".index("he", 2).should == nil
|
227
|
-
end
|
228
|
-
|
229
|
-
with_feature :encoding do
|
230
|
-
it "returns the character index of a multibyte character" do
|
231
|
-
"ありがとう".index("が").should == 2
|
232
|
-
end
|
233
|
-
|
234
|
-
it "returns the character index after offset" do
|
235
|
-
"われわれ".index("わ", 1).should == 2
|
236
|
-
end
|
237
|
-
|
238
|
-
it "raises an Encoding::CompatibilityError if the encodings are incompatible" do
|
239
|
-
char = "れ".encode Encoding::EUC_JP
|
240
|
-
lambda do
|
241
|
-
"あれ".index char
|
242
|
-
end.should raise_error(Encoding::CompatibilityError)
|
243
|
-
end
|
244
|
-
end
|
245
|
-
end
|
246
|
-
|
247
|
-
describe "String#index with Regexp" do
|
248
|
-
it "behaves the same as String#index(string) for escaped string regexps" do
|
249
|
-
["blablabla", "hello cruel world...!"].each do |str|
|
250
|
-
["", "b", "bla", "lab", "o c", "d."].each do |needle|
|
251
|
-
regexp = Regexp.new(Regexp.escape(needle))
|
252
|
-
str.index(regexp).should == str.index(needle)
|
253
|
-
|
254
|
-
0.upto(str.size + 1) do |start|
|
255
|
-
str.index(regexp, start).should == str.index(needle, start)
|
256
|
-
end
|
257
|
-
|
258
|
-
(-str.size - 1).upto(-1) do |start|
|
259
|
-
str.index(regexp, start).should == str.index(needle, start)
|
260
|
-
end
|
261
|
-
end
|
262
|
-
end
|
263
|
-
end
|
264
|
-
|
265
|
-
it "returns the index of the first match of regexp" do
|
266
|
-
"blablabla".index(/bla/).should == 0
|
267
|
-
"blablabla".index(/BLA/i).should == 0
|
268
|
-
|
269
|
-
"blablabla".index(/.{0}/).should == 0
|
270
|
-
"blablabla".index(/.{6}/).should == 0
|
271
|
-
"blablabla".index(/.{9}/).should == 0
|
272
|
-
|
273
|
-
"blablabla".index(/.*/).should == 0
|
274
|
-
"blablabla".index(/.+/).should == 0
|
275
|
-
|
276
|
-
"blablabla".index(/lab|b/).should == 0
|
277
|
-
|
278
|
-
not_compliant_on :opal do
|
279
|
-
"blablabla".index(/\A/).should == 0
|
280
|
-
"blablabla".index(/\Z/).should == 9
|
281
|
-
"blablabla".index(/\z/).should == 9
|
282
|
-
"blablabla\n".index(/\Z/).should == 9
|
283
|
-
"blablabla\n".index(/\z/).should == 10
|
284
|
-
end
|
285
|
-
|
286
|
-
"blablabla".index(/^/).should == 0
|
287
|
-
"\nblablabla".index(/^/).should == 0
|
288
|
-
|
289
|
-
not_compliant_on :opal do
|
290
|
-
"b\nablabla".index(/$/).should == 1
|
291
|
-
"bl\nablabla".index(/$/).should == 2
|
292
|
-
end
|
293
|
-
|
294
|
-
"blablabla".index(/.l./).should == 0
|
295
|
-
end
|
296
|
-
|
297
|
-
it "sets $~ to MatchData of match and nil when there's none" do
|
298
|
-
'hello.'.index(/.(.)/)
|
299
|
-
$~[0].should == 'he'
|
300
|
-
|
301
|
-
'hello.'.index(/not/)
|
302
|
-
$~.should == nil
|
303
|
-
end
|
304
|
-
|
305
|
-
it "starts the search at the given offset" do
|
306
|
-
"blablabla".index(/.{0}/, 5).should == 5
|
307
|
-
"blablabla".index(/.{1}/, 5).should == 5
|
308
|
-
"blablabla".index(/.{2}/, 5).should == 5
|
309
|
-
"blablabla".index(/.{3}/, 5).should == 5
|
310
|
-
"blablabla".index(/.{4}/, 5).should == 5
|
311
|
-
|
312
|
-
"blablabla".index(/.{0}/, 3).should == 3
|
313
|
-
"blablabla".index(/.{1}/, 3).should == 3
|
314
|
-
"blablabla".index(/.{2}/, 3).should == 3
|
315
|
-
"blablabla".index(/.{5}/, 3).should == 3
|
316
|
-
"blablabla".index(/.{6}/, 3).should == 3
|
317
|
-
|
318
|
-
"blablabla".index(/.l./, 0).should == 0
|
319
|
-
"blablabla".index(/.l./, 1).should == 3
|
320
|
-
"blablabla".index(/.l./, 2).should == 3
|
321
|
-
"blablabla".index(/.l./, 3).should == 3
|
322
|
-
|
323
|
-
"xblaxbla".index(/x./, 0).should == 0
|
324
|
-
"xblaxbla".index(/x./, 1).should == 4
|
325
|
-
"xblaxbla".index(/x./, 2).should == 4
|
326
|
-
|
327
|
-
not_compliant_on :opal do
|
328
|
-
"blablabla\n".index(/\Z/, 9).should == 9
|
329
|
-
end
|
330
|
-
end
|
331
|
-
|
332
|
-
it "starts the search at offset + self.length if offset is negative" do
|
333
|
-
str = "blablabla"
|
334
|
-
|
335
|
-
["bl", "bla", "blab", "la", "lab", "ab", ""].each do |needle|
|
336
|
-
(-str.length .. -1).each do |offset|
|
337
|
-
str.index(needle, offset).should ==
|
338
|
-
str.index(needle, offset + str.length)
|
339
|
-
end
|
340
|
-
end
|
341
|
-
end
|
342
|
-
|
343
|
-
it "returns nil if the substring isn't found" do
|
344
|
-
"blablabla".index(/BLA/).should == nil
|
345
|
-
|
346
|
-
"blablabla".index(/.{10}/).should == nil
|
347
|
-
"blaxbla".index(/.x/, 3).should == nil
|
348
|
-
"blaxbla".index(/..x/, 2).should == nil
|
349
|
-
end
|
350
|
-
|
351
|
-
it "returns nil if the Regexp matches the empty string and the offset is out of range" do
|
352
|
-
"ruby".index(//,12).should be_nil
|
353
|
-
end
|
354
|
-
|
355
|
-
not_compliant_on :opal do
|
356
|
-
it "supports \\G which matches at the given start offset" do
|
357
|
-
"helloYOU.".index(/\GYOU/, 5).should == 5
|
358
|
-
"helloYOU.".index(/\GYOU/).should == nil
|
359
|
-
|
360
|
-
re = /\G.+YOU/
|
361
|
-
# The # marks where \G will match.
|
362
|
-
[
|
363
|
-
["#hi!YOUall.", 0],
|
364
|
-
["h#i!YOUall.", 1],
|
365
|
-
["hi#!YOUall.", 2],
|
366
|
-
["hi!#YOUall.", nil]
|
367
|
-
].each do |spec|
|
368
|
-
|
369
|
-
start = spec[0].index("#")
|
370
|
-
str = spec[0].delete("#")
|
371
|
-
|
372
|
-
str.index(re, start).should == spec[1]
|
373
|
-
end
|
374
|
-
end
|
375
|
-
end
|
376
|
-
|
377
|
-
not_compliant_on :opal do
|
378
|
-
it "converts start_offset to an integer via to_int" do
|
379
|
-
obj = mock('1')
|
380
|
-
obj.should_receive(:to_int).and_return(1)
|
381
|
-
"RWOARW".index(/R./, obj).should == 4
|
382
|
-
end
|
383
|
-
end
|
384
|
-
|
385
|
-
with_feature :encoding do
|
386
|
-
it "returns the character index of a multibyte character" do
|
387
|
-
"ありがとう".index(/が/).should == 2
|
388
|
-
end
|
389
|
-
|
390
|
-
it "returns the character index after offset" do
|
391
|
-
"われわれ".index(/わ/, 1).should == 2
|
392
|
-
end
|
393
|
-
|
394
|
-
it "treats the offset as a character index" do
|
395
|
-
"われわわれ".index(/わ/, 3).should == 3
|
396
|
-
end
|
397
|
-
|
398
|
-
it "raises an Encoding::CompatibilityError if the encodings are incompatible" do
|
399
|
-
re = Regexp.new "れ".encode(Encoding::EUC_JP)
|
400
|
-
lambda do
|
401
|
-
"あれ".index re
|
402
|
-
end.should raise_error(Encoding::CompatibilityError)
|
403
|
-
end
|
404
|
-
end
|
405
|
-
end
|