opal-wedge 0.9.0.dev
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.gitmodules +7 -0
- data/.inch.yml +19 -0
- data/.jshintrc +48 -0
- data/.rspec +3 -0
- data/.spectator +2 -0
- data/.spectator-mspec +3 -0
- data/.travis.yml +60 -0
- data/.yardopts +6 -0
- data/CHANGELOG.md +571 -0
- data/CODE_OF_CONDUCT.md +15 -0
- data/CONTRIBUTING.md +192 -0
- data/Gemfile +26 -0
- data/Guardfile +77 -0
- data/LICENSE +19 -0
- data/README.md +167 -0
- data/Rakefile +15 -0
- data/benchmark/benchmarks +103 -0
- data/benchmark/bm_array_intersection_numbers.rb +7 -0
- data/benchmark/bm_array_intersection_objects.rb +7 -0
- data/benchmark/bm_array_intersection_strings.rb +7 -0
- data/benchmark/bm_array_minus_numbers.rb +7 -0
- data/benchmark/bm_array_minus_objects.rb +7 -0
- data/benchmark/bm_array_minus_strings.rb +7 -0
- data/benchmark/bm_array_union_numbers.rb +7 -0
- data/benchmark/bm_array_union_objects.rb +7 -0
- data/benchmark/bm_array_union_strings.rb +7 -0
- data/benchmark/bm_array_uniq_bang_numbers.rb +5 -0
- data/benchmark/bm_array_uniq_bang_objects.rb +5 -0
- data/benchmark/bm_array_uniq_bang_strings.rb +5 -0
- data/benchmark/bm_array_uniq_numbers.rb +5 -0
- data/benchmark/bm_array_uniq_objects.rb +5 -0
- data/benchmark/bm_array_uniq_strings.rb +5 -0
- data/benchmark/bm_dispatch_bind_table.rb +57 -0
- data/benchmark/bm_dispatch_code_gen.rb +65 -0
- data/benchmark/bm_dispatch_code_gen_if.rb +64 -0
- data/benchmark/bm_dispatch_hardcoded.rb +44 -0
- data/benchmark/bm_dispatch_send.rb +38 -0
- data/benchmark/bm_dispatch_send_table.rb +57 -0
- data/benchmark/bm_hash_assoc_object.rb +11 -0
- data/benchmark/bm_hash_assoc_string.rb +9 -0
- data/benchmark/bm_hash_clone_object.rb +9 -0
- data/benchmark/bm_hash_clone_string.rb +9 -0
- data/benchmark/bm_hash_delete_object.rb +11 -0
- data/benchmark/bm_hash_delete_string.rb +9 -0
- data/benchmark/bm_hash_each_key_object.rb +9 -0
- data/benchmark/bm_hash_each_key_string.rb +9 -0
- data/benchmark/bm_hash_each_object.rb +9 -0
- data/benchmark/bm_hash_each_string.rb +9 -0
- data/benchmark/bm_hash_each_value_object.rb +9 -0
- data/benchmark/bm_hash_each_value_string.rb +9 -0
- data/benchmark/bm_hash_element_reference_object.rb +11 -0
- data/benchmark/bm_hash_element_reference_string.rb +9 -0
- data/benchmark/bm_hash_element_set_object.rb +5 -0
- data/benchmark/bm_hash_element_set_string.rb +5 -0
- data/benchmark/bm_hash_equal_value_object.rb +14 -0
- data/benchmark/bm_hash_equal_value_string.rb +11 -0
- data/benchmark/bm_hash_fetch_object.rb +11 -0
- data/benchmark/bm_hash_fetch_string.rb +9 -0
- data/benchmark/bm_hash_flatten_object.rb +9 -0
- data/benchmark/bm_hash_flatten_string.rb +9 -0
- data/benchmark/bm_hash_has_key_object.rb +11 -0
- data/benchmark/bm_hash_has_key_string.rb +9 -0
- data/benchmark/bm_hash_has_value_object.rb +9 -0
- data/benchmark/bm_hash_has_value_string.rb +9 -0
- data/benchmark/bm_hash_hash_object.rb +9 -0
- data/benchmark/bm_hash_hash_string.rb +9 -0
- data/benchmark/bm_hash_inspect_object.rb +9 -0
- data/benchmark/bm_hash_inspect_string.rb +9 -0
- data/benchmark/bm_hash_invert_object.rb +9 -0
- data/benchmark/bm_hash_invert_string.rb +9 -0
- data/benchmark/bm_hash_keep_if_object.rb +9 -0
- data/benchmark/bm_hash_keep_if_string.rb +9 -0
- data/benchmark/bm_hash_key_object.rb +9 -0
- data/benchmark/bm_hash_key_string.rb +9 -0
- data/benchmark/bm_hash_keys_object.rb +9 -0
- data/benchmark/bm_hash_keys_string.rb +9 -0
- data/benchmark/bm_hash_literal_mixed_large.rb +3 -0
- data/benchmark/bm_hash_literal_mixed_small.rb +3 -0
- data/benchmark/bm_hash_literal_object_large.rb +4 -0
- data/benchmark/bm_hash_literal_object_small.rb +3 -0
- data/benchmark/bm_hash_literal_string_large.rb +4 -0
- data/benchmark/bm_hash_literal_string_small.rb +3 -0
- data/benchmark/bm_hash_merge_object.rb +22 -0
- data/benchmark/bm_hash_merge_string.rb +18 -0
- data/benchmark/bm_hash_rassoc_object.rb +9 -0
- data/benchmark/bm_hash_rassoc_string.rb +9 -0
- data/benchmark/bm_hash_rehash_object.rb +9 -0
- data/benchmark/bm_hash_rehash_string.rb +9 -0
- data/benchmark/bm_hash_reject_bang_object.rb +9 -0
- data/benchmark/bm_hash_reject_bang_string.rb +9 -0
- data/benchmark/bm_hash_reject_object.rb +9 -0
- data/benchmark/bm_hash_reject_string.rb +9 -0
- data/benchmark/bm_hash_replace_object.rb +18 -0
- data/benchmark/bm_hash_replace_string.rb +14 -0
- data/benchmark/bm_hash_select_bang_object.rb +9 -0
- data/benchmark/bm_hash_select_bang_string.rb +9 -0
- data/benchmark/bm_hash_select_object.rb +9 -0
- data/benchmark/bm_hash_select_string.rb +9 -0
- data/benchmark/bm_hash_shift_object.rb +10 -0
- data/benchmark/bm_hash_shift_string.rb +10 -0
- data/benchmark/bm_hash_to_a_object.rb +9 -0
- data/benchmark/bm_hash_to_a_string.rb +9 -0
- data/benchmark/bm_hash_to_h_object.rb +10 -0
- data/benchmark/bm_hash_to_h_string.rb +10 -0
- data/benchmark/bm_hash_values_object.rb +9 -0
- data/benchmark/bm_hash_values_string.rb +9 -0
- data/benchmark/run.rb +37 -0
- data/bin/opal +27 -0
- data/bin/opal-build +77 -0
- data/bin/opal-mspec +10 -0
- data/bin/opal-repl +72 -0
- data/config.ru +14 -0
- data/docs/compiler_directives.md +127 -0
- data/examples/rack/.gitignore +1 -0
- data/examples/rack/Gemfile +3 -0
- data/examples/rack/app/application.rb +13 -0
- data/examples/rack/app/user.rb +22 -0
- data/examples/rack/config.ru +20 -0
- data/examples/rack/index.html.erb +10 -0
- data/examples/sinatra/Gemfile +5 -0
- data/examples/sinatra/app/application.rb +7 -0
- data/examples/sinatra/config.ru +38 -0
- data/lib/mspec/opal/main.rb.erb +9 -0
- data/lib/mspec/opal/new.html.erb +1 -0
- data/lib/mspec/opal/rake_task.rb +248 -0
- data/lib/mspec/opal/runner.rb +281 -0
- data/lib/mspec/opal/special_calls.rb +44 -0
- data/lib/mspec/opal/sprockets.js +57 -0
- data/lib/opal-wedge.rb +4 -0
- data/lib/opal.rb +11 -0
- data/lib/opal/builder.rb +161 -0
- data/lib/opal/builder_processors.rb +149 -0
- data/lib/opal/cli.rb +162 -0
- data/lib/opal/cli_options.rb +158 -0
- data/lib/opal/cli_runners.rb +11 -0
- data/lib/opal/cli_runners/apple_script.rb +65 -0
- data/lib/opal/cli_runners/nodejs.rb +63 -0
- data/lib/opal/cli_runners/phantom.js +44 -0
- data/lib/opal/cli_runners/phantomjs.rb +28 -0
- data/lib/opal/cli_runners/server.rb +56 -0
- data/lib/opal/compiler.rb +381 -0
- data/lib/opal/config.rb +48 -0
- data/lib/opal/erb.rb +84 -0
- data/lib/opal/fragment.rb +53 -0
- data/lib/opal/hike_path_finder.rb +18 -0
- data/lib/opal/nodes.rb +26 -0
- data/lib/opal/nodes/arglist.rb +56 -0
- data/lib/opal/nodes/array.rb +54 -0
- data/lib/opal/nodes/base.rb +151 -0
- data/lib/opal/nodes/call.rb +290 -0
- data/lib/opal/nodes/call_special.rb +252 -0
- data/lib/opal/nodes/case.rb +96 -0
- data/lib/opal/nodes/class.rb +42 -0
- data/lib/opal/nodes/constants.rb +78 -0
- data/lib/opal/nodes/def.rb +281 -0
- data/lib/opal/nodes/defined.rb +113 -0
- data/lib/opal/nodes/definitions.rb +168 -0
- data/lib/opal/nodes/for.rb +48 -0
- data/lib/opal/nodes/hash.rb +67 -0
- data/lib/opal/nodes/helpers.rb +116 -0
- data/lib/opal/nodes/if.rb +81 -0
- data/lib/opal/nodes/iter.rb +136 -0
- data/lib/opal/nodes/literal.rb +247 -0
- data/lib/opal/nodes/logic.rb +217 -0
- data/lib/opal/nodes/masgn.rb +62 -0
- data/lib/opal/nodes/module.rb +45 -0
- data/lib/opal/nodes/rescue.rb +143 -0
- data/lib/opal/nodes/runtime_helpers.rb +45 -0
- data/lib/opal/nodes/scope.rb +281 -0
- data/lib/opal/nodes/singleton_class.rb +26 -0
- data/lib/opal/nodes/super.rb +97 -0
- data/lib/opal/nodes/top.rb +103 -0
- data/lib/opal/nodes/variables.rb +191 -0
- data/lib/opal/nodes/while.rb +65 -0
- data/lib/opal/nodes/yield.rb +95 -0
- data/lib/opal/parser.rb +742 -0
- data/lib/opal/parser/grammar.rb +5723 -0
- data/lib/opal/parser/grammar.y +1787 -0
- data/lib/opal/parser/keywords.rb +66 -0
- data/lib/opal/parser/lexer.rb +1260 -0
- data/lib/opal/parser/parser_scope.rb +28 -0
- data/lib/opal/parser/sexp.rb +81 -0
- data/lib/opal/path_reader.rb +35 -0
- data/lib/opal/paths.rb +55 -0
- data/lib/opal/regexp_anchors.rb +5 -0
- data/lib/opal/source_map.rb +70 -0
- data/lib/opal/sprockets.rb +3 -0
- data/lib/opal/sprockets/cache_key_fix.rb +17 -0
- data/lib/opal/sprockets/environment.rb +31 -0
- data/lib/opal/sprockets/erb.rb +23 -0
- data/lib/opal/sprockets/path_reader.rb +36 -0
- data/lib/opal/sprockets/processor.rb +167 -0
- data/lib/opal/sprockets/server.rb +160 -0
- data/lib/opal/sprockets/source_map_header_patch.rb +41 -0
- data/lib/opal/sprockets/source_map_server.rb +115 -0
- data/lib/opal/util.rb +69 -0
- data/lib/opal/version.rb +5 -0
- data/lib/tilt/opal.rb +54 -0
- data/opal.gemspec +37 -0
- data/opal/README.md +6 -0
- data/opal/corelib/array.rb +2073 -0
- data/opal/corelib/array/inheritance.rb +127 -0
- data/opal/corelib/basic_object.rb +82 -0
- data/opal/corelib/boolean.rb +47 -0
- data/opal/corelib/class.rb +55 -0
- data/opal/corelib/comparable.rb +57 -0
- data/opal/corelib/complex.rb +3 -0
- data/opal/corelib/dir.rb +20 -0
- data/opal/corelib/enumerable.rb +1138 -0
- data/opal/corelib/enumerator.rb +426 -0
- data/opal/corelib/error.rb +77 -0
- data/opal/corelib/file.rb +59 -0
- data/opal/corelib/hash.rb +951 -0
- data/opal/corelib/helpers.rb +102 -0
- data/opal/corelib/io.rb +73 -0
- data/opal/corelib/kernel.rb +1124 -0
- data/opal/corelib/main.rb +7 -0
- data/opal/corelib/match_data.rb +128 -0
- data/opal/corelib/method.rb +62 -0
- data/opal/corelib/module.rb +553 -0
- data/opal/corelib/nil_class.rb +57 -0
- data/opal/corelib/numeric.rb +564 -0
- data/opal/corelib/proc.rb +105 -0
- data/opal/corelib/process.rb +27 -0
- data/opal/corelib/range.rb +116 -0
- data/opal/corelib/rational.rb +3 -0
- data/opal/corelib/regexp.rb +203 -0
- data/opal/corelib/runtime.js +1637 -0
- data/opal/corelib/string.rb +1762 -0
- data/opal/corelib/string/inheritance.rb +117 -0
- data/opal/corelib/struct.rb +159 -0
- data/opal/corelib/time.rb +746 -0
- data/opal/corelib/variables.rb +28 -0
- data/opal/opal.rb +33 -0
- data/spec/README.md +8 -0
- data/spec/filters/bugs/array.rb +77 -0
- data/spec/filters/bugs/basicobject.rb +33 -0
- data/spec/filters/bugs/class.rb +15 -0
- data/spec/filters/bugs/comparable.rb +4 -0
- data/spec/filters/bugs/date.rb +173 -0
- data/spec/filters/bugs/enumerable.rb +62 -0
- data/spec/filters/bugs/enumerator.rb +45 -0
- data/spec/filters/bugs/exception.rb +84 -0
- data/spec/filters/bugs/fixnum.rb +35 -0
- data/spec/filters/bugs/float.rb +100 -0
- data/spec/filters/bugs/hash.rb +17 -0
- data/spec/filters/bugs/integer.rb +63 -0
- data/spec/filters/bugs/kernel.rb +395 -0
- data/spec/filters/bugs/language.rb +246 -0
- data/spec/filters/bugs/math.rb +89 -0
- data/spec/filters/bugs/method.rb +5 -0
- data/spec/filters/bugs/module.rb +372 -0
- data/spec/filters/bugs/nil.rb +7 -0
- data/spec/filters/bugs/numeric.rb +123 -0
- data/spec/filters/bugs/proc.rb +65 -0
- data/spec/filters/bugs/range.rb +148 -0
- data/spec/filters/bugs/regexp.rb +252 -0
- data/spec/filters/bugs/set.rb +51 -0
- data/spec/filters/bugs/singleton.rb +6 -0
- data/spec/filters/bugs/string.rb +99 -0
- data/spec/filters/bugs/strscan.rb +106 -0
- data/spec/filters/bugs/struct.rb +22 -0
- data/spec/filters/bugs/time.rb +28 -0
- data/spec/filters/bugs/unboundmethod.rb +22 -0
- data/spec/filters/unsupported/array.rb +176 -0
- data/spec/filters/unsupported/basicobject.rb +12 -0
- data/spec/filters/unsupported/class.rb +4 -0
- data/spec/filters/unsupported/delegator.rb +5 -0
- data/spec/filters/unsupported/enumerable.rb +8 -0
- data/spec/filters/unsupported/enumerator.rb +13 -0
- data/spec/filters/unsupported/fixnum.rb +15 -0
- data/spec/filters/unsupported/float.rb +6 -0
- data/spec/filters/unsupported/hash.rb +55 -0
- data/spec/filters/unsupported/integer.rb +3 -0
- data/spec/filters/unsupported/kernel.rb +22 -0
- data/spec/filters/unsupported/language.rb +31 -0
- data/spec/filters/unsupported/matchdata.rb +33 -0
- data/spec/filters/unsupported/math.rb +3 -0
- data/spec/filters/unsupported/module.rb +36 -0
- data/spec/filters/unsupported/pathname.rb +3 -0
- data/spec/filters/unsupported/regexp.rb +94 -0
- data/spec/filters/unsupported/set.rb +4 -0
- data/spec/filters/unsupported/singleton.rb +6 -0
- data/spec/filters/unsupported/string.rb +538 -0
- data/spec/filters/unsupported/struct.rb +3 -0
- data/spec/filters/unsupported/time.rb +208 -0
- data/spec/lib/builder_processors_spec.rb +27 -0
- data/spec/lib/builder_spec.rb +72 -0
- data/spec/lib/cli_spec.rb +150 -0
- data/spec/lib/compiler/pre_processed_conditionals_spec.rb +87 -0
- data/spec/lib/compiler_spec.rb +131 -0
- data/spec/lib/dependency_resolver_spec.rb +40 -0
- data/spec/lib/fixtures/complex_sprockets.js.rb.erb +4 -0
- data/spec/lib/fixtures/file_with_directives.js +2 -0
- data/spec/lib/fixtures/jst_file.js.jst +1 -0
- data/spec/lib/fixtures/no_requires.rb +1 -0
- data/spec/lib/fixtures/opal_file.rb +2 -0
- data/spec/lib/fixtures/require_tree_test.rb +3 -0
- data/spec/lib/fixtures/required_file.js +1 -0
- data/spec/lib/fixtures/required_tree_test/required_file1.rb +1 -0
- data/spec/lib/fixtures/required_tree_test/required_file2.rb +1 -0
- data/spec/lib/fixtures/requires.rb +7 -0
- data/spec/lib/fixtures/source_map.rb +1 -0
- data/spec/lib/fixtures/source_map/subfolder/other_file.rb +1 -0
- data/spec/lib/fixtures/sprockets_file.js.rb +3 -0
- data/spec/lib/fixtures/sprockets_require_tree_test.rb +3 -0
- data/spec/lib/hike_path_finder_spec.rb +23 -0
- data/spec/lib/lexer_spec.rb +110 -0
- data/spec/lib/parser/alias_spec.rb +26 -0
- data/spec/lib/parser/and_spec.rb +13 -0
- data/spec/lib/parser/attrasgn_spec.rb +28 -0
- data/spec/lib/parser/begin_spec.rb +42 -0
- data/spec/lib/parser/block_spec.rb +12 -0
- data/spec/lib/parser/break_spec.rb +17 -0
- data/spec/lib/parser/call_spec.rb +165 -0
- data/spec/lib/parser/class_spec.rb +35 -0
- data/spec/lib/parser/comments_spec.rb +11 -0
- data/spec/lib/parser/def_spec.rb +80 -0
- data/spec/lib/parser/if_spec.rb +26 -0
- data/spec/lib/parser/iter_spec.rb +59 -0
- data/spec/lib/parser/lambda_spec.rb +64 -0
- data/spec/lib/parser/literal_spec.rb +118 -0
- data/spec/lib/parser/masgn_spec.rb +37 -0
- data/spec/lib/parser/module_spec.rb +27 -0
- data/spec/lib/parser/not_spec.rb +21 -0
- data/spec/lib/parser/op_asgn1_spec.rb +23 -0
- data/spec/lib/parser/op_asgn2_spec.rb +23 -0
- data/spec/lib/parser/or_spec.rb +13 -0
- data/spec/lib/parser/return_spec.rb +17 -0
- data/spec/lib/parser/sclass_spec.rb +21 -0
- data/spec/lib/parser/string_spec.rb +276 -0
- data/spec/lib/parser/super_spec.rb +20 -0
- data/spec/lib/parser/unary_spec.rb +48 -0
- data/spec/lib/parser/undef_spec.rb +15 -0
- data/spec/lib/parser/unless_spec.rb +13 -0
- data/spec/lib/parser/variables_spec.rb +92 -0
- data/spec/lib/parser/while_spec.rb +15 -0
- data/spec/lib/parser/yield_spec.rb +20 -0
- data/spec/lib/path_reader_spec.rb +36 -0
- data/spec/lib/shared/path_finder_shared.rb +19 -0
- data/spec/lib/shared/path_reader_shared.rb +31 -0
- data/spec/lib/spec_helper.rb +9 -0
- data/spec/lib/sprockets/erb_spec.rb +38 -0
- data/spec/lib/sprockets/path_reader_spec.rb +41 -0
- data/spec/lib/sprockets/processor_spec.rb +67 -0
- data/spec/lib/sprockets/server_spec.rb +102 -0
- data/spec/lib/tilt/opal_spec.rb +37 -0
- data/spec/opal/compiler/irb_spec.rb +44 -0
- data/spec/opal/core/array/intersection_spec.rb +38 -0
- data/spec/opal/core/array/minus_spec.rb +38 -0
- data/spec/opal/core/array/select_spec.rb +14 -0
- data/spec/opal/core/array/set_range_to_array_spec.rb +7 -0
- data/spec/opal/core/array/union_spec.rb +38 -0
- data/spec/opal/core/array/uniq_spec.rb +49 -0
- data/spec/opal/core/date_spec.rb +177 -0
- data/spec/opal/core/enumerable/all_break_spec.rb +5 -0
- data/spec/opal/core/enumerable/any_break_spec.rb +5 -0
- data/spec/opal/core/enumerable/collect_break_spec.rb +13 -0
- data/spec/opal/core/enumerable/count_break_spec.rb +5 -0
- data/spec/opal/core/enumerable/detect_break_spec.rb +5 -0
- data/spec/opal/core/enumerable/drop_while_break_spec.rb +5 -0
- data/spec/opal/core/enumerable/each_slice_break.rb +6 -0
- data/spec/opal/core/enumerable/each_with_index_break_spec.rb +5 -0
- data/spec/opal/core/enumerable/each_with_object_break_spec.rb +5 -0
- data/spec/opal/core/enumerable/find_all_break_spec.rb +5 -0
- data/spec/opal/core/enumerable/find_index_break_spec.rb +5 -0
- data/spec/opal/core/enumerable/grep_break_spec.rb +5 -0
- data/spec/opal/core/enumerable/max_break_spec.rb +5 -0
- data/spec/opal/core/enumerable/max_by_break_spec.rb +5 -0
- data/spec/opal/core/enumerable/min_break_spec.rb +5 -0
- data/spec/opal/core/enumerable/min_by_break_spec.rb +5 -0
- data/spec/opal/core/enumerable/none_break_spec.rb +5 -0
- data/spec/opal/core/enumerable/one_break_spec.rb +5 -0
- data/spec/opal/core/enumerable/reduce_break_spec.rb +5 -0
- data/spec/opal/core/enumerable/take_while_break_spec.rb +5 -0
- data/spec/opal/core/exception_spec.rb +13 -0
- data/spec/opal/core/fixtures/class.rb +124 -0
- data/spec/opal/core/fixtures/class_variables.rb +0 -0
- data/spec/opal/core/fixtures/constants.rb +33 -0
- data/spec/opal/core/fixtures/require_tree_files/file 1.rb +1 -0
- data/spec/opal/core/fixtures/require_tree_files/file 2.rb +1 -0
- data/spec/opal/core/fixtures/require_tree_files/file 3.rb +1 -0
- data/spec/opal/core/fixtures/require_tree_files/file 4.rb +1 -0
- data/spec/opal/core/fixtures/require_tree_files/file 5.rb +1 -0
- data/spec/opal/core/fixtures/require_tree_files/nested/nested 1.rb +1 -0
- data/spec/opal/core/fixtures/require_tree_files/nested/nested 2.rb +1 -0
- data/spec/opal/core/fixtures/require_tree_files/other/other 1.rb +1 -0
- data/spec/opal/core/fixtures/require_tree_with_dot/file 1.rb +1 -0
- data/spec/opal/core/fixtures/require_tree_with_dot/file 2.rb +1 -0
- data/spec/opal/core/fixtures/require_tree_with_dot/file 3.rb +1 -0
- data/spec/opal/core/fixtures/require_tree_with_dot/index.rb +3 -0
- data/spec/opal/core/hash/has_value_spec.rb +13 -0
- data/spec/opal/core/hash/internals_spec.rb +332 -0
- data/spec/opal/core/kernel/Array_spec.rb +10 -0
- data/spec/opal/core/kernel/block_given_spec.rb +30 -0
- data/spec/opal/core/kernel/class_spec.rb +6 -0
- data/spec/opal/core/kernel/define_singleton_method_spec.rb +21 -0
- data/spec/opal/core/kernel/equal_value_spec.rb +12 -0
- data/spec/opal/core/kernel/extend_spec.rb +21 -0
- data/spec/opal/core/kernel/format_spec.rb +122 -0
- data/spec/opal/core/kernel/freeze_spec.rb +15 -0
- data/spec/opal/core/kernel/instance_eval_spec.rb +28 -0
- data/spec/opal/core/kernel/instance_variable_defined_spec.rb +15 -0
- data/spec/opal/core/kernel/instance_variable_get_spec.rb +14 -0
- data/spec/opal/core/kernel/instance_variable_set_spec.rb +10 -0
- data/spec/opal/core/kernel/loop_spec.rb +23 -0
- data/spec/opal/core/kernel/match_spec.rb +5 -0
- data/spec/opal/core/kernel/method_spec.rb +31 -0
- data/spec/opal/core/kernel/methods_spec.rb +25 -0
- data/spec/opal/core/kernel/nil_spec.rb +7 -0
- data/spec/opal/core/kernel/p_spec.rb +15 -0
- data/spec/opal/core/kernel/printf_spec.rb +11 -0
- data/spec/opal/core/kernel/proc_spec.rb +13 -0
- data/spec/opal/core/kernel/rand_spec.rb +23 -0
- data/spec/opal/core/kernel/require_tree_spec.rb +18 -0
- data/spec/opal/core/kernel/respond_to_spec.rb +41 -0
- data/spec/opal/core/kernel/send_spec.rb +56 -0
- data/spec/opal/core/kernel/sprintf_spec.rb +5 -0
- data/spec/opal/core/language/block_spec.rb +538 -0
- data/spec/opal/core/language/fixtures/array.rb +11 -0
- data/spec/opal/core/language/fixtures/block.rb +57 -0
- data/spec/opal/core/language/fixtures/break.rb +240 -0
- data/spec/opal/core/language/fixtures/ensure.rb +72 -0
- data/spec/opal/core/language/fixtures/literal_lambda.rb +7 -0
- data/spec/opal/core/language/fixtures/metaclass.rb +33 -0
- data/spec/opal/core/language/fixtures/module.rb +24 -0
- data/spec/opal/core/language/fixtures/next.rb +128 -0
- data/spec/opal/core/language/fixtures/return.rb +118 -0
- data/spec/opal/core/language/fixtures/send.rb +110 -0
- data/spec/opal/core/language/fixtures/send_1.9.rb +22 -0
- data/spec/opal/core/language/fixtures/super.rb +308 -0
- data/spec/opal/core/language/fixtures/variables.rb +58 -0
- data/spec/opal/core/language/fixtures/yield.rb +28 -0
- data/spec/opal/core/language/predefined_spec.rb +138 -0
- data/spec/opal/core/language/proc_spec.rb +263 -0
- data/spec/opal/core/language/regexp_spec.rb +20 -0
- data/spec/opal/core/language/send_spec.rb +225 -0
- data/spec/opal/core/language/string_spec.rb +44 -0
- data/spec/opal/core/language/variables_spec.rb +1366 -0
- data/spec/opal/core/language/versions/array_1.9.rb +39 -0
- data/spec/opal/core/language/versions/block_1.9.rb +0 -0
- data/spec/opal/core/language/versions/break_1.9.rb +0 -0
- data/spec/opal/core/language/versions/case_1.9.rb +20 -0
- data/spec/opal/core/language/versions/def_2_0_spec.rb +62 -0
- data/spec/opal/core/language/versions/hash_1.9.rb +18 -0
- data/spec/opal/core/language/versions/literal_lambda_1.9.rb +143 -0
- data/spec/opal/core/language/versions/not_1.9.rb +22 -0
- data/spec/opal/core/language/versions/send_1.9.rb +241 -0
- data/spec/opal/core/language/versions/symbol_1.9.rb +15 -0
- data/spec/opal/core/language/versions/variables_1.9.rb +8 -0
- data/spec/opal/core/language_spec.rb +23 -0
- data/spec/opal/core/method/to_proc_spec.rb +28 -0
- data/spec/opal/core/module/alias_method_spec.rb +28 -0
- data/spec/opal/core/module/ancestors_spec.rb +11 -0
- data/spec/opal/core/module/append_features_spec.rb +14 -0
- data/spec/opal/core/module/attr_accessor_spec.rb +26 -0
- data/spec/opal/core/module/const_defined_spec.rb +85 -0
- data/spec/opal/core/module/const_get_spec.rb +85 -0
- data/spec/opal/core/module/const_missing_spec.rb +17 -0
- data/spec/opal/core/module/const_set_spec.rb +64 -0
- data/spec/opal/core/module/constants_spec.rb +49 -0
- data/spec/opal/core/module/fixtures/classes.rb +434 -0
- data/spec/opal/core/module/method_defined_spec.rb +48 -0
- data/spec/opal/core/module/module_function_spec.rb +25 -0
- data/spec/opal/core/module/name_spec.rb +52 -0
- data/spec/opal/core/module/public_method_defined_spec.rb +18 -0
- data/spec/opal/core/module/remove_const_spec.rb +22 -0
- data/spec/opal/core/module/undef_method_spec.rb +66 -0
- data/spec/opal/core/numeric/bit_and_spec.rb +7 -0
- data/spec/opal/core/numeric/bit_or_spec.rb +8 -0
- data/spec/opal/core/numeric/bit_xor_spec.rb +6 -0
- data/spec/opal/core/numeric/ceil_spec.rb +8 -0
- data/spec/opal/core/numeric/chr_spec.rb +8 -0
- data/spec/opal/core/numeric/comparison_spec.rb +24 -0
- data/spec/opal/core/numeric/complement_spec.rb +8 -0
- data/spec/opal/core/numeric/divide_spec.rb +10 -0
- data/spec/opal/core/numeric/eql_spec.rb +9 -0
- data/spec/opal/core/numeric/exponent_spec.rb +33 -0
- data/spec/opal/core/numeric/floor_spec.rb +8 -0
- data/spec/opal/core/numeric/gt_spec.rb +11 -0
- data/spec/opal/core/numeric/gte_spec.rb +12 -0
- data/spec/opal/core/numeric/integer_spec.rb +9 -0
- data/spec/opal/core/numeric/left_shift_spec.rb +21 -0
- data/spec/opal/core/numeric/lt_spec.rb +11 -0
- data/spec/opal/core/numeric/lte_spec.rb +12 -0
- data/spec/opal/core/numeric/minus_spec.rb +8 -0
- data/spec/opal/core/numeric/modulo_spec.rb +19 -0
- data/spec/opal/core/numeric/multiply_spec.rb +9 -0
- data/spec/opal/core/numeric/next_spec.rb +9 -0
- data/spec/opal/core/numeric/ord_spec.rb +9 -0
- data/spec/opal/core/numeric/plus_spec.rb +8 -0
- data/spec/opal/core/numeric/pred_spec.rb +7 -0
- data/spec/opal/core/numeric/right_shift_spec.rb +25 -0
- data/spec/opal/core/numeric/step_spec.rb +11 -0
- data/spec/opal/core/numeric/succ_spec.rb +9 -0
- data/spec/opal/core/numeric/times_spec.rb +36 -0
- data/spec/opal/core/numeric/to_f_spec.rb +7 -0
- data/spec/opal/core/numeric/to_i_spec.rb +7 -0
- data/spec/opal/core/numeric/to_json_spec.rb +8 -0
- data/spec/opal/core/numeric/to_s_spec.rb +26 -0
- data/spec/opal/core/numeric/uminus_spec.rb +9 -0
- data/spec/opal/core/numeric/upto_spec.rb +19 -0
- data/spec/opal/core/numeric/zero_spec.rb +7 -0
- data/spec/opal/core/object_id_spec.rb +56 -0
- data/spec/opal/core/proc/call_spec.rb +21 -0
- data/spec/opal/core/proc/element_reference_spec.rb +21 -0
- data/spec/opal/core/proc/proc_tricks_spec.rb +7 -0
- data/spec/opal/core/runtime/begin_spec.rb +39 -0
- data/spec/opal/core/runtime/block_send_spec.rb +28 -0
- data/spec/opal/core/runtime/block_spec.rb +23 -0
- data/spec/opal/core/runtime/bridged_classes_spec.rb +111 -0
- data/spec/opal/core/runtime/constants_spec.rb +13 -0
- data/spec/opal/core/runtime/donate_spec.rb +53 -0
- data/spec/opal/core/runtime/eval_spec.rb +5 -0
- data/spec/opal/core/runtime/main_methods_spec.rb +27 -0
- data/spec/opal/core/runtime/method_missing_spec.rb +62 -0
- data/spec/opal/core/runtime/method_spec.rb +31 -0
- data/spec/opal/core/runtime/operator_call_spec.rb +13 -0
- data/spec/opal/core/runtime/paren_spec.rb +14 -0
- data/spec/opal/core/runtime/rescue_spec.rb +38 -0
- data/spec/opal/core/runtime/return_spec.rb +38 -0
- data/spec/opal/core/runtime/send_spec.rb +34 -0
- data/spec/opal/core/runtime/singleton_class_spec.rb +13 -0
- data/spec/opal/core/runtime/super_spec.rb +212 -0
- data/spec/opal/core/runtime/truthy_spec.rb +23 -0
- data/spec/opal/core/runtime/variables_spec.rb +20 -0
- data/spec/opal/core/runtime_spec.rb +58 -0
- data/spec/opal/core/source_map_spec.rb +15 -0
- data/spec/opal/core/string_spec.rb +11 -0
- data/spec/opal/stdlib/erb/erb_spec.rb +30 -0
- data/spec/opal/stdlib/erb/inline_block.opalerb +3 -0
- data/spec/opal/stdlib/erb/quoted.opalerb +1 -0
- data/spec/opal/stdlib/erb/simple.opalerb +1 -0
- data/spec/opal/stdlib/js_spec.rb +66 -0
- data/spec/opal/stdlib/json/ext_spec.rb +48 -0
- data/spec/opal/stdlib/json/parse_spec.rb +33 -0
- data/spec/opal/stdlib/native/alias_native_spec.rb +27 -0
- data/spec/opal/stdlib/native/each_spec.rb +13 -0
- data/spec/opal/stdlib/native/element_reference_spec.rb +16 -0
- data/spec/opal/stdlib/native/exposure_spec.rb +33 -0
- data/spec/opal/stdlib/native/ext_spec.rb +19 -0
- data/spec/opal/stdlib/native/initialize_spec.rb +17 -0
- data/spec/opal/stdlib/native/method_missing_spec.rb +51 -0
- data/spec/opal/stdlib/native/native_alias_spec.rb +19 -0
- data/spec/opal/stdlib/native/native_class_spec.rb +18 -0
- data/spec/opal/stdlib/native/native_module_spec.rb +13 -0
- data/spec/opal/stdlib/native/native_reader_spec.rb +22 -0
- data/spec/opal/stdlib/native/native_writer_spec.rb +30 -0
- data/spec/opal/stdlib/native/new_spec.rb +8 -0
- data/spec/opal/stdlib/promise/always_spec.rb +30 -0
- data/spec/opal/stdlib/promise/error_spec.rb +15 -0
- data/spec/opal/stdlib/promise/rescue_spec.rb +44 -0
- data/spec/opal/stdlib/promise/then_spec.rb +71 -0
- data/spec/opal/stdlib/promise/trace_spec.rb +52 -0
- data/spec/opal/stdlib/promise/value_spec.rb +15 -0
- data/spec/opal/stdlib/promise/when_spec.rb +34 -0
- data/spec/opal/stdlib/template/paths_spec.rb +10 -0
- data/spec/opal/stdlib/thread/mutex_spec.rb +40 -0
- data/spec/opal/stdlib/thread/thread_queue_spec.rb +32 -0
- data/spec/opal/stdlib/thread/thread_spec.rb +60 -0
- data/spec/rubyspecs +144 -0
- data/spec/spec_helper.rb +53 -0
- data/spec/support/mspec_rspec_adapter.rb +33 -0
- data/spec/support/parser_helpers.rb +37 -0
- data/stdlib/README.md +3 -0
- data/stdlib/base64.rb +152 -0
- data/stdlib/benchmark.rb +557 -0
- data/stdlib/buffer.rb +41 -0
- data/stdlib/buffer/array.rb +66 -0
- data/stdlib/buffer/view.rb +70 -0
- data/stdlib/date.rb +248 -0
- data/stdlib/delegate.rb +29 -0
- data/stdlib/dir.rb +1 -0
- data/stdlib/encoding.rb +170 -0
- data/stdlib/enumerator.rb +1 -0
- data/stdlib/erb.rb +16 -0
- data/stdlib/file.rb +1 -0
- data/stdlib/fileutils.rb +0 -0
- data/stdlib/forwardable.rb +71 -0
- data/stdlib/iconv.rb +0 -0
- data/stdlib/js.rb +56 -0
- data/stdlib/json.rb +190 -0
- data/stdlib/math.rb +370 -0
- data/stdlib/native.rb +530 -0
- data/stdlib/nodejs.rb +7 -0
- data/stdlib/nodejs/dir.rb +13 -0
- data/stdlib/nodejs/file.rb +98 -0
- data/stdlib/nodejs/fileutils.rb +26 -0
- data/stdlib/nodejs/io.rb +2 -0
- data/stdlib/nodejs/irb.rb +45 -0
- data/stdlib/nodejs/kernel.rb +33 -0
- data/stdlib/nodejs/node_modules/.bin/js-yaml +140 -0
- data/stdlib/nodejs/node_modules/glob/LICENSE +15 -0
- data/stdlib/nodejs/node_modules/glob/README.md +357 -0
- data/stdlib/nodejs/node_modules/glob/common.js +177 -0
- data/stdlib/nodejs/node_modules/glob/glob.js +649 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/inflight/.eslintrc +17 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/inflight/LICENSE +15 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/inflight/README.md +37 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/inflight/inflight.js +44 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/inflight/node_modules/wrappy/LICENSE +15 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/inflight/node_modules/wrappy/README.md +36 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/inflight/node_modules/wrappy/package.json +52 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/inflight/node_modules/wrappy/test/basic.js +51 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/inflight/node_modules/wrappy/wrappy.js +33 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/inflight/package.json +61 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/inflight/test.js +97 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/inherits/LICENSE +16 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/inherits/README.md +42 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/inherits/inherits.js +1 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/inherits/inherits_browser.js +23 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/inherits/package.json +51 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/inherits/test.js +25 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/.npmignore +1 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/.travis.yml +4 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/LICENSE +23 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/README.md +216 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/benchmark.js +15 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/browser.js +1181 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/minimatch.js +845 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/.npmignore +2 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/.travis.yml +3 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/README.md +121 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/example.js +8 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/index.js +191 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/.npmignore +2 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/.travis.yml +4 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/Makefile +6 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/README.md +80 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/example.js +5 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/index.js +38 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/package.json +73 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match/test/balanced.js +56 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/.travis.yml +4 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/LICENSE +18 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/README.markdown +62 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/example/map.js +6 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/index.js +13 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/package.json +83 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map/test/map.js +39 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/package.json +75 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/bash-comparison.js +32 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/bash-results.txt +1075 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/cases.txt +182 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/dollar.js +9 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/empty-option.js +10 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/generate.sh +24 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/negative-increment.js +15 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/nested.js +16 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/order.js +10 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/pad.js +13 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/same-type.js +7 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/test/sequence.js +50 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/package.json +60 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/test/basic.js +399 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/test/brace-expand.js +45 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/test/defaults.js +274 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/minimatch/test/extglob-ending-with-state-char.js +8 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/once/LICENSE +27 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/once/README.md +51 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/once/node_modules/wrappy/LICENSE +15 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/once/node_modules/wrappy/README.md +36 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/once/node_modules/wrappy/package.json +52 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/once/node_modules/wrappy/test/basic.js +51 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/once/node_modules/wrappy/wrappy.js +33 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/once/once.js +21 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/once/package.json +60 -0
- data/stdlib/nodejs/node_modules/glob/node_modules/once/test/once.js +23 -0
- data/stdlib/nodejs/node_modules/glob/package.json +72 -0
- data/stdlib/nodejs/node_modules/glob/sync.js +409 -0
- data/stdlib/nodejs/node_modules/js-yaml/HISTORY.md +277 -0
- data/stdlib/nodejs/node_modules/js-yaml/LICENSE +21 -0
- data/stdlib/nodejs/node_modules/js-yaml/README.md +288 -0
- data/stdlib/nodejs/node_modules/js-yaml/bin/js-yaml.js +140 -0
- data/stdlib/nodejs/node_modules/js-yaml/bower.json +23 -0
- data/stdlib/nodejs/node_modules/js-yaml/dist/js-yaml.js +3666 -0
- data/stdlib/nodejs/node_modules/js-yaml/dist/js-yaml.min.js +3 -0
- data/stdlib/nodejs/node_modules/js-yaml/examples/custom_types.js +102 -0
- data/stdlib/nodejs/node_modules/js-yaml/examples/custom_types.yml +18 -0
- data/stdlib/nodejs/node_modules/js-yaml/examples/dumper.js +31 -0
- data/stdlib/nodejs/node_modules/js-yaml/examples/dumper.json +22 -0
- data/stdlib/nodejs/node_modules/js-yaml/examples/sample_document.js +18 -0
- data/stdlib/nodejs/node_modules/js-yaml/examples/sample_document.yml +197 -0
- data/stdlib/nodejs/node_modules/js-yaml/index.js +7 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml.js +39 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/common.js +62 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/dumper.js +554 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/exception.js +25 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/loader.js +1581 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/mark.js +78 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/schema.js +103 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/schema/core.js +18 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/schema/default_full.js +25 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/schema/default_safe.js +28 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/schema/failsafe.js +17 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/schema/json.js +25 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type.js +61 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/binary.js +133 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/bool.js +37 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/float.js +110 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/int.js +183 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/js/function.js +85 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/js/regexp.js +84 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/js/undefined.js +27 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/map.js +8 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/merge.js +12 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/null.js +36 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/omap.js +56 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/pairs.js +61 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/seq.js +8 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/set.js +33 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/str.js +8 -0
- data/stdlib/nodejs/node_modules/js-yaml/lib/js-yaml/type/timestamp.js +98 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/.bin/esparse +117 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/.bin/esvalidate +177 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/HISTORY.md +115 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/LICENSE +21 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/README.md +239 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/examples/arguments.js +36 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/examples/choice.js +22 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/examples/constants.js +59 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/examples/help.js +13 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/examples/nargs.js +33 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/examples/parents.js +28 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/examples/prefix_chars.js +23 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/examples/sub_commands.js +49 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/examples/sum.js +35 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/examples/testformatters.js +270 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/index.js +1 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action.js +146 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action/append.js +55 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action/append/constant.js +47 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action/count.js +40 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action/help.js +48 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action/store.js +50 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action/store/constant.js +43 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action/store/false.js +27 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action/store/true.js +26 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action/subparsers.js +148 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action/version.js +50 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/action_container.js +481 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/argparse.js +14 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/argument/error.js +50 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/argument/exclusive.js +54 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/argument/group.js +75 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/argument_parser.js +1168 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/const.js +18 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/help/added_formatters.js +88 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/help/formatter.js +798 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/lib/namespace.js +77 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/.npmignore +2 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/.travis.yml +8 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/README.markdown +825 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/bower.json +33 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/component.json +11 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/foo.js +10 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/gulpfile.js +26 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/lib/underscore.string.js +673 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/libpeerconnection.log +0 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string/package.json +107 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/LICENSE +23 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/README.md +22 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/package.json +69 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/underscore-min.js +6 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/node_modules/underscore/underscore.js +1415 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/argparse/package.json +62 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/esprima/README.md +73 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/esprima/bin/esparse.js +117 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/esprima/bin/esvalidate.js +177 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/esprima/esprima.js +3908 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/esprima/package.json +69 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/esprima/test/compat.js +239 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/esprima/test/reflect.js +422 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/esprima/test/run.js +66 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/esprima/test/runner.js +387 -0
- data/stdlib/nodejs/node_modules/js-yaml/node_modules/esprima/test/test.js +20238 -0
- data/stdlib/nodejs/node_modules/js-yaml/package.json +83 -0
- data/stdlib/nodejs/package.json +6 -0
- data/stdlib/nodejs/require.rb +30 -0
- data/stdlib/nodejs/rubygems.rb +68 -0
- data/stdlib/nodejs/yaml.rb +11 -0
- data/stdlib/observer.rb +202 -0
- data/stdlib/opal-parser.rb +54 -0
- data/stdlib/opal-source-maps.rb +2 -0
- data/stdlib/ostruct.rb +69 -0
- data/stdlib/pathname.rb +55 -0
- data/stdlib/phantomjs.rb +3 -0
- data/stdlib/pp.rb +35 -0
- data/stdlib/promise.rb +427 -0
- data/stdlib/racc/parser.rb +215 -0
- data/stdlib/rbconfig.rb +18 -0
- data/stdlib/securerandom.rb +12 -0
- data/stdlib/set.rb +170 -0
- data/stdlib/singleton.rb +40 -0
- data/stdlib/source_map.rb +5 -0
- data/stdlib/source_map/map.rb +220 -0
- data/stdlib/source_map/mapping.rb +26 -0
- data/stdlib/source_map/offset.rb +88 -0
- data/stdlib/source_map/version.rb +3 -0
- data/stdlib/source_map/vlq.rb +98 -0
- data/stdlib/sourcemap.rb +1 -0
- data/stdlib/stringio.rb +181 -0
- data/stdlib/strscan.rb +166 -0
- data/stdlib/template.rb +46 -0
- data/stdlib/thread.rb +164 -0
- data/stdlib/time.rb +9 -0
- data/stdlib/yaml.rb +1 -0
- data/tasks/benchmarking.rake +88 -0
- data/tasks/building.rake +58 -0
- data/tasks/documenting.rake +37 -0
- data/tasks/github.rake +19 -0
- data/tasks/linting.rake +18 -0
- data/tasks/testing.rake +125 -0
- data/vendored-minitest/minitest.rb +780 -0
- data/vendored-minitest/minitest/assertions.rb +662 -0
- data/vendored-minitest/minitest/autorun.rb +12 -0
- data/vendored-minitest/minitest/benchmark.rb +426 -0
- data/vendored-minitest/minitest/expectations.rb +281 -0
- data/vendored-minitest/minitest/hell.rb +11 -0
- data/vendored-minitest/minitest/mock.rb +220 -0
- data/vendored-minitest/minitest/parallel.rb +65 -0
- data/vendored-minitest/minitest/pride.rb +4 -0
- data/vendored-minitest/minitest/pride_plugin.rb +142 -0
- data/vendored-minitest/minitest/spec.rb +310 -0
- data/vendored-minitest/minitest/test.rb +293 -0
- data/vendored-minitest/minitest/unit.rb +45 -0
- data/vendored-minitest/test/unit.rb +28 -0
- metadata +1058 -0
@@ -0,0 +1,662 @@
|
|
1
|
+
require "rbconfig"
|
2
|
+
require "tempfile"
|
3
|
+
require 'stringio'
|
4
|
+
|
5
|
+
module Minitest
|
6
|
+
##
|
7
|
+
# Minitest Assertions. All assertion methods accept a +msg+ which is
|
8
|
+
# printed if the assertion fails.
|
9
|
+
#
|
10
|
+
# Protocol: Nearly everything here boils up to +assert+, which
|
11
|
+
# expects to be able to increment an instance accessor named
|
12
|
+
# +assertions+. This is not provided by Assertions and must be
|
13
|
+
# provided by the thing including Assertions. See Minitest::Runnable
|
14
|
+
# for an example.
|
15
|
+
|
16
|
+
module Assertions
|
17
|
+
UNDEFINED = Object.new # :nodoc:
|
18
|
+
|
19
|
+
def UNDEFINED.inspect # :nodoc:
|
20
|
+
"UNDEFINED" # again with the rdoc bugs... :(
|
21
|
+
end
|
22
|
+
|
23
|
+
##
|
24
|
+
# Returns the diff command to use in #diff. Tries to intelligently
|
25
|
+
# figure out what diff to use.
|
26
|
+
|
27
|
+
def self.diff
|
28
|
+
@diff = if (RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ &&
|
29
|
+
system("diff.exe", __FILE__, __FILE__)) then
|
30
|
+
"diff.exe -u"
|
31
|
+
elsif Minitest::Test.maglev? then
|
32
|
+
"diff -u"
|
33
|
+
elsif system("gdiff", __FILE__, __FILE__)
|
34
|
+
"gdiff -u" # solaris and kin suck
|
35
|
+
elsif system("diff", __FILE__, __FILE__)
|
36
|
+
"diff -u"
|
37
|
+
else
|
38
|
+
nil
|
39
|
+
end unless defined? @diff
|
40
|
+
|
41
|
+
@diff
|
42
|
+
end
|
43
|
+
|
44
|
+
##
|
45
|
+
# Set the diff command to use in #diff.
|
46
|
+
|
47
|
+
def self.diff= o
|
48
|
+
@diff = o
|
49
|
+
end
|
50
|
+
|
51
|
+
##
|
52
|
+
# Returns a diff between +exp+ and +act+. If there is no known
|
53
|
+
# diff command or if it doesn't make sense to diff the output
|
54
|
+
# (single line, short output), then it simply returns a basic
|
55
|
+
# comparison between the two.
|
56
|
+
|
57
|
+
def diff exp, act
|
58
|
+
expect = mu_pp_for_diff exp
|
59
|
+
butwas = mu_pp_for_diff act
|
60
|
+
result = nil
|
61
|
+
|
62
|
+
need_to_diff = false
|
63
|
+
# (expect.include?("\n") ||
|
64
|
+
# butwas.include?("\n") ||
|
65
|
+
# expect.size > 30 ||
|
66
|
+
# butwas.size > 30 ||
|
67
|
+
# expect == butwas) &&
|
68
|
+
# Minitest::Assertions.diff
|
69
|
+
|
70
|
+
|
71
|
+
return "Expected: #{mu_pp exp}\n Actual: #{mu_pp act}" unless
|
72
|
+
need_to_diff
|
73
|
+
|
74
|
+
# Tempfile.open("expect") do |a|
|
75
|
+
# a.puts expect
|
76
|
+
# a.flush
|
77
|
+
#
|
78
|
+
# Tempfile.open("butwas") do |b|
|
79
|
+
# b.puts butwas
|
80
|
+
# b.flush
|
81
|
+
#
|
82
|
+
# result = `#{Minitest::Assertions.diff} #{a.path} #{b.path}`
|
83
|
+
# result.sub!(/^\-\-\- .+/, "--- expected")
|
84
|
+
# result.sub!(/^\+\+\+ .+/, "+++ actual")
|
85
|
+
#
|
86
|
+
# if result.empty? then
|
87
|
+
# klass = exp.class
|
88
|
+
# result = [
|
89
|
+
# "No visible difference in the #{klass}#inspect output.\n",
|
90
|
+
# "You should look at the implementation of #== on ",
|
91
|
+
# "#{klass} or its members.\n",
|
92
|
+
# expect,
|
93
|
+
# ].join
|
94
|
+
# end
|
95
|
+
# end
|
96
|
+
# end
|
97
|
+
|
98
|
+
result
|
99
|
+
end
|
100
|
+
|
101
|
+
##
|
102
|
+
# This returns a human-readable version of +obj+. By default
|
103
|
+
# #inspect is called. You can override this to use #pretty_print
|
104
|
+
# if you want.
|
105
|
+
|
106
|
+
def mu_pp obj
|
107
|
+
s = obj.inspect
|
108
|
+
s = s.encode Encoding.default_external if defined? Encoding
|
109
|
+
s
|
110
|
+
end
|
111
|
+
|
112
|
+
##
|
113
|
+
# This returns a diff-able human-readable version of +obj+. This
|
114
|
+
# differs from the regular mu_pp because it expands escaped
|
115
|
+
# newlines and makes hex-values generic (like object_ids). This
|
116
|
+
# uses mu_pp to do the first pass and then cleans it up.
|
117
|
+
|
118
|
+
def mu_pp_for_diff obj
|
119
|
+
mu_pp(obj).gsub(/\\n/, "\n").gsub(/:0x[a-fA-F0-9]{4,}/m, ':0xXXXXXX')
|
120
|
+
end
|
121
|
+
|
122
|
+
##
|
123
|
+
# Fails unless +test+ is truthy.
|
124
|
+
|
125
|
+
def assert test, msg = nil
|
126
|
+
self.assertions += 1
|
127
|
+
unless test then
|
128
|
+
msg ||= "Failed assertion, no message given."
|
129
|
+
msg = msg.call if Proc === msg
|
130
|
+
raise Minitest::Assertion, msg
|
131
|
+
end
|
132
|
+
true
|
133
|
+
end
|
134
|
+
|
135
|
+
def _synchronize # :nodoc:
|
136
|
+
yield
|
137
|
+
end
|
138
|
+
|
139
|
+
##
|
140
|
+
# Fails unless +obj+ is empty.
|
141
|
+
|
142
|
+
def assert_empty obj, msg = nil
|
143
|
+
msg = message(msg) { "Expected #{mu_pp(obj)} to be empty" }
|
144
|
+
assert_respond_to obj, :empty?
|
145
|
+
assert obj.empty?, msg
|
146
|
+
end
|
147
|
+
|
148
|
+
E = "" # :nodoc:
|
149
|
+
|
150
|
+
##
|
151
|
+
# Fails unless <tt>exp == act</tt> printing the difference between
|
152
|
+
# the two, if possible.
|
153
|
+
#
|
154
|
+
# If there is no visible difference but the assertion fails, you
|
155
|
+
# should suspect that your #== is buggy, or your inspect output is
|
156
|
+
# missing crucial details.
|
157
|
+
#
|
158
|
+
# For floats use assert_in_delta.
|
159
|
+
#
|
160
|
+
# See also: Minitest::Assertions.diff
|
161
|
+
|
162
|
+
def assert_equal exp, act, msg = nil
|
163
|
+
msg = message(msg, E) { diff exp, act }
|
164
|
+
assert exp == act, msg
|
165
|
+
end
|
166
|
+
|
167
|
+
##
|
168
|
+
# For comparing Floats. Fails unless +exp+ and +act+ are within +delta+
|
169
|
+
# of each other.
|
170
|
+
#
|
171
|
+
# assert_in_delta Math::PI, (22.0 / 7.0), 0.01
|
172
|
+
|
173
|
+
def assert_in_delta exp, act, delta = 0.001, msg = nil
|
174
|
+
n = (exp - act).abs
|
175
|
+
msg = message(msg) {
|
176
|
+
"Expected |#{exp} - #{act}| (#{n}) to be <= #{delta}"
|
177
|
+
}
|
178
|
+
assert delta >= n, msg
|
179
|
+
end
|
180
|
+
|
181
|
+
##
|
182
|
+
# For comparing Floats. Fails unless +exp+ and +act+ have a relative
|
183
|
+
# error less than +epsilon+.
|
184
|
+
|
185
|
+
def assert_in_epsilon a, b, epsilon = 0.001, msg = nil
|
186
|
+
assert_in_delta a, b, [a.abs, b.abs].min * epsilon, msg
|
187
|
+
end
|
188
|
+
|
189
|
+
##
|
190
|
+
# Fails unless +collection+ includes +obj+.
|
191
|
+
|
192
|
+
def assert_includes collection, obj, msg = nil
|
193
|
+
msg = message(msg) {
|
194
|
+
"Expected #{mu_pp(collection)} to include #{mu_pp(obj)}"
|
195
|
+
}
|
196
|
+
assert_respond_to collection, :include?
|
197
|
+
assert collection.include?(obj), msg
|
198
|
+
end
|
199
|
+
|
200
|
+
##
|
201
|
+
# Fails unless +obj+ is an instance of +cls+.
|
202
|
+
|
203
|
+
def assert_instance_of cls, obj, msg = nil
|
204
|
+
msg = message(msg) {
|
205
|
+
"Expected #{mu_pp(obj)} to be an instance of #{cls}, not #{obj.class}"
|
206
|
+
}
|
207
|
+
|
208
|
+
assert obj.instance_of?(cls), msg
|
209
|
+
end
|
210
|
+
|
211
|
+
##
|
212
|
+
# Fails unless +obj+ is a kind of +cls+.
|
213
|
+
|
214
|
+
def assert_kind_of cls, obj, msg = nil
|
215
|
+
msg = message(msg) {
|
216
|
+
"Expected #{mu_pp(obj)} to be a kind of #{cls}, not #{obj.class}" }
|
217
|
+
|
218
|
+
assert obj.kind_of?(cls), msg
|
219
|
+
end
|
220
|
+
|
221
|
+
##
|
222
|
+
# Fails unless +matcher+ <tt>=~</tt> +obj+.
|
223
|
+
|
224
|
+
def assert_match matcher, obj, msg = nil
|
225
|
+
msg = message(msg) { "Expected #{mu_pp matcher} to match #{mu_pp obj}" }
|
226
|
+
assert_respond_to matcher, :"=~"
|
227
|
+
matcher = Regexp.new Regexp.escape matcher if String === matcher
|
228
|
+
assert matcher =~ obj, msg
|
229
|
+
end
|
230
|
+
|
231
|
+
##
|
232
|
+
# Fails unless +obj+ is nil
|
233
|
+
|
234
|
+
def assert_nil obj, msg = nil
|
235
|
+
msg = message(msg) { "Expected #{mu_pp(obj)} to be nil" }
|
236
|
+
assert obj.nil?, msg
|
237
|
+
end
|
238
|
+
|
239
|
+
##
|
240
|
+
# For testing with binary operators. Eg:
|
241
|
+
#
|
242
|
+
# assert_operator 5, :<=, 4
|
243
|
+
|
244
|
+
def assert_operator o1, op, o2 = UNDEFINED, msg = nil
|
245
|
+
return assert_predicate o1, op, msg if UNDEFINED == o2
|
246
|
+
msg = message(msg) { "Expected #{mu_pp(o1)} to be #{op} #{mu_pp(o2)}" }
|
247
|
+
assert o1.__send__(op, o2), msg
|
248
|
+
end
|
249
|
+
|
250
|
+
##
|
251
|
+
# Fails if stdout or stderr do not output the expected results.
|
252
|
+
# Pass in nil if you don't care about that streams output. Pass in
|
253
|
+
# "" if you require it to be silent. Pass in a regexp if you want
|
254
|
+
# to pattern match.
|
255
|
+
#
|
256
|
+
# NOTE: this uses #capture_io, not #capture_subprocess_io.
|
257
|
+
#
|
258
|
+
# See also: #assert_silent
|
259
|
+
|
260
|
+
def assert_output stdout = nil, stderr = nil
|
261
|
+
out, err = capture_io do
|
262
|
+
yield
|
263
|
+
end
|
264
|
+
|
265
|
+
err_msg = Regexp === stderr ? :assert_match : :assert_equal if stderr
|
266
|
+
out_msg = Regexp === stdout ? :assert_match : :assert_equal if stdout
|
267
|
+
|
268
|
+
y = send err_msg, stderr, err, "In stderr" if err_msg
|
269
|
+
x = send out_msg, stdout, out, "In stdout" if out_msg
|
270
|
+
|
271
|
+
(!stdout || x) && (!stderr || y)
|
272
|
+
end
|
273
|
+
|
274
|
+
##
|
275
|
+
# For testing with predicates. Eg:
|
276
|
+
#
|
277
|
+
# assert_predicate str, :empty?
|
278
|
+
#
|
279
|
+
# This is really meant for specs and is front-ended by assert_operator:
|
280
|
+
#
|
281
|
+
# str.must_be :empty?
|
282
|
+
|
283
|
+
def assert_predicate o1, op, msg = nil
|
284
|
+
msg = message(msg) { "Expected #{mu_pp(o1)} to be #{op}" }
|
285
|
+
assert o1.__send__(op), msg
|
286
|
+
end
|
287
|
+
|
288
|
+
##
|
289
|
+
# Fails unless the block raises one of +exp+. Returns the
|
290
|
+
# exception matched so you can check the message, attributes, etc.
|
291
|
+
|
292
|
+
def assert_raises *exp
|
293
|
+
msg = "#{exp.pop}.\n" if String === exp.last
|
294
|
+
|
295
|
+
begin
|
296
|
+
yield
|
297
|
+
rescue Minitest::Skip => e
|
298
|
+
return e if exp.include? Minitest::Skip
|
299
|
+
raise e
|
300
|
+
rescue Exception => e
|
301
|
+
expected = exp.any? { |ex|
|
302
|
+
if ex.instance_of? Module then
|
303
|
+
e.kind_of? ex
|
304
|
+
else
|
305
|
+
e.instance_of? ex
|
306
|
+
end
|
307
|
+
}
|
308
|
+
|
309
|
+
assert expected, proc {
|
310
|
+
exception_details(e, "#{msg}#{mu_pp(exp)} exception expected, not")
|
311
|
+
}
|
312
|
+
|
313
|
+
return e
|
314
|
+
end
|
315
|
+
|
316
|
+
exp = exp.first if exp.size == 1
|
317
|
+
|
318
|
+
flunk "#{msg}#{mu_pp(exp)} expected but nothing was raised."
|
319
|
+
end
|
320
|
+
|
321
|
+
##
|
322
|
+
# Fails unless +obj+ responds to +meth+.
|
323
|
+
|
324
|
+
def assert_respond_to obj, meth, msg = nil
|
325
|
+
msg = message(msg) {
|
326
|
+
"Expected #{mu_pp(obj)} (#{obj.class}) to respond to ##{meth}"
|
327
|
+
}
|
328
|
+
assert obj.respond_to?(meth), msg
|
329
|
+
end
|
330
|
+
|
331
|
+
##
|
332
|
+
# Fails unless +exp+ and +act+ are #equal?
|
333
|
+
|
334
|
+
def assert_same exp, act, msg = nil
|
335
|
+
msg = message(msg) {
|
336
|
+
data = [mu_pp(act), act.object_id, mu_pp(exp), exp.object_id]
|
337
|
+
"Expected %s (oid=%d) to be the same as %s (oid=%d)" % data
|
338
|
+
}
|
339
|
+
assert exp.equal?(act), msg
|
340
|
+
end
|
341
|
+
|
342
|
+
##
|
343
|
+
# +send_ary+ is a receiver, message and arguments.
|
344
|
+
#
|
345
|
+
# Fails unless the call returns a true value
|
346
|
+
|
347
|
+
def assert_send send_ary, m = nil
|
348
|
+
recv, msg, *args = send_ary
|
349
|
+
m = message(m) {
|
350
|
+
"Expected #{mu_pp(recv)}.#{msg}(*#{mu_pp(args)}) to return true" }
|
351
|
+
assert recv.__send__(msg, *args), m
|
352
|
+
end
|
353
|
+
|
354
|
+
##
|
355
|
+
# Fails if the block outputs anything to stderr or stdout.
|
356
|
+
#
|
357
|
+
# See also: #assert_output
|
358
|
+
|
359
|
+
def assert_silent
|
360
|
+
assert_output "", "" do
|
361
|
+
yield
|
362
|
+
end
|
363
|
+
end
|
364
|
+
|
365
|
+
##
|
366
|
+
# Fails unless the block throws +sym+
|
367
|
+
|
368
|
+
def assert_throws sym, msg = nil
|
369
|
+
default = "Expected #{mu_pp(sym)} to have been thrown"
|
370
|
+
caught = true
|
371
|
+
catch(sym) do
|
372
|
+
begin
|
373
|
+
yield
|
374
|
+
rescue ThreadError => e # wtf?!? 1.8 + threads == suck
|
375
|
+
default += ", not \:#{e.message[/uncaught throw \`(\w+?)\'/, 1]}"
|
376
|
+
rescue ArgumentError => e # 1.9 exception
|
377
|
+
default += ", not #{e.message.split(/ /).last}"
|
378
|
+
rescue NameError => e # 1.8 exception
|
379
|
+
default += ", not #{e.name.inspect}"
|
380
|
+
end
|
381
|
+
caught = false
|
382
|
+
end
|
383
|
+
|
384
|
+
assert caught, message(msg) { default }
|
385
|
+
end
|
386
|
+
|
387
|
+
##
|
388
|
+
# Captures $stdout and $stderr into strings:
|
389
|
+
#
|
390
|
+
# out, err = capture_io do
|
391
|
+
# puts "Some info"
|
392
|
+
# warn "You did a bad thing"
|
393
|
+
# end
|
394
|
+
#
|
395
|
+
# assert_match %r%info%, out
|
396
|
+
# assert_match %r%bad%, err
|
397
|
+
#
|
398
|
+
# NOTE: For efficiency, this method uses StringIO and does not
|
399
|
+
# capture IO for subprocesses. Use #capture_subprocess_io for
|
400
|
+
# that.
|
401
|
+
|
402
|
+
def capture_io
|
403
|
+
_synchronize do
|
404
|
+
begin
|
405
|
+
captured_stdout, captured_stderr = StringIO.new, StringIO.new
|
406
|
+
|
407
|
+
orig_stdout, orig_stderr = $stdout, $stderr
|
408
|
+
$stdout, $stderr = captured_stdout, captured_stderr
|
409
|
+
|
410
|
+
yield
|
411
|
+
|
412
|
+
return captured_stdout.string, captured_stderr.string
|
413
|
+
ensure
|
414
|
+
$stdout = orig_stdout
|
415
|
+
$stderr = orig_stderr
|
416
|
+
end
|
417
|
+
end
|
418
|
+
end
|
419
|
+
|
420
|
+
##
|
421
|
+
# Captures $stdout and $stderr into strings, using Tempfile to
|
422
|
+
# ensure that subprocess IO is captured as well.
|
423
|
+
#
|
424
|
+
# out, err = capture_subprocess_io do
|
425
|
+
# system "echo Some info"
|
426
|
+
# system "echo You did a bad thing 1>&2"
|
427
|
+
# end
|
428
|
+
#
|
429
|
+
# assert_match %r%info%, out
|
430
|
+
# assert_match %r%bad%, err
|
431
|
+
#
|
432
|
+
# NOTE: This method is approximately 10x slower than #capture_io so
|
433
|
+
# only use it when you need to test the output of a subprocess.
|
434
|
+
|
435
|
+
def capture_subprocess_io
|
436
|
+
_synchronize do
|
437
|
+
begin
|
438
|
+
require 'tempfile'
|
439
|
+
|
440
|
+
captured_stdout, captured_stderr = Tempfile.new("out"), Tempfile.new("err")
|
441
|
+
|
442
|
+
orig_stdout, orig_stderr = $stdout.dup, $stderr.dup
|
443
|
+
$stdout.reopen captured_stdout
|
444
|
+
$stderr.reopen captured_stderr
|
445
|
+
|
446
|
+
yield
|
447
|
+
|
448
|
+
$stdout.rewind
|
449
|
+
$stderr.rewind
|
450
|
+
|
451
|
+
return captured_stdout.read, captured_stderr.read
|
452
|
+
ensure
|
453
|
+
captured_stdout.unlink
|
454
|
+
captured_stderr.unlink
|
455
|
+
$stdout.reopen orig_stdout
|
456
|
+
$stderr.reopen orig_stderr
|
457
|
+
end
|
458
|
+
end
|
459
|
+
end
|
460
|
+
|
461
|
+
##
|
462
|
+
# Returns details for exception +e+
|
463
|
+
|
464
|
+
def exception_details e, msg
|
465
|
+
[
|
466
|
+
"#{msg}",
|
467
|
+
"Class: <#{e.class}>",
|
468
|
+
"Message: <#{e.message.inspect}>",
|
469
|
+
"---Backtrace---",
|
470
|
+
"#{Minitest::filter_backtrace(e.backtrace).join("\n")}",
|
471
|
+
"---------------",
|
472
|
+
].join "\n"
|
473
|
+
end
|
474
|
+
|
475
|
+
##
|
476
|
+
# Fails with +msg+
|
477
|
+
|
478
|
+
def flunk msg = nil
|
479
|
+
msg ||= "Epic Fail!"
|
480
|
+
assert false, msg
|
481
|
+
end
|
482
|
+
|
483
|
+
##
|
484
|
+
# Returns a proc that will output +msg+ along with the default message.
|
485
|
+
|
486
|
+
def message msg = nil, ending = nil, &default
|
487
|
+
proc {
|
488
|
+
msg = msg.call.chomp(".") if Proc === msg
|
489
|
+
custom_message = "#{msg}.\n" unless msg.nil? or msg.to_s.empty?
|
490
|
+
"#{custom_message}#{default.call}#{ending || "."}"
|
491
|
+
}
|
492
|
+
end
|
493
|
+
|
494
|
+
##
|
495
|
+
# used for counting assertions
|
496
|
+
|
497
|
+
def pass msg = nil
|
498
|
+
assert true
|
499
|
+
end
|
500
|
+
|
501
|
+
##
|
502
|
+
# Fails if +test+ is truthy.
|
503
|
+
|
504
|
+
def refute test, msg = nil
|
505
|
+
msg ||= "Failed refutation, no message given"
|
506
|
+
not assert(! test, msg)
|
507
|
+
end
|
508
|
+
|
509
|
+
##
|
510
|
+
# Fails if +obj+ is empty.
|
511
|
+
|
512
|
+
def refute_empty obj, msg = nil
|
513
|
+
msg = message(msg) { "Expected #{mu_pp(obj)} to not be empty" }
|
514
|
+
assert_respond_to obj, :empty?
|
515
|
+
refute obj.empty?, msg
|
516
|
+
end
|
517
|
+
|
518
|
+
##
|
519
|
+
# Fails if <tt>exp == act</tt>.
|
520
|
+
#
|
521
|
+
# For floats use refute_in_delta.
|
522
|
+
|
523
|
+
def refute_equal exp, act, msg = nil
|
524
|
+
msg = message(msg) {
|
525
|
+
"Expected #{mu_pp(act)} to not be equal to #{mu_pp(exp)}"
|
526
|
+
}
|
527
|
+
refute exp == act, msg
|
528
|
+
end
|
529
|
+
|
530
|
+
##
|
531
|
+
# For comparing Floats. Fails if +exp+ is within +delta+ of +act+.
|
532
|
+
#
|
533
|
+
# refute_in_delta Math::PI, (22.0 / 7.0)
|
534
|
+
|
535
|
+
def refute_in_delta exp, act, delta = 0.001, msg = nil
|
536
|
+
n = (exp - act).abs
|
537
|
+
msg = message(msg) {
|
538
|
+
"Expected |#{exp} - #{act}| (#{n}) to not be <= #{delta}"
|
539
|
+
}
|
540
|
+
refute delta >= n, msg
|
541
|
+
end
|
542
|
+
|
543
|
+
##
|
544
|
+
# For comparing Floats. Fails if +exp+ and +act+ have a relative error
|
545
|
+
# less than +epsilon+.
|
546
|
+
|
547
|
+
def refute_in_epsilon a, b, epsilon = 0.001, msg = nil
|
548
|
+
refute_in_delta a, b, a * epsilon, msg
|
549
|
+
end
|
550
|
+
|
551
|
+
##
|
552
|
+
# Fails if +collection+ includes +obj+.
|
553
|
+
|
554
|
+
def refute_includes collection, obj, msg = nil
|
555
|
+
msg = message(msg) {
|
556
|
+
"Expected #{mu_pp(collection)} to not include #{mu_pp(obj)}"
|
557
|
+
}
|
558
|
+
assert_respond_to collection, :include?
|
559
|
+
refute collection.include?(obj), msg
|
560
|
+
end
|
561
|
+
|
562
|
+
##
|
563
|
+
# Fails if +obj+ is an instance of +cls+.
|
564
|
+
|
565
|
+
def refute_instance_of cls, obj, msg = nil
|
566
|
+
msg = message(msg) {
|
567
|
+
"Expected #{mu_pp(obj)} to not be an instance of #{cls}"
|
568
|
+
}
|
569
|
+
refute obj.instance_of?(cls), msg
|
570
|
+
end
|
571
|
+
|
572
|
+
##
|
573
|
+
# Fails if +obj+ is a kind of +cls+.
|
574
|
+
|
575
|
+
def refute_kind_of cls, obj, msg = nil
|
576
|
+
msg = message(msg) { "Expected #{mu_pp(obj)} to not be a kind of #{cls}" }
|
577
|
+
refute obj.kind_of?(cls), msg
|
578
|
+
end
|
579
|
+
|
580
|
+
##
|
581
|
+
# Fails if +matcher+ <tt>=~</tt> +obj+.
|
582
|
+
|
583
|
+
def refute_match matcher, obj, msg = nil
|
584
|
+
msg = message(msg) {"Expected #{mu_pp matcher} to not match #{mu_pp obj}"}
|
585
|
+
assert_respond_to matcher, :"=~"
|
586
|
+
matcher = Regexp.new Regexp.escape matcher if String === matcher
|
587
|
+
refute matcher =~ obj, msg
|
588
|
+
end
|
589
|
+
|
590
|
+
##
|
591
|
+
# Fails if +obj+ is nil.
|
592
|
+
|
593
|
+
def refute_nil obj, msg = nil
|
594
|
+
msg = message(msg) { "Expected #{mu_pp(obj)} to not be nil" }
|
595
|
+
refute obj.nil?, msg
|
596
|
+
end
|
597
|
+
|
598
|
+
##
|
599
|
+
# Fails if +o1+ is not +op+ +o2+. Eg:
|
600
|
+
#
|
601
|
+
# refute_operator 1, :>, 2 #=> pass
|
602
|
+
# refute_operator 1, :<, 2 #=> fail
|
603
|
+
|
604
|
+
def refute_operator o1, op, o2 = UNDEFINED, msg = nil
|
605
|
+
return refute_predicate o1, op, msg if UNDEFINED == o2
|
606
|
+
msg = message(msg) { "Expected #{mu_pp(o1)} to not be #{op} #{mu_pp(o2)}"}
|
607
|
+
refute o1.__send__(op, o2), msg
|
608
|
+
end
|
609
|
+
|
610
|
+
##
|
611
|
+
# For testing with predicates.
|
612
|
+
#
|
613
|
+
# refute_predicate str, :empty?
|
614
|
+
#
|
615
|
+
# This is really meant for specs and is front-ended by refute_operator:
|
616
|
+
#
|
617
|
+
# str.wont_be :empty?
|
618
|
+
|
619
|
+
def refute_predicate o1, op, msg = nil
|
620
|
+
msg = message(msg) { "Expected #{mu_pp(o1)} to not be #{op}" }
|
621
|
+
refute o1.__send__(op), msg
|
622
|
+
end
|
623
|
+
|
624
|
+
##
|
625
|
+
# Fails if +obj+ responds to the message +meth+.
|
626
|
+
|
627
|
+
def refute_respond_to obj, meth, msg = nil
|
628
|
+
msg = message(msg) { "Expected #{mu_pp(obj)} to not respond to #{meth}" }
|
629
|
+
|
630
|
+
refute obj.respond_to?(meth), msg
|
631
|
+
end
|
632
|
+
|
633
|
+
##
|
634
|
+
# Fails if +exp+ is the same (by object identity) as +act+.
|
635
|
+
|
636
|
+
def refute_same exp, act, msg = nil
|
637
|
+
msg = message(msg) {
|
638
|
+
data = [mu_pp(act), act.object_id, mu_pp(exp), exp.object_id]
|
639
|
+
"Expected %s (oid=%d) to not be the same as %s (oid=%d)" % data
|
640
|
+
}
|
641
|
+
refute exp.equal?(act), msg
|
642
|
+
end
|
643
|
+
|
644
|
+
##
|
645
|
+
# Skips the current run. If run in verbose-mode, the skipped run
|
646
|
+
# gets listed at the end of the run but doesn't cause a failure
|
647
|
+
# exit code.
|
648
|
+
|
649
|
+
def skip msg = nil, bt = caller
|
650
|
+
msg ||= "Skipped, no message given"
|
651
|
+
@skip = true
|
652
|
+
raise Minitest::Skip, msg, bt
|
653
|
+
end
|
654
|
+
|
655
|
+
##
|
656
|
+
# Was this testcase skipped? Meant for #teardown.
|
657
|
+
|
658
|
+
def skipped?
|
659
|
+
defined?(@skip) and @skip
|
660
|
+
end
|
661
|
+
end
|
662
|
+
end
|