From edee53f93d3e48d8f84d8aea1c8b4b3c709e41e2 Mon Sep 17 00:00:00 2001 From: Bob Nystrom Date: Thu, 21 Sep 2017 18:29:40 +0000 Subject: [PATCH] Bring back the deleted 1.0 corelib tests. What is dead may never die. Change-Id: I80ef766b8ce2b6e1416df8e1f9b91fb74169dc79 Reviewed-on: https://dart-review.googlesource.com/7483 Reviewed-by: William Hesse --- PRESUBMIT.py | 1 + tests/corelib/apply2_test.dart | 96 + tests/corelib/apply3_test.dart | 69 + tests/corelib/apply4_test.dart | 20 + tests/corelib/apply5_test.dart | 23 + tests/corelib/apply_test.dart | 76 + tests/corelib/big_integer_arith_vm_test.dart | 447 + .../corelib/big_integer_huge_mul_vm_test.dart | 25 + .../big_integer_parsed_arith_vm_test.dart | 601 ++ .../big_integer_parsed_div_rem_vm_test.dart | 111 + .../big_integer_parsed_mul_div_vm_test.dart | 804 ++ tests/corelib/bit_twiddling_bigint_test.dart | 61 + tests/corelib/bit_twiddling_test.dart | 173 + .../corelib/bool_from_environment2_test.dart | 11 + tests/corelib/bool_from_environment_test.dart | 15 + tests/corelib/bool_hashcode_test.dart | 15 + tests/corelib/collection_from_test.dart | 44 + tests/corelib/collection_length_test.dart | 76 + tests/corelib/collection_removes_test.dart | 130 + tests/corelib/collection_test.dart | 41 + tests/corelib/collection_to_string_test.dart | 387 + tests/corelib/compare_to2_test.dart | 94 + tests/corelib/compare_to_test.dart | 136 + tests/corelib/const_list_literal_test.dart | 80 + .../corelib/const_list_remove_range_test.dart | 27 + tests/corelib/const_list_set_range_test.dart | 51 + tests/corelib/core_runtime_types_test.dart | 342 + tests/corelib/corelib.status | 787 ++ tests/corelib/data_uri_test.dart | 335 + tests/corelib/date_time10_test.dart | 54 + tests/corelib/date_time2_test.dart | 16 + tests/corelib/date_time3_test.dart | 14 + tests/corelib/date_time4_test.dart | 104 + tests/corelib/date_time5_test.dart | 81 + tests/corelib/date_time6_test.dart | 31 + tests/corelib/date_time7_test.dart | 50 + tests/corelib/date_time8_test.dart | 22 + tests/corelib/date_time9_test.dart | 42 + tests/corelib/date_time_parse_test.dart | 52 + tests/corelib/date_time_test.dart | 1380 ++++ tests/corelib/double_ceil2_test.dart | 12 + tests/corelib/double_ceil_test.dart | 84 + tests/corelib/double_ceil_to_double_test.dart | 93 + tests/corelib/double_compare_test.dart | 49 + tests/corelib/double_floor2_test.dart | 12 + tests/corelib/double_floor_test.dart | 84 + .../corelib/double_floor_to_double_test.dart | 85 + tests/corelib/double_parse_test.dart | 1196 +++ tests/corelib/double_round2_test.dart | 12 + tests/corelib/double_round3_test.dart | 12 + tests/corelib/double_round4_test.dart | 38 + tests/corelib/double_round_test.dart | 54 + .../corelib/double_round_to_double2_test.dart | 13 + .../corelib/double_round_to_double3_test.dart | 34 + .../corelib/double_round_to_double_test.dart | 62 + tests/corelib/double_truncate2_test.dart | 12 + tests/corelib/double_truncate_test.dart | 92 + .../double_truncate_to_double_test.dart | 85 + tests/corelib/duration2_test.dart | 27 + tests/corelib/duration_big_num_test.dart | 21 + .../duration_double_multiplication_test.dart | 19 + tests/corelib/duration_test.dart | 293 + tests/corelib/error_stack_trace1_test.dart | 40 + tests/corelib/error_stack_trace2_test.dart | 29 + tests/corelib/error_stack_trace_test.dart | 83 + tests/corelib/errors_test.dart | 77 + .../exception_implementation_test.dart | 18 + tests/corelib/expando_test.dart | 116 + tests/corelib/expression_test.dart | 117 + tests/corelib/for_in_test.dart | 96 + tests/corelib/format_exception_test.dart | 108 + .../from_environment_const_type_test.dart | 43 + ...environment_const_type_undefined_test.dart | 42 + tests/corelib/growable_list_test.dart | 187 + tests/corelib/has_next_iterator_test.dart | 37 + tests/corelib/hash_map2_test.dart | 308 + tests/corelib/hash_map_test.dart | 23 + tests/corelib/hash_set_test.dart | 363 + tests/corelib/hash_set_type_check_test.dart | 47 + tests/corelib/hashcode_boxed_test.dart | 21 + tests/corelib/hashcode_test.dart | 48 + tests/corelib/hidden_library2_test.dart | 15 + tests/corelib/indexed_list_access_test.dart | 50 + tests/corelib/int_ceil_test.dart | 39 + tests/corelib/int_ceil_to_double_test.dart | 39 + tests/corelib/int_floor_test.dart | 39 + tests/corelib/int_floor_to_double_test.dart | 39 + tests/corelib/int_from_environment2_test.dart | 14 + tests/corelib/int_from_environment3_test.dart | 11 + tests/corelib/int_from_environment_test.dart | 15 + tests/corelib/int_modulo_arith_test.dart | 197 + .../int_parse_radix_bad_handler_test.dart | 15 + tests/corelib/int_parse_radix_test.dart | 147 + tests/corelib/int_round_test.dart | 39 + tests/corelib/int_round_to_double_test.dart | 39 + tests/corelib/int_to_int_test.dart | 39 + tests/corelib/int_truncate_test.dart | 39 + .../corelib/int_truncate_to_double_test.dart | 39 + .../corelib/integer_to_radix_string_test.dart | 95 + tests/corelib/integer_to_string_test.dart | 89 + .../corelib/is_operator_basic_types_test.dart | 61 + tests/corelib/iterable_contains2_test.dart | 38 + tests/corelib/iterable_contains_test.dart | 48 + tests/corelib/iterable_element_at_test.dart | 42 + tests/corelib/iterable_empty_test.dart | 71 + tests/corelib/iterable_expand_test.dart | 74 + tests/corelib/iterable_first_test.dart | 22 + tests/corelib/iterable_first_where_test.dart | 43 + tests/corelib/iterable_fold_test.dart | 202 + tests/corelib/iterable_generate_test.dart | 79 + tests/corelib/iterable_join_test.dart | 148 + tests/corelib/iterable_last_test.dart | 22 + tests/corelib/iterable_last_where_test.dart | 43 + tests/corelib/iterable_length_test.dart | 44 + tests/corelib/iterable_mapping_test.dart | 50 + tests/corelib/iterable_reduce_test.dart | 205 + tests/corelib/iterable_return_type_test.dart | 90 + tests/corelib/iterable_single_test.dart | 31 + tests/corelib/iterable_single_where_test.dart | 32 + tests/corelib/iterable_skip_test.dart | 258 + tests/corelib/iterable_skip_while_test.dart | 146 + tests/corelib/iterable_take_test.dart | 227 + tests/corelib/iterable_take_while_test.dart | 130 + tests/corelib/iterable_test.dart | 18 + tests/corelib/iterable_to_list_test.dart | 73 + tests/corelib/iterable_to_set_test.dart | 53 + tests/corelib/iterable_tostring_test.dart | 106 + tests/corelib/json_map_test.dart | 334 + .../linked_hash_map_from_iterable_test.dart | 117 + .../linked_hash_map_from_iterables_test.dart | 79 + tests/corelib/linked_hash_map_test.dart | 116 + tests/corelib/list_as_map_test.dart | 96 + .../list_contains_argument_order_test.dart | 40 + tests/corelib/list_fill_range_test.dart | 80 + .../list_filled_type_argument_test.dart | 15 + tests/corelib/list_first_test.dart | 20 + tests/corelib/list_fixed_test.dart | 29 + tests/corelib/list_for_each_test.dart | 67 + tests/corelib/list_get_range_test.dart | 82 + tests/corelib/list_growable_test.dart | 38 + tests/corelib/list_index_of2_test.dart | 32 + tests/corelib/list_index_of_test.dart | 35 + tests/corelib/list_insert_all_test.dart | 90 + tests/corelib/list_insert_test.dart | 79 + tests/corelib/list_iterators_test.dart | 50 + tests/corelib/list_last_test.dart | 20 + .../list_literal_is_growable_test.dart | 12 + tests/corelib/list_literal_test.dart | 24 + tests/corelib/list_map_test.dart | 164 + tests/corelib/list_remove_range_test.dart | 80 + tests/corelib/list_removeat_test.dart | 81 + tests/corelib/list_replace_range_test.dart | 123 + tests/corelib/list_reversed_test.dart | 136 + tests/corelib/list_set_all_test.dart | 103 + tests/corelib/list_set_range_test.dart | 120 + tests/corelib/list_sort_test.dart | 24 + tests/corelib/list_sublist_test.dart | 57 + tests/corelib/list_test.dart | 633 ++ tests/corelib/list_to_string2_test.dart | 32 + tests/corelib/list_to_string_test.dart | 31 + tests/corelib/list_unmodifiable_test.dart | 304 + tests/corelib/main_test.dart | 11 + tests/corelib/map_contains_key_test.dart | 27 + tests/corelib/map_contains_value_test.dart | 28 + tests/corelib/map_from_iterable_test.dart | 111 + tests/corelib/map_from_iterables_test.dart | 78 + tests/corelib/map_from_test.dart | 101 + tests/corelib/map_index_test.dart | 27 + tests/corelib/map_keys2_test.dart | 34 + tests/corelib/map_keys_test.dart | 47 + tests/corelib/map_remove_test.dart | 27 + tests/corelib/map_test.dart | 974 +++ tests/corelib/map_to_string_test.dart | 32 + tests/corelib/map_values2_test.dart | 53 + tests/corelib/map_values3_test.dart | 53 + tests/corelib/map_values4_test.dart | 15 + tests/corelib/map_values_test.dart | 47 + tests/corelib/maps_test.dart | 138 + tests/corelib/nan_infinity_test.dart | 90 + tests/corelib/null_nosuchmethod_test.dart | 21 + tests/corelib/null_test.dart | 32 + tests/corelib/num_clamp_test.dart | 80 + tests/corelib/num_parse_test.dart | 234 + tests/corelib/num_sign_test.dart | 109 + tests/corelib/print_test.dart | 21 + tests/corelib/queue_first_test.dart | 17 + tests/corelib/queue_iterator_test.dart | 61 + tests/corelib/queue_last_test.dart | 17 + tests/corelib/queue_single_test.dart | 20 + tests/corelib/queue_test.dart | 488 ++ tests/corelib/range_error_test.dart | 94 + tests/corelib/reg_exp1_test.dart | 31 + tests/corelib/reg_exp4_test.dart | 49 + tests/corelib/reg_exp5_test.dart | 25 + tests/corelib/reg_exp_all_matches_test.dart | 118 + tests/corelib/reg_exp_first_match_test.dart | 18 + tests/corelib/reg_exp_group_test.dart | 22 + tests/corelib/reg_exp_groups_test.dart | 22 + tests/corelib/reg_exp_has_match_test.dart | 19 + tests/corelib/reg_exp_pattern_test.dart | 27 + tests/corelib/reg_exp_start_end_test.dart | 19 + tests/corelib/reg_exp_string_match_test.dart | 18 + tests/corelib/regexp/UC16_test.dart | 71 + ...lternative-length-miscalculation_test.dart | 37 + tests/corelib/regexp/alternatives_test.dart | 52 + .../regexp/ascii-regexp-subject_test.dart | 54 + tests/corelib/regexp/assertion_test.dart | 117 + tests/corelib/regexp/backreferences_test.dart | 47 + .../regexp/bol-with-multiline_test.dart | 40 + tests/corelib/regexp/bol_test.dart | 54 + tests/corelib/regexp/capture-3_test.dart | 130 + tests/corelib/regexp/capture_test.dart | 57 + tests/corelib/regexp/captures_test.dart | 37 + .../corelib/regexp/char-insensitive_test.dart | 68 + .../character-match-out-of-order_test.dart | 33 + tests/corelib/regexp/compile-crash_test.dart | 38 + tests/corelib/regexp/compile_test.dart | 42 + tests/corelib/regexp/constructor_test.dart | 43 + .../regexp/default_arguments_test.dart | 35 + tests/corelib/regexp/dotstar_test.dart | 166 + tests/corelib/regexp/early-acid3-86_test.dart | 38 + .../regexp/ecma-regex-examples_test.dart | 71 + .../extended-characters-match_test.dart | 45 + .../regexp/extended-characters-more_test.dart | 40 + .../regexp/find-first-asserted_test.dart | 37 + tests/corelib/regexp/global_test.dart | 184 + tests/corelib/regexp/indexof_test.dart | 105 + .../regexp/invalid-range-in-class_test.dart | 54 + tests/corelib/regexp/issue_19193_test.dart | 12 + tests/corelib/regexp/lastindex_test.dart | 44 + tests/corelib/regexp/look-ahead_test.dart | 34 + tests/corelib/regexp/lookahead_test.dart | 162 + tests/corelib/regexp/loop-capture_test.dart | 36 + .../regexp/malformed-escapes_test.dart | 59 + tests/corelib/regexp/many-brackets_test.dart | 44 + tests/corelib/regexp/multiline_test.dart | 114 + .../negative-special-characters_test.dart | 95 + tests/corelib/regexp/no-extensions_test.dart | 94 + tests/corelib/regexp/non-bmp_test.dart | 51 + .../non-capturing-backtracking_test.dart | 34 + .../regexp/non-capturing-groups_test.dart | 49 + tests/corelib/regexp/non-character_test.dart | 46 + .../regexp/non-greedy-parentheses_test.dart | 41 + tests/corelib/regexp/norepeat_test.dart | 34 + tests/corelib/regexp/overflow_test.dart | 45 + tests/corelib/regexp/parentheses_test.dart | 358 + tests/corelib/regexp/pcre-test-4_test.dart | 1031 +++ tests/corelib/regexp/pcre_test.dart | 7225 +++++++++++++++++ .../regexp/quantified-assertions_test.dart | 46 + .../corelib/regexp/range-bound-ffff_test.dart | 35 + .../regexp/range-out-of-order_test.dart | 33 + .../ranges-and-escaped-hyphens_test.dart | 81 + tests/corelib/regexp/regexp_kde_test.dart | 118 + tests/corelib/regexp/regexp_test.dart | 622 ++ .../regexp/regress-6-9-regexp_test.dart | 36 + .../regexp/regress-regexp-codeflush_test.dart | 61 + .../regress-regexp-construct-result_test.dart | 50 + .../regexp/repeat-match-waldemar_test.dart | 59 + tests/corelib/regexp/results-cache_test.dart | 81 + .../corelib/regexp/stack-overflow2_test.dart | 21 + tests/corelib/regexp/stack-overflow_test.dart | 39 + tests/corelib/regexp/standalones_test.dart | 84 + tests/corelib/regexp/toString_test.dart | 68 + .../corelib/regexp/unicode-handling_test.dart | 75 + .../regexp/unicodeCaseInsensitive_test.dart | 108 + tests/corelib/regexp/v8_regexp_utils.dart | 65 + .../regexp/zero-length-alternatives_test.dart | 279 + tests/corelib/regress_11099_test.dart | 16 + tests/corelib/regress_r21715_test.dart | 17 + tests/corelib/safe_to_string_test.dart | 35 + tests/corelib/set_containsAll_test.dart | 26 + tests/corelib/set_contains_test.dart | 28 + tests/corelib/set_intersection_test.dart | 31 + tests/corelib/set_iterator_test.dart | 146 + tests/corelib/set_removeAll_test.dart | 28 + tests/corelib/set_remove_test.dart | 28 + tests/corelib/set_retainAll_test.dart | 28 + tests/corelib/set_test.dart | 550 ++ tests/corelib/set_to_string_test.dart | 36 + tests/corelib/shuffle_test.dart | 129 + tests/corelib/sort_helper.dart | 152 + tests/corelib/sort_test.dart | 313 + .../splay_tree_from_iterable_test.dart | 167 + .../splay_tree_from_iterables_test.dart | 85 + tests/corelib/splay_tree_test.dart | 142 + tests/corelib/stacktrace_current_test.dart | 36 + tests/corelib/stacktrace_fromstring_test.dart | 45 + tests/corelib/stopwatch2_test.dart | 17 + tests/corelib/stopwatch_test.dart | 128 + tests/corelib/string_base_vm_test.dart | 83 + tests/corelib/string_buffer_test.dart | 239 + tests/corelib/string_case_test.dart | 55 + tests/corelib/string_codeunits_test.dart | 80 + .../string_from_environment2_test.dart | 12 + .../string_from_environment3_test.dart | 11 + .../corelib/string_from_environment_test.dart | 13 + tests/corelib/string_from_list_test.dart | 84 + tests/corelib/string_fromcharcode_test.dart | 31 + tests/corelib/string_fromcharcodes_test.dart | 292 + .../string_operations_with_null_test.dart | 17 + tests/corelib/string_pattern_test.dart | 111 + tests/corelib/string_replace_all_test.dart | 140 + tests/corelib/string_replace_dollar_test.dart | 27 + tests/corelib/string_replace_test.dart | 227 + tests/corelib/string_runes_test.dart | 84 + tests/corelib/string_source_test.dart | 35 + tests/corelib/string_split_test.dart | 135 + tests/corelib/string_substring_test.dart | 31 + tests/corelib/string_test.dart | 494 ++ tests/corelib/string_to_lower_case_test.dart | 19 + tests/corelib/string_trim2_test.dart | 48 + tests/corelib/string_trim_test.dart | 25 + tests/corelib/string_trimlr_test.dart | 111 + tests/corelib/strings_test.dart | 33 + tests/corelib/symbol_map_helper.dart | 15 + tests/corelib/symbol_operator_test.dart | 81 + tests/corelib/symbol_reserved_word_test.dart | 124 + tests/corelib/symbol_test.dart | 90 + .../throw_half_surrogate_pair_test.dart | 12 + tests/corelib/toInt_test.dart | 20 + tests/corelib/unicode2_test.dart | 77 + tests/corelib/unicode_test.dart | 16 + tests/corelib/uri_base_test.dart | 14 + tests/corelib/uri_example_test.dart | 96 + tests/corelib/uri_file_test.dart | 325 + tests/corelib/uri_http_test.dart | 82 + tests/corelib/uri_ipv4_test.dart | 31 + tests/corelib/uri_ipv6_test.dart | 148 + tests/corelib/uri_normalize_path_test.dart | 59 + tests/corelib/uri_normalize_test.dart | 77 + tests/corelib/uri_parameters_all_test.dart | 51 + tests/corelib/uri_parse_test.dart | 72 + tests/corelib/uri_path_test.dart | 188 + tests/corelib/uri_query_test.dart | 182 + tests/corelib/uri_scheme_test.dart | 37 + tests/corelib/uri_test.dart | 975 +++ .../test/parse_build_results_test.dart | 1 + tools/status_clean.dart | 1 + tools/testing/dart/options.dart | 1 + tools/testing/dart/test_configurations.dart | 1 + 340 files changed, 41929 insertions(+) create mode 100644 tests/corelib/apply2_test.dart create mode 100644 tests/corelib/apply3_test.dart create mode 100644 tests/corelib/apply4_test.dart create mode 100644 tests/corelib/apply5_test.dart create mode 100644 tests/corelib/apply_test.dart create mode 100644 tests/corelib/big_integer_arith_vm_test.dart create mode 100644 tests/corelib/big_integer_huge_mul_vm_test.dart create mode 100644 tests/corelib/big_integer_parsed_arith_vm_test.dart create mode 100644 tests/corelib/big_integer_parsed_div_rem_vm_test.dart create mode 100644 tests/corelib/big_integer_parsed_mul_div_vm_test.dart create mode 100644 tests/corelib/bit_twiddling_bigint_test.dart create mode 100644 tests/corelib/bit_twiddling_test.dart create mode 100644 tests/corelib/bool_from_environment2_test.dart create mode 100644 tests/corelib/bool_from_environment_test.dart create mode 100644 tests/corelib/bool_hashcode_test.dart create mode 100644 tests/corelib/collection_from_test.dart create mode 100644 tests/corelib/collection_length_test.dart create mode 100644 tests/corelib/collection_removes_test.dart create mode 100644 tests/corelib/collection_test.dart create mode 100644 tests/corelib/collection_to_string_test.dart create mode 100644 tests/corelib/compare_to2_test.dart create mode 100644 tests/corelib/compare_to_test.dart create mode 100644 tests/corelib/const_list_literal_test.dart create mode 100644 tests/corelib/const_list_remove_range_test.dart create mode 100644 tests/corelib/const_list_set_range_test.dart create mode 100644 tests/corelib/core_runtime_types_test.dart create mode 100644 tests/corelib/corelib.status create mode 100644 tests/corelib/data_uri_test.dart create mode 100644 tests/corelib/date_time10_test.dart create mode 100644 tests/corelib/date_time2_test.dart create mode 100644 tests/corelib/date_time3_test.dart create mode 100644 tests/corelib/date_time4_test.dart create mode 100644 tests/corelib/date_time5_test.dart create mode 100644 tests/corelib/date_time6_test.dart create mode 100644 tests/corelib/date_time7_test.dart create mode 100644 tests/corelib/date_time8_test.dart create mode 100644 tests/corelib/date_time9_test.dart create mode 100644 tests/corelib/date_time_parse_test.dart create mode 100644 tests/corelib/date_time_test.dart create mode 100644 tests/corelib/double_ceil2_test.dart create mode 100644 tests/corelib/double_ceil_test.dart create mode 100644 tests/corelib/double_ceil_to_double_test.dart create mode 100644 tests/corelib/double_compare_test.dart create mode 100644 tests/corelib/double_floor2_test.dart create mode 100644 tests/corelib/double_floor_test.dart create mode 100644 tests/corelib/double_floor_to_double_test.dart create mode 100644 tests/corelib/double_parse_test.dart create mode 100644 tests/corelib/double_round2_test.dart create mode 100644 tests/corelib/double_round3_test.dart create mode 100644 tests/corelib/double_round4_test.dart create mode 100644 tests/corelib/double_round_test.dart create mode 100644 tests/corelib/double_round_to_double2_test.dart create mode 100644 tests/corelib/double_round_to_double3_test.dart create mode 100644 tests/corelib/double_round_to_double_test.dart create mode 100644 tests/corelib/double_truncate2_test.dart create mode 100644 tests/corelib/double_truncate_test.dart create mode 100644 tests/corelib/double_truncate_to_double_test.dart create mode 100644 tests/corelib/duration2_test.dart create mode 100644 tests/corelib/duration_big_num_test.dart create mode 100644 tests/corelib/duration_double_multiplication_test.dart create mode 100644 tests/corelib/duration_test.dart create mode 100644 tests/corelib/error_stack_trace1_test.dart create mode 100644 tests/corelib/error_stack_trace2_test.dart create mode 100644 tests/corelib/error_stack_trace_test.dart create mode 100644 tests/corelib/errors_test.dart create mode 100644 tests/corelib/exception_implementation_test.dart create mode 100644 tests/corelib/expando_test.dart create mode 100644 tests/corelib/expression_test.dart create mode 100644 tests/corelib/for_in_test.dart create mode 100644 tests/corelib/format_exception_test.dart create mode 100644 tests/corelib/from_environment_const_type_test.dart create mode 100644 tests/corelib/from_environment_const_type_undefined_test.dart create mode 100644 tests/corelib/growable_list_test.dart create mode 100644 tests/corelib/has_next_iterator_test.dart create mode 100644 tests/corelib/hash_map2_test.dart create mode 100644 tests/corelib/hash_map_test.dart create mode 100644 tests/corelib/hash_set_test.dart create mode 100644 tests/corelib/hash_set_type_check_test.dart create mode 100644 tests/corelib/hashcode_boxed_test.dart create mode 100644 tests/corelib/hashcode_test.dart create mode 100644 tests/corelib/hidden_library2_test.dart create mode 100644 tests/corelib/indexed_list_access_test.dart create mode 100644 tests/corelib/int_ceil_test.dart create mode 100644 tests/corelib/int_ceil_to_double_test.dart create mode 100644 tests/corelib/int_floor_test.dart create mode 100644 tests/corelib/int_floor_to_double_test.dart create mode 100644 tests/corelib/int_from_environment2_test.dart create mode 100644 tests/corelib/int_from_environment3_test.dart create mode 100644 tests/corelib/int_from_environment_test.dart create mode 100644 tests/corelib/int_modulo_arith_test.dart create mode 100644 tests/corelib/int_parse_radix_bad_handler_test.dart create mode 100644 tests/corelib/int_parse_radix_test.dart create mode 100644 tests/corelib/int_round_test.dart create mode 100644 tests/corelib/int_round_to_double_test.dart create mode 100644 tests/corelib/int_to_int_test.dart create mode 100644 tests/corelib/int_truncate_test.dart create mode 100644 tests/corelib/int_truncate_to_double_test.dart create mode 100644 tests/corelib/integer_to_radix_string_test.dart create mode 100644 tests/corelib/integer_to_string_test.dart create mode 100644 tests/corelib/is_operator_basic_types_test.dart create mode 100644 tests/corelib/iterable_contains2_test.dart create mode 100644 tests/corelib/iterable_contains_test.dart create mode 100644 tests/corelib/iterable_element_at_test.dart create mode 100644 tests/corelib/iterable_empty_test.dart create mode 100644 tests/corelib/iterable_expand_test.dart create mode 100644 tests/corelib/iterable_first_test.dart create mode 100644 tests/corelib/iterable_first_where_test.dart create mode 100644 tests/corelib/iterable_fold_test.dart create mode 100644 tests/corelib/iterable_generate_test.dart create mode 100644 tests/corelib/iterable_join_test.dart create mode 100644 tests/corelib/iterable_last_test.dart create mode 100644 tests/corelib/iterable_last_where_test.dart create mode 100644 tests/corelib/iterable_length_test.dart create mode 100644 tests/corelib/iterable_mapping_test.dart create mode 100644 tests/corelib/iterable_reduce_test.dart create mode 100644 tests/corelib/iterable_return_type_test.dart create mode 100644 tests/corelib/iterable_single_test.dart create mode 100644 tests/corelib/iterable_single_where_test.dart create mode 100644 tests/corelib/iterable_skip_test.dart create mode 100644 tests/corelib/iterable_skip_while_test.dart create mode 100644 tests/corelib/iterable_take_test.dart create mode 100644 tests/corelib/iterable_take_while_test.dart create mode 100644 tests/corelib/iterable_test.dart create mode 100644 tests/corelib/iterable_to_list_test.dart create mode 100644 tests/corelib/iterable_to_set_test.dart create mode 100644 tests/corelib/iterable_tostring_test.dart create mode 100644 tests/corelib/json_map_test.dart create mode 100644 tests/corelib/linked_hash_map_from_iterable_test.dart create mode 100644 tests/corelib/linked_hash_map_from_iterables_test.dart create mode 100644 tests/corelib/linked_hash_map_test.dart create mode 100644 tests/corelib/list_as_map_test.dart create mode 100644 tests/corelib/list_contains_argument_order_test.dart create mode 100644 tests/corelib/list_fill_range_test.dart create mode 100644 tests/corelib/list_filled_type_argument_test.dart create mode 100644 tests/corelib/list_first_test.dart create mode 100644 tests/corelib/list_fixed_test.dart create mode 100644 tests/corelib/list_for_each_test.dart create mode 100644 tests/corelib/list_get_range_test.dart create mode 100644 tests/corelib/list_growable_test.dart create mode 100644 tests/corelib/list_index_of2_test.dart create mode 100644 tests/corelib/list_index_of_test.dart create mode 100644 tests/corelib/list_insert_all_test.dart create mode 100644 tests/corelib/list_insert_test.dart create mode 100644 tests/corelib/list_iterators_test.dart create mode 100644 tests/corelib/list_last_test.dart create mode 100644 tests/corelib/list_literal_is_growable_test.dart create mode 100644 tests/corelib/list_literal_test.dart create mode 100644 tests/corelib/list_map_test.dart create mode 100644 tests/corelib/list_remove_range_test.dart create mode 100644 tests/corelib/list_removeat_test.dart create mode 100644 tests/corelib/list_replace_range_test.dart create mode 100644 tests/corelib/list_reversed_test.dart create mode 100644 tests/corelib/list_set_all_test.dart create mode 100644 tests/corelib/list_set_range_test.dart create mode 100644 tests/corelib/list_sort_test.dart create mode 100644 tests/corelib/list_sublist_test.dart create mode 100644 tests/corelib/list_test.dart create mode 100644 tests/corelib/list_to_string2_test.dart create mode 100644 tests/corelib/list_to_string_test.dart create mode 100644 tests/corelib/list_unmodifiable_test.dart create mode 100644 tests/corelib/main_test.dart create mode 100644 tests/corelib/map_contains_key_test.dart create mode 100644 tests/corelib/map_contains_value_test.dart create mode 100644 tests/corelib/map_from_iterable_test.dart create mode 100644 tests/corelib/map_from_iterables_test.dart create mode 100644 tests/corelib/map_from_test.dart create mode 100644 tests/corelib/map_index_test.dart create mode 100644 tests/corelib/map_keys2_test.dart create mode 100644 tests/corelib/map_keys_test.dart create mode 100644 tests/corelib/map_remove_test.dart create mode 100644 tests/corelib/map_test.dart create mode 100644 tests/corelib/map_to_string_test.dart create mode 100644 tests/corelib/map_values2_test.dart create mode 100644 tests/corelib/map_values3_test.dart create mode 100644 tests/corelib/map_values4_test.dart create mode 100644 tests/corelib/map_values_test.dart create mode 100644 tests/corelib/maps_test.dart create mode 100644 tests/corelib/nan_infinity_test.dart create mode 100644 tests/corelib/null_nosuchmethod_test.dart create mode 100644 tests/corelib/null_test.dart create mode 100644 tests/corelib/num_clamp_test.dart create mode 100644 tests/corelib/num_parse_test.dart create mode 100644 tests/corelib/num_sign_test.dart create mode 100644 tests/corelib/print_test.dart create mode 100644 tests/corelib/queue_first_test.dart create mode 100644 tests/corelib/queue_iterator_test.dart create mode 100644 tests/corelib/queue_last_test.dart create mode 100644 tests/corelib/queue_single_test.dart create mode 100644 tests/corelib/queue_test.dart create mode 100644 tests/corelib/range_error_test.dart create mode 100644 tests/corelib/reg_exp1_test.dart create mode 100644 tests/corelib/reg_exp4_test.dart create mode 100644 tests/corelib/reg_exp5_test.dart create mode 100644 tests/corelib/reg_exp_all_matches_test.dart create mode 100644 tests/corelib/reg_exp_first_match_test.dart create mode 100644 tests/corelib/reg_exp_group_test.dart create mode 100644 tests/corelib/reg_exp_groups_test.dart create mode 100644 tests/corelib/reg_exp_has_match_test.dart create mode 100644 tests/corelib/reg_exp_pattern_test.dart create mode 100644 tests/corelib/reg_exp_start_end_test.dart create mode 100644 tests/corelib/reg_exp_string_match_test.dart create mode 100644 tests/corelib/regexp/UC16_test.dart create mode 100644 tests/corelib/regexp/alternative-length-miscalculation_test.dart create mode 100644 tests/corelib/regexp/alternatives_test.dart create mode 100644 tests/corelib/regexp/ascii-regexp-subject_test.dart create mode 100644 tests/corelib/regexp/assertion_test.dart create mode 100644 tests/corelib/regexp/backreferences_test.dart create mode 100644 tests/corelib/regexp/bol-with-multiline_test.dart create mode 100644 tests/corelib/regexp/bol_test.dart create mode 100644 tests/corelib/regexp/capture-3_test.dart create mode 100644 tests/corelib/regexp/capture_test.dart create mode 100644 tests/corelib/regexp/captures_test.dart create mode 100644 tests/corelib/regexp/char-insensitive_test.dart create mode 100644 tests/corelib/regexp/character-match-out-of-order_test.dart create mode 100644 tests/corelib/regexp/compile-crash_test.dart create mode 100644 tests/corelib/regexp/compile_test.dart create mode 100644 tests/corelib/regexp/constructor_test.dart create mode 100644 tests/corelib/regexp/default_arguments_test.dart create mode 100644 tests/corelib/regexp/dotstar_test.dart create mode 100644 tests/corelib/regexp/early-acid3-86_test.dart create mode 100644 tests/corelib/regexp/ecma-regex-examples_test.dart create mode 100644 tests/corelib/regexp/extended-characters-match_test.dart create mode 100644 tests/corelib/regexp/extended-characters-more_test.dart create mode 100644 tests/corelib/regexp/find-first-asserted_test.dart create mode 100644 tests/corelib/regexp/global_test.dart create mode 100644 tests/corelib/regexp/indexof_test.dart create mode 100644 tests/corelib/regexp/invalid-range-in-class_test.dart create mode 100644 tests/corelib/regexp/issue_19193_test.dart create mode 100644 tests/corelib/regexp/lastindex_test.dart create mode 100644 tests/corelib/regexp/look-ahead_test.dart create mode 100644 tests/corelib/regexp/lookahead_test.dart create mode 100644 tests/corelib/regexp/loop-capture_test.dart create mode 100644 tests/corelib/regexp/malformed-escapes_test.dart create mode 100644 tests/corelib/regexp/many-brackets_test.dart create mode 100644 tests/corelib/regexp/multiline_test.dart create mode 100644 tests/corelib/regexp/negative-special-characters_test.dart create mode 100644 tests/corelib/regexp/no-extensions_test.dart create mode 100644 tests/corelib/regexp/non-bmp_test.dart create mode 100644 tests/corelib/regexp/non-capturing-backtracking_test.dart create mode 100644 tests/corelib/regexp/non-capturing-groups_test.dart create mode 100644 tests/corelib/regexp/non-character_test.dart create mode 100644 tests/corelib/regexp/non-greedy-parentheses_test.dart create mode 100644 tests/corelib/regexp/norepeat_test.dart create mode 100644 tests/corelib/regexp/overflow_test.dart create mode 100644 tests/corelib/regexp/parentheses_test.dart create mode 100644 tests/corelib/regexp/pcre-test-4_test.dart create mode 100644 tests/corelib/regexp/pcre_test.dart create mode 100644 tests/corelib/regexp/quantified-assertions_test.dart create mode 100644 tests/corelib/regexp/range-bound-ffff_test.dart create mode 100644 tests/corelib/regexp/range-out-of-order_test.dart create mode 100644 tests/corelib/regexp/ranges-and-escaped-hyphens_test.dart create mode 100644 tests/corelib/regexp/regexp_kde_test.dart create mode 100644 tests/corelib/regexp/regexp_test.dart create mode 100644 tests/corelib/regexp/regress-6-9-regexp_test.dart create mode 100644 tests/corelib/regexp/regress-regexp-codeflush_test.dart create mode 100644 tests/corelib/regexp/regress-regexp-construct-result_test.dart create mode 100644 tests/corelib/regexp/repeat-match-waldemar_test.dart create mode 100644 tests/corelib/regexp/results-cache_test.dart create mode 100644 tests/corelib/regexp/stack-overflow2_test.dart create mode 100644 tests/corelib/regexp/stack-overflow_test.dart create mode 100644 tests/corelib/regexp/standalones_test.dart create mode 100644 tests/corelib/regexp/toString_test.dart create mode 100644 tests/corelib/regexp/unicode-handling_test.dart create mode 100644 tests/corelib/regexp/unicodeCaseInsensitive_test.dart create mode 100644 tests/corelib/regexp/v8_regexp_utils.dart create mode 100644 tests/corelib/regexp/zero-length-alternatives_test.dart create mode 100644 tests/corelib/regress_11099_test.dart create mode 100644 tests/corelib/regress_r21715_test.dart create mode 100644 tests/corelib/safe_to_string_test.dart create mode 100644 tests/corelib/set_containsAll_test.dart create mode 100644 tests/corelib/set_contains_test.dart create mode 100644 tests/corelib/set_intersection_test.dart create mode 100644 tests/corelib/set_iterator_test.dart create mode 100644 tests/corelib/set_removeAll_test.dart create mode 100644 tests/corelib/set_remove_test.dart create mode 100644 tests/corelib/set_retainAll_test.dart create mode 100644 tests/corelib/set_test.dart create mode 100644 tests/corelib/set_to_string_test.dart create mode 100644 tests/corelib/shuffle_test.dart create mode 100644 tests/corelib/sort_helper.dart create mode 100644 tests/corelib/sort_test.dart create mode 100644 tests/corelib/splay_tree_from_iterable_test.dart create mode 100644 tests/corelib/splay_tree_from_iterables_test.dart create mode 100644 tests/corelib/splay_tree_test.dart create mode 100644 tests/corelib/stacktrace_current_test.dart create mode 100644 tests/corelib/stacktrace_fromstring_test.dart create mode 100644 tests/corelib/stopwatch2_test.dart create mode 100644 tests/corelib/stopwatch_test.dart create mode 100644 tests/corelib/string_base_vm_test.dart create mode 100644 tests/corelib/string_buffer_test.dart create mode 100644 tests/corelib/string_case_test.dart create mode 100644 tests/corelib/string_codeunits_test.dart create mode 100644 tests/corelib/string_from_environment2_test.dart create mode 100644 tests/corelib/string_from_environment3_test.dart create mode 100644 tests/corelib/string_from_environment_test.dart create mode 100644 tests/corelib/string_from_list_test.dart create mode 100644 tests/corelib/string_fromcharcode_test.dart create mode 100644 tests/corelib/string_fromcharcodes_test.dart create mode 100644 tests/corelib/string_operations_with_null_test.dart create mode 100644 tests/corelib/string_pattern_test.dart create mode 100644 tests/corelib/string_replace_all_test.dart create mode 100644 tests/corelib/string_replace_dollar_test.dart create mode 100644 tests/corelib/string_replace_test.dart create mode 100644 tests/corelib/string_runes_test.dart create mode 100644 tests/corelib/string_source_test.dart create mode 100644 tests/corelib/string_split_test.dart create mode 100644 tests/corelib/string_substring_test.dart create mode 100644 tests/corelib/string_test.dart create mode 100644 tests/corelib/string_to_lower_case_test.dart create mode 100644 tests/corelib/string_trim2_test.dart create mode 100644 tests/corelib/string_trim_test.dart create mode 100644 tests/corelib/string_trimlr_test.dart create mode 100644 tests/corelib/strings_test.dart create mode 100644 tests/corelib/symbol_map_helper.dart create mode 100644 tests/corelib/symbol_operator_test.dart create mode 100644 tests/corelib/symbol_reserved_word_test.dart create mode 100644 tests/corelib/symbol_test.dart create mode 100644 tests/corelib/throw_half_surrogate_pair_test.dart create mode 100644 tests/corelib/toInt_test.dart create mode 100755 tests/corelib/unicode2_test.dart create mode 100644 tests/corelib/unicode_test.dart create mode 100644 tests/corelib/uri_base_test.dart create mode 100644 tests/corelib/uri_example_test.dart create mode 100644 tests/corelib/uri_file_test.dart create mode 100644 tests/corelib/uri_http_test.dart create mode 100644 tests/corelib/uri_ipv4_test.dart create mode 100644 tests/corelib/uri_ipv6_test.dart create mode 100644 tests/corelib/uri_normalize_path_test.dart create mode 100644 tests/corelib/uri_normalize_test.dart create mode 100644 tests/corelib/uri_parameters_all_test.dart create mode 100644 tests/corelib/uri_parse_test.dart create mode 100644 tests/corelib/uri_path_test.dart create mode 100644 tests/corelib/uri_query_test.dart create mode 100644 tests/corelib/uri_scheme_test.dart create mode 100644 tests/corelib/uri_test.dart diff --git a/PRESUBMIT.py b/PRESUBMIT.py index 744f0b2a61a..804774eb82d 100644 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -102,6 +102,7 @@ def _CheckNewTests(input_api, output_api): # Dart 1 tests DDC tests # ================= ========================== ("tests/language/", "tests/language_2/"), + ("tests/corelib/", "tests/corelib_2/"), ("tests/lib/", "tests/lib_2/"), ("tests/html/", "tests/lib_2/html/"), ] diff --git a/tests/corelib/apply2_test.dart b/tests/corelib/apply2_test.dart new file mode 100644 index 00000000000..25fed9be9a6 --- /dev/null +++ b/tests/corelib/apply2_test.dart @@ -0,0 +1,96 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +apply(Function function, List positional, Map named) { + return Function.apply(function, positional, named); +} + +void throwsNSME(function, positional, named) { + Expect.throws( + () => apply(function, positional, named), (e) => e is NoSuchMethodError); +} + +main() { + var c1 = () => 'c1'; + var c2 = (a) => 'c2 $a'; + var c3 = ([a = 1]) => 'c3 $a'; + var c4 = ({a: 1}) => 'c4 $a'; + var c5 = ({a: 1, b: 2}) => 'c5 $a $b'; + var c6 = ({b: 1, a: 2}) => 'c6 $a $b'; + var c7 = (x, {b: 1, a: 2}) => 'c7 $x $a $b'; + var c8 = (x, y, [a = 2, b = 3]) => 'c8 $x $y $a $b'; + + Expect.equals('c1', apply(c1, null, null)); + Expect.equals('c1', apply(c1, [], null)); + Expect.equals('c1', apply(c1, [], {})); + Expect.equals('c1', apply(c1, null, {})); + throwsNSME(c1, [1], null); + throwsNSME(c1, [1], {#a: 2}); + throwsNSME(c1, null, {#a: 2}); + + Expect.equals('c2 1', apply(c2, [1], null)); + Expect.equals('c2 1', apply(c2, [1], {})); + throwsNSME(c2, null, null); + throwsNSME(c2, [], null); + throwsNSME(c2, null, {}); + throwsNSME(c2, null, {#a: 1}); + throwsNSME(c2, [2], {#a: 1}); + + Expect.equals('c3 1', apply(c3, null, null)); + Expect.equals('c3 1', apply(c3, [], null)); + Expect.equals('c3 2', apply(c3, [2], {})); + throwsNSME(c3, [1, 2], null); + throwsNSME(c3, null, {#a: 1}); + + Expect.equals('c4 1', apply(c4, [], null)); + Expect.equals('c4 2', apply(c4, [], {#a: 2})); + Expect.equals('c4 1', apply(c4, null, null)); + Expect.equals('c4 1', apply(c4, [], {})); + throwsNSME(c4, [1], {#a: 1}); + throwsNSME(c4, [1], {}); + throwsNSME(c4, [], {#a: 1, #b: 2}); + + Expect.equals('c5 1 2', apply(c5, [], null)); + Expect.equals('c5 3 2', apply(c5, [], {#a: 3})); + Expect.equals('c5 1 2', apply(c5, null, null)); + Expect.equals('c5 1 2', apply(c5, [], {})); + Expect.equals('c5 3 4', apply(c5, [], {#a: 3, #b: 4})); + Expect.equals('c5 4 3', apply(c5, [], {#b: 3, #a: 4})); + Expect.equals('c5 1 3', apply(c5, [], {#b: 3})); + throwsNSME(c5, [1], {#a: 1}); + throwsNSME(c5, [1], {}); + throwsNSME(c5, [], {#a: 1, #b: 2, #c: 3}); + + Expect.equals('c6 2 1', apply(c6, [], null)); + Expect.equals('c6 3 1', apply(c6, [], {#a: 3})); + Expect.equals('c6 2 1', apply(c6, null, null)); + Expect.equals('c6 2 1', apply(c6, [], {})); + Expect.equals('c6 3 4', apply(c6, [], {#a: 3, #b: 4})); + Expect.equals('c6 4 3', apply(c6, [], {#b: 3, #a: 4})); + Expect.equals('c6 2 3', apply(c6, [], {#b: 3})); + throwsNSME(c6, [1], {#a: 1}); + throwsNSME(c6, [1], {}); + throwsNSME(c6, [], {#a: 1, #b: 2, #c: 3}); + + Expect.equals('c7 7 2 1', apply(c7, [7], null)); + Expect.equals('c7 7 3 1', apply(c7, [7], {#a: 3})); + Expect.equals('c7 7 2 1', apply(c7, [7], {})); + Expect.equals('c7 7 3 4', apply(c7, [7], {#a: 3, #b: 4})); + Expect.equals('c7 7 4 3', apply(c7, [7], {#b: 3, #a: 4})); + Expect.equals('c7 7 2 3', apply(c7, [7], {#b: 3})); + throwsNSME(c7, [], {#a: 1}); + throwsNSME(c7, [], {}); + throwsNSME(c7, [7], {#a: 1, #b: 2, #c: 3}); + + Expect.equals('c8 7 8 2 3', apply(c8, [7, 8], null)); + Expect.equals('c8 7 8 2 3', apply(c8, [7, 8], {})); + Expect.equals('c8 7 8 3 3', apply(c8, [7, 8, 3], null)); + Expect.equals('c8 7 8 3 4', apply(c8, [7, 8, 3, 4], null)); + throwsNSME(c8, [], null); + throwsNSME(c8, [], {}); + throwsNSME(c8, [1], null); + throwsNSME(c8, [7, 8, 9, 10, 11], null); +} diff --git a/tests/corelib/apply3_test.dart b/tests/corelib/apply3_test.dart new file mode 100644 index 00000000000..12a98c41e11 --- /dev/null +++ b/tests/corelib/apply3_test.dart @@ -0,0 +1,69 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// Test [Function.apply] on user-defined classes that implement [noSuchMethod]. + +import "package:expect/expect.dart"; +import 'dart:mirrors'; + +class F { + call([p1]) => "call"; + noSuchMethod(Invocation invocation) => "NSM"; +} + +class G { + call() => '42'; + noSuchMethod(Invocation invocation) => invocation; +} + +class H { + call(required, {a}) => required + a; +} + +main() { + Expect.equals('call', Function.apply(new F(), [])); + Expect.equals('call', Function.apply(new F(), [1])); + Expect.equals('NSM', Function.apply(new F(), [1, 2])); + Expect.equals('NSM', Function.apply(new F(), [1, 2, 3])); + + var symbol = const Symbol('a'); + var requiredParameters = [1]; + var optionalParameters = new Map()..[symbol] = 42; + Invocation i = + Function.apply(new G(), requiredParameters, optionalParameters); + + Expect.equals(const Symbol('call'), i.memberName); + Expect.listEquals(requiredParameters, i.positionalArguments); + Expect.mapEquals(optionalParameters, i.namedArguments); + Expect.isTrue(i.isMethod); + Expect.isFalse(i.isGetter); + Expect.isFalse(i.isSetter); + Expect.isFalse(i.isAccessor); + + // Check that changing the passed list and map for parameters does + // not affect [i]. + requiredParameters[0] = 42; + optionalParameters[symbol] = 12; + Expect.listEquals([1], i.positionalArguments); + Expect.mapEquals(new Map()..[symbol] = 42, i.namedArguments); + + // Check that using [i] for invocation yields the same [Invocation] + // object. + var mirror = reflect(new G()); + Invocation other = mirror.delegate(i); + Expect.equals(i.memberName, other.memberName); + Expect.listEquals(i.positionalArguments, other.positionalArguments); + Expect.mapEquals(i.namedArguments, other.namedArguments); + Expect.equals(i.isMethod, other.isMethod); + Expect.equals(i.isGetter, other.isGetter); + Expect.equals(i.isSetter, other.isSetter); + Expect.equals(i.isAccessor, other.isAccessor); + + // Test that [i] can be used to hit an existing method. + Expect.equals(43, new H().call(1, a: 42)); + Expect.equals(43, Function.apply(new H(), [1], new Map()..[symbol] = 42)); + mirror = reflect(new H()); + Expect.equals(43, mirror.delegate(i)); + Expect.equals(43, mirror.delegate(other)); +} diff --git a/tests/corelib/apply4_test.dart b/tests/corelib/apply4_test.dart new file mode 100644 index 00000000000..fba4b9d48b8 --- /dev/null +++ b/tests/corelib/apply4_test.dart @@ -0,0 +1,20 @@ +// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +// Testing Function.apply calls work correctly for arities that are not +// otherwise present in the program (and thus might not have stubs +// generated). + +class A { + foo(x, [y, z, a, b, c, d = 99, e, f, g, h, i, j]) => "$x $d"; +} + +main() { + var a = new A(); + var clos = a.foo; + Expect.equals(Function.apply(clos, ["well"]), "well 99"); + Expect.equals(Function.apply(clos, ["well", 0, 2, 4, 3, 6, 9, 10]), "well 9"); +} diff --git a/tests/corelib/apply5_test.dart b/tests/corelib/apply5_test.dart new file mode 100644 index 00000000000..5435f107189 --- /dev/null +++ b/tests/corelib/apply5_test.dart @@ -0,0 +1,23 @@ +// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +// Testing that, when compiled to JS, Function.apply works correctly for +// functions with that will be invoked directly vs using .apply(). + +class A { + foo([a = 10, b = 20, c = 30, d = 40, e = 50]) => "$a $b $c $d $e"; +} + +main() { + var a = new A(); + var clos = a.foo; + Expect.equals(Function.apply(clos, []), "10 20 30 40 50"); + Expect.equals(Function.apply(clos, [11]), "11 20 30 40 50"); + Expect.equals(Function.apply(clos, [11, 21]), "11 21 30 40 50"); + Expect.equals(Function.apply(clos, [11, 21, 31]), "11 21 31 40 50"); + Expect.equals(Function.apply(clos, [11, 21, 31, 41]), "11 21 31 41 50"); + Expect.equals(Function.apply(clos, [11, 21, 31, 41, 51]), "11 21 31 41 51"); +} diff --git a/tests/corelib/apply_test.dart b/tests/corelib/apply_test.dart new file mode 100644 index 00000000000..2540d9a129d --- /dev/null +++ b/tests/corelib/apply_test.dart @@ -0,0 +1,76 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; +import "symbol_map_helper.dart"; + +// Testing Function.apply calls correctly. +// This test is not testing error handling, only that correct parameters +// cause a correct call. + +int test0() => 42; +int test0a({int a}) => 37 + a; +int test1(int i) => i + 1; +int test1a(int i, {int a}) => i + a; +int test2(int i, int j) => i + j; +int test2a(int i, int j, {int a}) => i + j + a; + +class C { + int x = 10; + int foo(y) => this.x + y; +} + +class Callable { + int call(int x, int y) => x + y; +} + +@NoInline() +@AssumeDynamic() +confuse(x) => x; + +main() { + testMap(res, func, map) { + map = symbolMapToStringMap(map); + Expect.equals(res, Function.apply(func, null, map)); + Expect.equals(res, Function.apply(func, [], map)); + } + + testList(res, func, list) { + Expect.equals(res, Function.apply(func, list)); + Expect.equals(res, Function.apply(func, list, null)); + Expect.equals(res, Function.apply(func, list, new Map())); + } + + test(res, func, list, map) { + map = symbolMapToStringMap(map); + Expect.equals(res, Function.apply(func, list, map)); + } + + testList(42, test0, null); + testList(42, test0, []); + testMap(42, test0a, {"a": 5}); + testList(42, test1, [41]); + test(42, test1a, [20], {"a": 22}); + testList(42, test2, [20, 22]); + test(42, test2a, [10, 15], {"a": 17}); + + // Test that "this" is correct when calling closurized functions. + var cfoo = new C().foo; + testList(42, cfoo, [32]); + + // Test that apply works even with a different name. + var app = confuse(Function.apply); + Expect.equals(42, app(test2, [22, 20])); + + // Test that apply can itself be applied. + Expect.equals( + 42, + Function.apply(Function.apply, [ + test2, + [17, 25] + ])); + + // Test that apply works on callable objects. + testList(42, new Callable(), [13, 29]); +} diff --git a/tests/corelib/big_integer_arith_vm_test.dart b/tests/corelib/big_integer_arith_vm_test.dart new file mode 100644 index 00000000000..c22c7af3623 --- /dev/null +++ b/tests/corelib/big_integer_arith_vm_test.dart @@ -0,0 +1,447 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// Testing Bigints with and without intrinsics. +// VMOptions= +// VMOptions=--no_intrinsify +// VMOptions=--no-background-compilation +// VMOptions=--optimization_counter_threshold=10 --no-background_compilation + +library big_integer_test; + +import "package:expect/expect.dart"; + +foo() => 1234567890123456789; +bar() => 12345678901234567890; + +testSmiOverflow() { + var a = 1073741823; + var b = 1073741822; + Expect.equals(2147483645, a + b); + a = -1000000000; + b = 1000000001; + Expect.equals(-2000000001, a - b); + Expect.equals(-1000000001000000000, a * b); +} + +testBigintAdd() { + // Bigint and Smi. + var a = 12345678901234567890; + var b = 2; + Expect.equals(12345678901234567892, a + b); + Expect.equals(12345678901234567892, b + a); + // Bigint and Bigint. + a = 10000000000000000001; + Expect.equals(20000000000000000002, a + a); + // Bigint and double. + a = 100000000000000000000.0; + b = 200000000000000000000; + Expect.isTrue((a + b) is double); + Expect.equals(300000000000000000000.0, a + b); + Expect.isTrue((b + a) is double); + Expect.equals(300000000000000000000.0, b + a); +} + +testBigintSub() { + // Bigint and Smi. + var a = 12345678901234567890; + var b = 2; + Expect.equals(12345678901234567888, a - b); + Expect.equals(-12345678901234567888, b - a); + // Bigint and Bigint. + a = 10000000000000000001; + Expect.equals(20000000000000000002, a + a); + // Bigint and double. + a = 100000000000000000000.0; + b = 200000000000000000000; + Expect.isTrue((a + b) is double); + Expect.equals(-100000000000000000000.0, a - b); + Expect.isTrue((b + a) is double); + Expect.equals(100000000000000000000.0, b - a); + Expect.equals(-1, 0xF00000000 - 0xF00000001); +} + +testBigintMul() { + // Bigint and Smi. + var a = 12345678901234567890; + var b = 10; + Expect.equals(123456789012345678900, a * b); + Expect.equals(123456789012345678900, b * a); + // Bigint and Bigint. + a = 12345678901234567890; + b = 10000000000000000; + Expect.equals(123456789012345678900000000000000000, a * b); + // Bigint and double. + a = 2.0; + b = 200000000000000000000; + Expect.isTrue((a * b) is double); + Expect.equals(400000000000000000000.0, a * b); + Expect.isTrue((b * a) is double); + Expect.equals(400000000000000000000.0, b * a); +} + +testBigintTruncDiv() { + var a = 12345678901234567890; + var b = 10; + // Bigint and Smi. + Expect.equals(1234567890123456789, a ~/ b); + Expect.equals(0, b ~/ a); + Expect.equals(123456789, 123456789012345678 ~/ 1000000000); + // Bigint and Bigint. + a = 12345678901234567890; + b = 10000000000000000; + Expect.equals(1234, a ~/ b); + // Bigint and double. + a = 100000000000000000000.0; + b = 200000000000000000000; + Expect.equals(0, a ~/ b); + Expect.equals(2, b ~/ a); +} + +testBigintDiv() { + // Bigint and Smi. + Expect.equals(1234567890123456789.1, 12345678901234567891 / 10); + Expect.equals(0.000000001234, 1234 / 1000000000000); + Expect.equals(12345678901234000000.0, 123456789012340000000 / 10); + // Bigint and Bigint. + var a = 12345670000000000000; + var b = 10000000000000000; + Expect.equals(1234.567, a / b); + // Bigint and double. + a = 400000000000000000000.0; + b = 200000000000000000000; + Expect.equals(2.0, a / b); + Expect.equals(0.5, b / a); +} + +testBigintModulo() { + // Bigint and Smi. + var a = 1000000000005; + var b = 10; + Expect.equals(5, a % b); + Expect.equals(10, b % a); + // Bigint & Bigint + a = 10000000000000000001; + b = 10000000000000000000; + Expect.equals(1, a % b); + Expect.equals(10000000000000000000, b % a); + // Bigint & double. + a = 10000000100000000.0; + b = 10000000000000000; + Expect.equals(100000000.0, a % b); + Expect.equals(10000000000000000.0, b % a); + // Transitioning from Mint to Bigint. + var iStart = 4611686018427387900; + var prevX = -23 % iStart; + for (int i = iStart + 1; i < iStart + 10; i++) { + var x = -23 % i; + Expect.equals(1, x - prevX); + Expect.isTrue(x > 0); + prevX = x; + } +} + +testBigintModPow() { + var x, e, m; + x = 1234567890; + e = 1000000001; + m = 19; + Expect.equals(11, x.modPow(e, m)); + x = 1234567890; + e = 19; + m = 1000000001; + Expect.equals(122998977, x.modPow(e, m)); + x = 19; + e = 1234567890; + m = 1000000001; + Expect.equals(619059596, x.modPow(e, m)); + x = 19; + e = 1000000001; + m = 1234567890; + Expect.equals(84910879, x.modPow(e, m)); + x = 1000000001; + e = 19; + m = 1234567890; + Expect.equals(872984351, x.modPow(e, m)); + x = 1000000001; + e = 1234567890; + m = 19; + Expect.equals(0, x.modPow(e, m)); + x = 12345678901234567890; + e = 10000000000000000001; + m = 19; + Expect.equals(2, x.modPow(e, m)); + x = 12345678901234567890; + e = 19; + m = 10000000000000000001; + Expect.equals(3239137215315834625, x.modPow(e, m)); + x = 19; + e = 12345678901234567890; + m = 10000000000000000001; + Expect.equals(4544207837373941034, x.modPow(e, m)); + x = 19; + e = 10000000000000000001; + m = 12345678901234567890; + Expect.equals(11135411705397624859, x.modPow(e, m)); + x = 10000000000000000001; + e = 19; + m = 12345678901234567890; + Expect.equals(2034013733189773841, x.modPow(e, m)); + x = 10000000000000000001; + e = 12345678901234567890; + m = 19; + Expect.equals(1, x.modPow(e, m)); + x = 12345678901234567890; + e = 19; + m = 10000000000000000001; + Expect.equals(3239137215315834625, x.modPow(e, m)); + x = 12345678901234567890; + e = 10000000000000000001; + m = 19; + Expect.equals(2, x.modPow(e, m)); + x = 123456789012345678901234567890; + e = 123456789012345678901234567891; + m = 123456789012345678901234567899; + Expect.equals(116401406051033429924651549616, x.modPow(e, m)); + x = 123456789012345678901234567890; + e = 123456789012345678901234567899; + m = 123456789012345678901234567891; + Expect.equals(123456789012345678901234567890, x.modPow(e, m)); + x = 123456789012345678901234567899; + e = 123456789012345678901234567890; + m = 123456789012345678901234567891; + Expect.equals(35088523091000351053091545070, x.modPow(e, m)); + x = 123456789012345678901234567899; + e = 123456789012345678901234567891; + m = 123456789012345678901234567890; + Expect.equals(18310047270234132455316941949, x.modPow(e, m)); + x = 123456789012345678901234567891; + e = 123456789012345678901234567899; + m = 123456789012345678901234567890; + Expect.equals(1, x.modPow(e, m)); + x = 123456789012345678901234567891; + e = 123456789012345678901234567890; + m = 123456789012345678901234567899; + Expect.equals(40128068573873018143207285483, x.modPow(e, m)); +} + +testBigintModInverse() { + var x, m; + x = 1; + m = 1; + Expect.equals(0, x.modInverse(m)); + x = 0; + m = 1000000001; + Expect.throws(() => x.modInverse(m), (e) => e is Exception); // Not coprime. + x = 1234567890; + m = 19; + Expect.equals(11, x.modInverse(m)); + x = 1234567890; + m = 1000000001; + Expect.equals(189108911, x.modInverse(m)); + x = 19; + m = 1000000001; + Expect.throws(() => x.modInverse(m), (e) => e is Exception); // Not coprime. + x = 19; + m = 1234567890; + Expect.equals(519818059, x.modInverse(m)); + x = 1000000001; + m = 1234567890; + Expect.equals(1001100101, x.modInverse(m)); + x = 1000000001; + m = 19; + Expect.throws(() => x.modInverse(m), (e) => e is Exception); // Not coprime. + x = 12345678901234567890; + m = 19; + Expect.equals(3, x.modInverse(m)); + x = 12345678901234567890; + m = 10000000000000000001; + Expect.equals(9736746307686209582, x.modInverse(m)); + x = 19; + m = 10000000000000000001; + Expect.equals(6315789473684210527, x.modInverse(m)); + x = 19; + m = 12345678901234567890; + Expect.equals(10396361179987004539, x.modInverse(m)); + x = 10000000000000000001; + m = 12345678901234567890; + Expect.equals(325004555487045911, x.modInverse(m)); + x = 10000000000000000001; + m = 19; + Expect.equals(7, x.modInverse(m)); + x = 12345678901234567890; + m = 10000000000000000001; + Expect.equals(9736746307686209582, x.modInverse(m)); + x = 12345678901234567890; + m = 19; + Expect.equals(3, x.modInverse(m)); + x = 123456789012345678901234567890; + m = 123456789012345678901234567899; + Expect.throws(() => x.modInverse(m), (e) => e is Exception); // Not coprime. + x = 123456789012345678901234567890; + m = 123456789012345678901234567891; + Expect.equals(123456789012345678901234567890, x.modInverse(m)); + x = 123456789012345678901234567899; + m = 123456789012345678901234567891; + Expect.equals(77160493132716049313271604932, x.modInverse(m)); + x = 123456789012345678901234567899; + m = 123456789012345678901234567890; + Expect.throws(() => x.modInverse(m), (e) => e is Exception); // Not coprime. + x = 123456789012345678901234567891; + m = 123456789012345678901234567890; + Expect.equals(1, x.modInverse(m)); + x = 123456789012345678901234567891; + m = 123456789012345678901234567899; + Expect.equals(46296295879629629587962962962, x.modInverse(m)); +} + +testBigintGcd() { + var x, m; + x = 1; + m = 1; + Expect.equals(1, x.gcd(m)); + x = 693; + m = 609; + Expect.equals(21, x.gcd(m)); + x = 693 << 40; + m = 609 << 40; + Expect.equals(21 << 40, x.gcd(m)); + x = 609 << 40; + ; + m = 693 << 40; + ; + Expect.equals(21 << 40, x.gcd(m)); + x = 0; + m = 1000000001; + Expect.equals(m, x.gcd(m)); + x = 1000000001; + m = 0; + Expect.equals(x, x.gcd(m)); + x = 0; + m = -1000000001; + Expect.equals(-m, x.gcd(m)); + x = -1000000001; + m = 0; + Expect.equals(-x, x.gcd(m)); + x = 0; + m = 0; + Expect.equals(0, x.gcd(m)); + x = 0; + m = 123456789012345678901234567890; + Expect.equals(m, x.gcd(m)); + x = 123456789012345678901234567890; + m = 0; + Expect.equals(x, x.gcd(m)); + x = 0; + m = -123456789012345678901234567890; + Expect.equals(-m, x.gcd(m)); + x = -123456789012345678901234567890; + m = 0; + Expect.equals(-x, x.gcd(m)); + x = 1234567890; + m = 19; + Expect.equals(1, x.gcd(m)); + x = 1234567890; + m = 1000000001; + Expect.equals(1, x.gcd(m)); + x = 19; + m = 1000000001; + Expect.equals(19, x.gcd(m)); + x = 19; + m = 1234567890; + Expect.equals(1, x.gcd(m)); + x = 1000000001; + m = 1234567890; + Expect.equals(1, x.gcd(m)); + x = 1000000001; + m = 19; + Expect.equals(19, x.gcd(m)); + x = 12345678901234567890; + m = 19; + Expect.equals(1, x.gcd(m)); + x = 12345678901234567890; + m = 10000000000000000001; + Expect.equals(1, x.gcd(m)); + x = 19; + m = 10000000000000000001; + Expect.equals(1, x.gcd(m)); + x = 19; + m = 12345678901234567890; + Expect.equals(1, x.gcd(m)); + x = 10000000000000000001; + m = 12345678901234567890; + Expect.equals(1, x.gcd(m)); + x = 10000000000000000001; + m = 19; + Expect.equals(1, x.gcd(m)); + x = 12345678901234567890; + m = 10000000000000000001; + Expect.equals(1, x.gcd(m)); + x = 12345678901234567890; + m = 19; + Expect.equals(1, x.gcd(m)); + x = 123456789012345678901234567890; + m = 123456789012345678901234567899; + Expect.equals(9, x.gcd(m)); + x = 123456789012345678901234567890; + m = 123456789012345678901234567891; + Expect.equals(1, x.gcd(m)); + x = 123456789012345678901234567899; + m = 123456789012345678901234567891; + Expect.equals(1, x.gcd(m)); + x = 123456789012345678901234567899; + m = 123456789012345678901234567890; + Expect.equals(9, x.gcd(m)); + x = 123456789012345678901234567891; + m = 123456789012345678901234567890; + Expect.equals(1, x.gcd(m)); + x = 123456789012345678901234567891; + m = 123456789012345678901234567899; + Expect.equals(1, x.gcd(m)); +} + +testBigintNegate() { + var a = 0xF000000000000000F; + var b = ~a; // negate. + Expect.equals(-0xF0000000000000010, b); + Expect.equals(0, a & b); + Expect.equals(-1, a | b); +} + +testShiftAmount() { + Expect.equals(0, 12 >> 111111111111111111111111111111); + Expect.equals(-1, -12 >> 111111111111111111111111111111); + bool exceptionCaught = false; + try { + var a = 1 << 1111111111111111111111111111; + } on OutOfMemoryError catch (e) { + exceptionCaught = true; + } + Expect.equals(true, exceptionCaught); +} + +main() { + for (int i = 0; i < 10; i++) { + Expect.equals(1234567890123456789, foo()); + Expect.equals(12345678901234567890, bar()); + testSmiOverflow(); // //# overflow: ok + testBigintAdd(); // //# add: ok + testBigintSub(); // //# sub: ok + testBigintMul(); // //# mul: ok + testBigintTruncDiv(); // //# trunDiv: ok + testBigintDiv(); // //# div: ok + testBigintModulo(); // //# mod: ok + testBigintModPow(); // //# modPow: ok + testBigintModInverse(); // //# modInv: ok + testBigintGcd(); // //# gcd: ok + testBigintNegate(); // //# negate: ok + testShiftAmount(); // //# shift: ok + Expect.equals(12345678901234567890, (12345678901234567890).abs()); + Expect.equals(12345678901234567890, (-12345678901234567890).abs()); + var a = 10000000000000000000; + var b = 10000000000000000001; + Expect.equals(false, a.hashCode == b.hashCode); + Expect.equals(true, a.hashCode == (b - 1).hashCode); + } +} diff --git a/tests/corelib/big_integer_huge_mul_vm_test.dart b/tests/corelib/big_integer_huge_mul_vm_test.dart new file mode 100644 index 00000000000..b5bbeaa986e --- /dev/null +++ b/tests/corelib/big_integer_huge_mul_vm_test.dart @@ -0,0 +1,25 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// Testing Bigints with and without intrinsics. +// VMOptions= +// VMOptions=--no_intrinsify + +library big_integer_test; + +import "package:expect/expect.dart"; + +testBigintHugeMul() { + var bits = 65536; + var a = 1 << bits; + var a1 = a - 1; // all 1's + var p1 = a1 * a1; + var p2 = a * a - a - a + 1; + // Use isTrue instead of equals to avoid trying to print such big numbers. + Expect.isTrue(p1 == p2, 'products do not match'); +} + +main() { + testBigintHugeMul(); +} diff --git a/tests/corelib/big_integer_parsed_arith_vm_test.dart b/tests/corelib/big_integer_parsed_arith_vm_test.dart new file mode 100644 index 00000000000..88b4fd030e2 --- /dev/null +++ b/tests/corelib/big_integer_parsed_arith_vm_test.dart @@ -0,0 +1,601 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// Testing Bigints with and without intrinsics. +// VMOptions= +// VMOptions=--no_intrinsify + +library big_integer_test; + +import "package:expect/expect.dart"; + +addSubParsed(String a, String b, String sum) { + int int_a = int.parse(a); + int int_b = int.parse(b); + int int_sum = int.parse(sum); + int computed_sum = int_a + int_b; + Expect.equals(int_sum, computed_sum); + String str_sum = computed_sum >= 0 + ? "0x${computed_sum.toRadixString(16)}" + : "-0x${(-computed_sum).toRadixString(16)}"; + Expect.equals(sum.toLowerCase(), str_sum); + int computed_difference1 = int_sum - int_a; + Expect.equals(int_b, computed_difference1); + String str_difference1 = computed_difference1 >= 0 + ? "0x${computed_difference1.toRadixString(16)}" + : "-0x${(-computed_difference1).toRadixString(16)}"; + Expect.equals(b.toLowerCase(), str_difference1); + int computed_difference2 = int_sum - int_b; + Expect.equals(int_a, computed_difference2); + String str_difference2 = computed_difference2 >= 0 + ? "0x${computed_difference2.toRadixString(16)}" + : "-0x${(-computed_difference2).toRadixString(16)}"; + Expect.equals(a.toLowerCase(), str_difference2); +} + +testBigintAddSub() { + String zero = "0x0"; + String one = "0x1"; + String minus_one = "-0x1"; + + addSubParsed(zero, zero, zero); + addSubParsed(zero, one, one); + addSubParsed(one, zero, one); + addSubParsed(one, one, "0x2"); + addSubParsed(minus_one, minus_one, "-0x2"); + addSubParsed("0x123", zero, "0x123"); + addSubParsed(zero, "0x123", "0x123"); + addSubParsed("0x123", one, "0x124"); + addSubParsed(one, "0x123", "0x124"); + addSubParsed( + "0xFFFFFFF", + one, // 28 bit overflow. + "0x10000000"); + addSubParsed( + "0xFFFFFFFF", + one, // 32 bit overflow. + "0x100000000"); + addSubParsed( + "0xFFFFFFFFFFFFFF", + one, // 56 bit overflow. + "0x100000000000000"); + addSubParsed( + "0xFFFFFFFFFFFFFFFF", + one, // 64 bit overflow. + "0x10000000000000000"); + addSubParsed( + "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", // 128 bit. + one, + "0x100000000000000000000000000000000"); + addSubParsed("0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", one, + "0x10000000000000000000000000000000000000000000"); + addSubParsed( + "0x8000000", // 28 bit overflow. + "0x8000000", + "0x10000000"); + addSubParsed( + "0x80000000", // 32 bit overflow. + "0x80000000", + "0x100000000"); + addSubParsed( + "0x80000000000000", // 56 bit overflow. + "0x80000000000000", + "0x100000000000000"); + addSubParsed( + "0x8000000000000000", // 64 bit overflow. + "0x8000000000000000", + "0x10000000000000000"); + addSubParsed( + "0x80000000000000000000000000000000", // 128 bit. + "0x80000000000000000000000000000000", + "0x100000000000000000000000000000000"); + addSubParsed( + "0x8000000000000000000000000000000000000000000", + "0x8000000000000000000000000000000000000000000", + "0x10000000000000000000000000000000000000000000"); + + { + String a = "0x123456789ABCDEF01234567890ABCDEF0123456789ABCDEF0"; + String sum1 = "0x123456789ABCDEF01234567890ABCDEF0123456789ABCDEF1"; + String times2 = "0x2468ACF13579BDE02468ACF121579BDE02468ACF13579BDE0"; + addSubParsed(a, zero, a); + addSubParsed(a, one, sum1); + addSubParsed(a, a, times2); + } + + addSubParsed("-0x123", minus_one, "-0x124"); + addSubParsed(minus_one, "-0x123", "-0x124"); + addSubParsed( + "-0xFFFFFFF", + minus_one, // 28 bit overflow. + "-0x10000000"); + addSubParsed( + "-0xFFFFFFFF", + minus_one, // 32 bit overflow. + "-0x100000000"); + addSubParsed( + "-0xFFFFFFFFFFFFFF", + minus_one, // 56 bit overflow. + "-0x100000000000000"); + addSubParsed( + "-0xFFFFFFFFFFFFFFFF", + minus_one, // 64 bit overflow. + "-0x10000000000000000"); + addSubParsed( + "-0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", // 128 bit. + minus_one, + "-0x100000000000000000000000000000000"); + addSubParsed("-0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", minus_one, + "-0x10000000000000000000000000000000000000000000"); + addSubParsed( + "-0x8000000", // 28 bit overflow. + "-0x8000000", + "-0x10000000"); + addSubParsed( + "-0x80000000", // 32 bit overflow. + "-0x80000000", + "-0x100000000"); + addSubParsed( + "-0x80000000000000", // 56 bit overflow. + "-0x80000000000000", + "-0x100000000000000"); + addSubParsed( + "-0x8000000000000000", // 64 bit overflow. + "-0x8000000000000000", + "-0x10000000000000000"); + addSubParsed( + "-0x80000000000000000000000000000000", // 128 bit. + "-0x80000000000000000000000000000000", + "-0x100000000000000000000000000000000"); + addSubParsed( + "-0x8000000000000000000000000000000000000000000", + "-0x8000000000000000000000000000000000000000000", + "-0x10000000000000000000000000000000000000000000"); + + { + String a = "-0x123456789ABCDEF01234567890ABCDEF0123456789ABCDEF0"; + String sum1 = "-0x123456789ABCDEF01234567890ABCDEF0123456789ABCDEF1"; + String times2 = "-0x2468ACF13579BDE02468ACF121579BDE02468ACF13579BDE0"; + addSubParsed(a, zero, a); + addSubParsed(a, minus_one, sum1); + addSubParsed(a, a, times2); + } + + addSubParsed("0x10000000000000000000000000000000000000000000", "0xFFFF", + "0x1000000000000000000000000000000000000000FFFF"); + addSubParsed("0x10000000000000000000000000000000000000000000", + "0xFFFF00000000", "0x10000000000000000000000000000000FFFF00000000"); + addSubParsed("0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", "0x100000000", + "0x1000000000000000000000000000000000000FFFFFFFF"); + addSubParsed( + "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", + "0x10000000000000000000", + "0x10000000000000000000000000FFFFFFFFFFFFFFFFFFF"); + + addSubParsed("0xB", "-0x7", "0x4"); + addSubParsed("-0xB", "-0x7", "-0x12"); + addSubParsed("0xB", "0x7", "0x12"); + addSubParsed("-0xB", "0x7", "-0x4"); + addSubParsed("-0x7", "0xB", "0x4"); + addSubParsed("-0x7", "-0xB", "-0x12"); + addSubParsed("0x7", "0xB", "0x12"); + addSubParsed("0x7", "-0xB", "-0x4"); +} + +shiftLeftParsed(String a, int amount, String result) { + int int_a = int.parse(a); + int int_result = int.parse(result); + int shifted = int_a << amount; + Expect.equals(int_result, shifted); + String str_shifted = shifted >= 0 + ? "0x${shifted.toRadixString(16)}" + : "-0x${(-shifted).toRadixString(16)}"; + Expect.equals(result.toLowerCase(), str_shifted); + int back_shifted = shifted >> amount; + Expect.equals(int_a, back_shifted); + String str_back_shifted = back_shifted >= 0 + ? "0x${back_shifted.toRadixString(16)}" + : "-0x${(-back_shifted).toRadixString(16)}"; + Expect.equals(a.toLowerCase(), str_back_shifted); +} + +testBigintLeftShift() { + String zero = "0x0"; + String one = "0x1"; + String minus_one = "-0x1"; + + shiftLeftParsed(zero, 0, zero); + shiftLeftParsed(one, 0, one); + shiftLeftParsed("0x1234", 0, "0x1234"); + shiftLeftParsed(zero, 100000, zero); + shiftLeftParsed(one, 1, "0x2"); + shiftLeftParsed(one, 28, "0x10000000"); + shiftLeftParsed(one, 32, "0x100000000"); + shiftLeftParsed(one, 64, "0x10000000000000000"); + shiftLeftParsed("0x5", 28, "0x50000000"); + shiftLeftParsed("0x5", 32, "0x500000000"); + shiftLeftParsed("0x5", 56, "0x500000000000000"); + shiftLeftParsed("0x5", 64, "0x50000000000000000"); + shiftLeftParsed("0x5", 128, "0x500000000000000000000000000000000"); + shiftLeftParsed("0x5", 27, "0x28000000"); + shiftLeftParsed("0x5", 31, "0x280000000"); + shiftLeftParsed("0x5", 55, "0x280000000000000"); + shiftLeftParsed("0x5", 63, "0x28000000000000000"); + shiftLeftParsed("0x5", 127, "0x280000000000000000000000000000000"); + shiftLeftParsed("0x8000001", 1, "0x10000002"); + shiftLeftParsed("0x80000001", 1, "0x100000002"); + shiftLeftParsed("0x8000000000000001", 1, "0x10000000000000002"); + shiftLeftParsed("0x8000001", 29, "0x100000020000000"); + shiftLeftParsed("0x80000001", 33, "0x10000000200000000"); + shiftLeftParsed( + "0x8000000000000001", 65, "0x100000000000000020000000000000000"); + shiftLeftParsed(minus_one, 0, minus_one); + shiftLeftParsed("-0x1234", 0, "-0x1234"); + shiftLeftParsed(minus_one, 1, "-0x2"); + shiftLeftParsed(minus_one, 28, "-0x10000000"); + shiftLeftParsed(minus_one, 32, "-0x100000000"); + shiftLeftParsed(minus_one, 64, "-0x10000000000000000"); + shiftLeftParsed("-0x5", 28, "-0x50000000"); + shiftLeftParsed("-0x5", 32, "-0x500000000"); + shiftLeftParsed("-0x5", 64, "-0x50000000000000000"); + shiftLeftParsed("-0x5", 27, "-0x28000000"); + shiftLeftParsed("-0x5", 31, "-0x280000000"); + shiftLeftParsed("-0x5", 63, "-0x28000000000000000"); + shiftLeftParsed("-0x8000001", 1, "-0x10000002"); + shiftLeftParsed("-0x80000001", 1, "-0x100000002"); + shiftLeftParsed("-0x8000000000000001", 1, "-0x10000000000000002"); + shiftLeftParsed("-0x8000001", 29, "-0x100000020000000"); + shiftLeftParsed("-0x80000001", 33, "-0x10000000200000000"); + shiftLeftParsed( + "-0x8000000000000001", 65, "-0x100000000000000020000000000000000"); +} + +shiftRightParsed(String a, int amount, String result) { + int int_a = int.parse(a); + int int_result = int.parse(result); + int shifted = int_a >> amount; + Expect.equals(int_result, shifted); + String str_shifted = shifted >= 0 + ? "0x${shifted.toRadixString(16)}" + : "-0x${(-shifted).toRadixString(16)}"; + Expect.equals(result.toLowerCase(), str_shifted); +} + +testBigintRightShift() { + String zero = "0x0"; + String one = "0x1"; + String minus_one = "-0x1"; + + shiftRightParsed(one, 1, zero); + shiftRightParsed(minus_one, 1, minus_one); + shiftRightParsed("-0x2", 1, minus_one); + shiftRightParsed("0x12345678", 29, zero); + shiftRightParsed("-0x12345678", 29, minus_one); + shiftRightParsed("-0x12345678", 100, minus_one); + shiftRightParsed("0x5", 1, "0x2"); + shiftRightParsed("0x5", 2, "0x1"); + shiftRightParsed("-0x5", 1, "-0x3"); + shiftRightParsed("-0x5", 2, "-0x2"); + shiftRightParsed("0x10000001", 28, one); + shiftRightParsed("0x100000001", 32, one); + shiftRightParsed("0x10000000000000001", 64, one); + shiftRightParsed("-0x10000001", 28, "-0x2"); + shiftRightParsed("-0x100000001", 32, "-0x2"); + shiftRightParsed("-0x10000000000000001", 64, "-0x2"); + shiftRightParsed("0x30000000", 29, one); + shiftRightParsed("0x300000000", 33, one); + shiftRightParsed("0x30000000000000000", 65, one); + shiftRightParsed("-0x30000000", 29, "-0x2"); + shiftRightParsed("-0x300000000", 33, "-0x2"); + shiftRightParsed("-0x30000000000000000", 65, "-0x2"); +} + +bitAndParsed(String a, String b, String result) { + int int_a = int.parse(a); + int int_b = int.parse(b); + int int_result = int.parse(result); + int anded = int_a & int_b; + Expect.equals(int_result, anded); + String str_anded = anded >= 0 + ? "0x${anded.toRadixString(16)}" + : "-0x${(-anded).toRadixString(16)}"; + Expect.equals(result.toLowerCase(), str_anded); + int anded2 = int_b & int_a; + Expect.equals(int_result, anded2); + String str_anded2 = anded2 >= 0 + ? "0x${anded2.toRadixString(16)}" + : "-0x${(-anded2).toRadixString(16)}"; + Expect.equals(result.toLowerCase(), str_anded2); +} + +testBigintBitAnd() { + String zero = "0x0"; + String one = "0x1"; + String minus_one = "-0x1"; + + bitAndParsed(one, zero, zero); + bitAndParsed(one, one, one); + bitAndParsed(minus_one, zero, zero); + bitAndParsed(minus_one, one, one); + bitAndParsed(minus_one, minus_one, minus_one); + bitAndParsed("0x5", "0x3", one); + bitAndParsed("0x5", minus_one, "0x5"); + bitAndParsed("0x50000000", one, zero); + bitAndParsed("0x50000000", minus_one, "0x50000000"); + bitAndParsed("0x500000000", one, zero); + bitAndParsed("0x500000000", minus_one, "0x500000000"); + bitAndParsed("0x50000000000000000", one, zero); + bitAndParsed("0x50000000000000000", minus_one, "0x50000000000000000"); + bitAndParsed("-0x50000000", "-0x50000000", "-0x50000000"); + bitAndParsed("-0x500000000", "-0x500000000", "-0x500000000"); + bitAndParsed( + "-0x50000000000000000", "-0x50000000000000000", "-0x50000000000000000"); + bitAndParsed("0x1234567890ABCDEF012345678", "0x876543210FEDCBA0987654321", + "0x224422000A9C9A0002244220"); + bitAndParsed("-0x1234567890ABCDEF012345678", "-0x876543210FEDCBA0987654321", + "-0x977557799FEFCFEF997755778"); + bitAndParsed("0x1234567890ABCDEF012345678", "-0x876543210FEDCBA0987654321", + "0x101014589002044F010101458"); + bitAndParsed( + "0x1234567890ABCDEF012345678FFFFFFFFFFFFFFFFFFFFFFFFF", + "-0x876543210FEDCBA0987654321", + "0x1234567890ABCDEF012345678789ABCDEF012345F6789ABCDF"); + bitAndParsed("0x12345678", "0xFFFFFFF", "0x2345678"); + bitAndParsed("0x123456789", "0xFFFFFFFF", "0x23456789"); + bitAndParsed("-0x10000000", "0xFFFFFFF", "0x0"); + bitAndParsed("-0x100000000", "0xFFFFFFFF", "0x0"); + bitAndParsed("-0x10000001", "0xFFFFFFF", "0xFFFFFFF"); + bitAndParsed("-0x100000001", "0xFFFFFFFF", "0xFFFFFFFF"); + bitAndParsed("-0x10000001", "0x3FFFFFFF", "0x2FFFFFFF"); + bitAndParsed("-0x100000001", "0x3FFFFFFFF", "0x2FFFFFFFF"); + bitAndParsed( + "-0x10000000000000001", "0x3FFFFFFFFFFFFFFFF", "0x2FFFFFFFFFFFFFFFF"); + bitAndParsed("-0x100000000000000", "0xFFFFFFFFFFFFFF", "0x0"); + bitAndParsed("-0x10000000000000000", "0xFFFFFFFFFFFFFFFF", "0x0"); + bitAndParsed("-0x300000000000000", "0xFFFFFFFFFFFFFFF", "0xD00000000000000"); + bitAndParsed( + "-0x30000000000000000", "0xFFFFFFFFFFFFFFFFF", "0xD0000000000000000"); + bitAndParsed("-0x10000000", "-0x10000000", "-0x10000000"); + bitAndParsed("-0x100000000", "-0x100000000", "-0x100000000"); + bitAndParsed( + "-0x100000000000000", "-0x100000000000000", "-0x100000000000000"); + bitAndParsed( + "-0x10000000000000000", "-0x10000000000000000", "-0x10000000000000000"); + bitAndParsed("-0x3", "-0x2", "-0x4"); + bitAndParsed("-0x10000000", "-0x10000001", "-0x20000000"); + bitAndParsed("-0x100000000", "-0x100000001", "-0x200000000"); + bitAndParsed( + "-0x100000000000000", "-0x100000000000001", "-0x200000000000000"); + bitAndParsed( + "-0x10000000000000000", "-0x10000000000000001", "-0x20000000000000000"); + bitAndParsed( + "0x123456789ABCDEF01234567890", + "0x3FFFFFFF", // Max Smi for 32 bits. + "0x34567890"); + bitAndParsed( + "0x123456789ABCDEF01274567890", + "0x3FFFFFFF", // Max Smi for 32 bits. + "0x34567890"); + bitAndParsed( + "0x123456789ABCDEF01234567890", + "0x40000000", // Max Smi for 32 bits + 1. + "0x0"); + bitAndParsed( + "0x123456789ABCDEF01274567890", + "0x40000000", // Max Smi for 32 bits + 1. + "0x40000000"); + bitAndParsed( + "0x123456789ABCDEF01234567890", + "0x3FFFFFFFFFFFFFFF", // Max Smi for 64 bits. + "0x3CDEF01234567890"); + bitAndParsed( + "0x123456789ACCDEF01234567890", + "0x4000000000000000", // Max Smi for 64 bits + 1. + "0x4000000000000000"); + bitAndParsed( + "0x123456789ABCDEF01234567890", + "0x4000000000000000", // Max Smi for 64 bits + 1. + "0x0"); +} + +bitOrParsed(String a, String b, String result) { + int int_a = int.parse(a); + int int_b = int.parse(b); + int int_result = int.parse(result); + int ored = int_a | int_b; + Expect.equals(int_result, ored); + String str_ored = ored >= 0 + ? "0x${ored.toRadixString(16)}" + : "-0x${(-ored).toRadixString(16)}"; + Expect.equals(result.toLowerCase(), str_ored); + int ored2 = int_b | int_a; + Expect.equals(int_result, ored2); + String str_ored2 = ored2 >= 0 + ? "0x${ored2.toRadixString(16)}" + : "-0x${(-ored2).toRadixString(16)}"; + Expect.equals(result.toLowerCase(), str_ored2); +} + +testBigintBitOr() { + String zero = "0x0"; + String one = "0x1"; + String minus_one = "-0x1"; + + bitOrParsed(one, zero, one); + bitOrParsed(one, one, one); + bitOrParsed(minus_one, zero, minus_one); + bitOrParsed(minus_one, one, minus_one); + bitOrParsed(minus_one, minus_one, minus_one); + bitOrParsed("-0x3", one, "-0x3"); + bitOrParsed("0x5", "0x3", "0x7"); + bitOrParsed("0x5", minus_one, minus_one); + bitOrParsed("0x5", zero, "0x5"); + bitOrParsed("0x50000000", one, "0x50000001"); + bitOrParsed("0x50000000", minus_one, minus_one); + bitOrParsed("0x500000000", one, "0x500000001"); + bitOrParsed("0x500000000", minus_one, minus_one); + bitOrParsed("0x50000000000000000", one, "0x50000000000000001"); + bitOrParsed("0x50000000000000000", minus_one, minus_one); + bitOrParsed("-0x50000000", "-0x50000000", "-0x50000000"); + bitOrParsed("-0x500000000", "-0x500000000", "-0x500000000"); + bitOrParsed( + "-0x50000000000000000", "-0x50000000000000000", "-0x50000000000000000"); + bitOrParsed("0x1234567890ABCDEF012345678", "0x876543210FEDCBA0987654321", + "0x977557799FEFCFEF997755779"); + bitOrParsed("-0x1234567890ABCDEF012345678", "-0x876543210FEDCBA0987654321", + "-0x224422000A9C9A0002244221"); + bitOrParsed("0x1234567890ABCDEF012345678", "-0x876543210FEDCBA0987654321", + "-0x854101010F440200985410101"); + bitOrParsed("0x1234567890ABCDEF012345678FFFFFFFFFFFFFFFFFFFFFFFFF", + "-0x876543210FEDCBA0987654321", "-0x1"); + bitOrParsed("0x12345678", "0xFFFFFFF", "0x1FFFFFFF"); + bitOrParsed("0x123456789", "0xFFFFFFFF", "0x1FFFFFFFF"); + bitOrParsed("-0x10000000", "0xFFFFFFF", "-0x1"); + bitOrParsed("-0x100000000", "0xFFFFFFFF", "-0x1"); + bitOrParsed("-0x10000001", "0xFFFFFFF", "-0x10000001"); + bitOrParsed("-0x100000001", "0xFFFFFFFF", "-0x100000001"); + bitOrParsed("-0x10000001", "0x3FFFFFFF", "-0x1"); + bitOrParsed("-0x100000001", "0x3FFFFFFFF", "-0x1"); + bitOrParsed("-0x10000000000000001", "0x3FFFFFFFFFFFFFFFF", "-0x1"); + bitOrParsed("-0x100000000000000", "0xFFFFFFFFFFFFFF", "-0x1"); + bitOrParsed("-0x10000000000000000", "0xFFFFFFFFFFFFFFFF", "-0x1"); + bitOrParsed("-0x300000000000000", "0xFFFFFFFFFFFFFFF", "-0x1"); + bitOrParsed("-0x30000000000000000", "0xFFFFFFFFFFFFFFFFF", "-0x1"); + bitOrParsed("-0x10000000", "-0x10000000", "-0x10000000"); + bitOrParsed("-0x100000000", "-0x100000000", "-0x100000000"); + bitOrParsed("-0x100000000000000", "-0x100000000000000", "-0x100000000000000"); + bitOrParsed( + "-0x10000000000000000", "-0x10000000000000000", "-0x10000000000000000"); + bitOrParsed("-0x10000000", "-0x10000001", "-0x1"); + bitOrParsed("-0x100000000", "-0x100000001", "-0x1"); + bitOrParsed("-0x100000000000000", "-0x100000000000001", "-0x1"); + bitOrParsed("-0x10000000000000000", "-0x10000000000000001", "-0x1"); + bitOrParsed("-0x10000000000000000", "-0x1", "-0x1"); +} + +bitXorParsed(String a, String b, String result) { + int int_a = int.parse(a); + int int_b = int.parse(b); + int int_result = int.parse(result); + int xored = int_a ^ int_b; + Expect.equals(int_result, xored); + String str_xored = xored >= 0 + ? "0x${xored.toRadixString(16)}" + : "-0x${(-xored).toRadixString(16)}"; + Expect.equals(result.toLowerCase(), str_xored); + int xored2 = int_b ^ int_a; + Expect.equals(int_result, xored2); + String str_xored2 = xored2 >= 0 + ? "0x${xored2.toRadixString(16)}" + : "-0x${(-xored2).toRadixString(16)}"; + Expect.equals(result.toLowerCase(), str_xored2); + int xored3 = int_a ^ xored2; + Expect.equals(int_b, xored3); + String str_xored3 = xored3 >= 0 + ? "0x${xored3.toRadixString(16)}" + : "-0x${(-xored3).toRadixString(16)}"; + Expect.equals(b.toLowerCase(), str_xored3); +} + +testBigintBitXor() { + String zero = "0x0"; + String one = "0x1"; + String minus_one = "-0x1"; + + bitXorParsed(one, zero, one); + bitXorParsed(one, one, zero); + bitXorParsed(minus_one, zero, minus_one); + bitXorParsed(minus_one, one, "-0x2"); + bitXorParsed(minus_one, minus_one, zero); + bitXorParsed("0x5", "0x3", "0x6"); + bitXorParsed("0x5", minus_one, "-0x6"); + bitXorParsed("0x5", zero, "0x5"); + bitXorParsed(minus_one, "-0x8", "0x7"); + bitXorParsed("0x50000000", one, "0x50000001"); + bitXorParsed("0x50000000", minus_one, "-0x50000001"); + bitXorParsed("0x500000000", one, "0x500000001"); + bitXorParsed("0x500000000", minus_one, "-0x500000001"); + bitXorParsed("0x50000000000000000", one, "0x50000000000000001"); + bitXorParsed("0x50000000000000000", minus_one, "-0x50000000000000001"); + bitXorParsed("-0x50000000", "-0x50000000", zero); + bitXorParsed("-0x500000000", "-0x500000000", zero); + bitXorParsed("-0x50000000000000000", "-0x50000000000000000", zero); + bitXorParsed("0x1234567890ABCDEF012345678", "0x876543210FEDCBA0987654321", + "0x955115599F46064F995511559"); + bitXorParsed("-0x1234567890ABCDEF012345678", "-0x876543210FEDCBA0987654321", + "0x955115599F46064F995511557"); + bitXorParsed("0x1234567890ABCDEF012345678", "-0x876543210FEDCBA0987654321", + "-0x955115599F46064F995511559"); + bitXorParsed( + "0x1234567890ABCDEF012345678FFFFFFFFFFFFFFFFFFFFFFFFF", + "-0x876543210FEDCBA0987654321", + "-0x1234567890ABCDEF012345678789ABCDEF012345F6789ABCE0"); + bitXorParsed("0x12345678", "0xFFFFFFF", "0x1DCBA987"); + bitXorParsed("0x123456789", "0xFFFFFFFF", "0x1DCBA9876"); + bitXorParsed("-0x10000000", "0xFFFFFFF", "-0x1"); + bitXorParsed("-0x100000000", "0xFFFFFFFF", "-0x1"); + bitXorParsed("-0x10000001", "0xFFFFFFF", "-0x20000000"); + bitXorParsed("-0x100000001", "0xFFFFFFFF", "-0x200000000"); + bitXorParsed("-0x10000001", "0x3FFFFFFF", "-0x30000000"); + bitXorParsed("-0x100000001", "0x3FFFFFFFF", "-0x300000000"); + bitXorParsed( + "-0x10000000000000001", "0x3FFFFFFFFFFFFFFFF", "-0x30000000000000000"); + bitXorParsed("-0x100000000000000", "0xFFFFFFFFFFFFFF", "-0x1"); + bitXorParsed("-0x10000000000000000", "0xFFFFFFFFFFFFFFFF", "-0x1"); + bitXorParsed("-0x300000000000000", "0xFFFFFFFFFFFFFFF", "-0xD00000000000001"); + bitXorParsed( + "-0x30000000000000000", "0xFFFFFFFFFFFFFFFFF", "-0xD0000000000000001"); + bitXorParsed("-0x10000000", "-0x10000000", zero); + bitXorParsed("-0x100000000", "-0x100000000", zero); + bitXorParsed("-0x100000000000000", "-0x100000000000000", zero); + bitXorParsed("-0x10000000000000000", "-0x10000000000000000", zero); + bitXorParsed("-0x10000000", "-0x10000001", "0x1FFFFFFF"); + bitXorParsed("-0x100000000", "-0x100000001", "0x1FFFFFFFF"); + bitXorParsed("-0x100000000000000", "-0x100000000000001", "0x1FFFFFFFFFFFFFF"); + bitXorParsed( + "-0x10000000000000000", "-0x10000000000000001", "0x1FFFFFFFFFFFFFFFF"); +} + +bitNotParsed(String a, String result) { + int int_a = int.parse(a); + int int_result = int.parse(result); + int inverted = ~int_a; + Expect.equals(int_result, inverted); + String str_inverted = inverted >= 0 + ? "0x${inverted.toRadixString(16)}" + : "-0x${(-inverted).toRadixString(16)}"; + Expect.equals(result.toLowerCase(), str_inverted); + int back = ~inverted; + Expect.equals(int_a, back); + String str_back = back >= 0 + ? "0x${back.toRadixString(16)}" + : "-0x${(-back).toRadixString(16)}"; + Expect.equals(a.toLowerCase(), str_back); +} + +testBigintBitNot() { + String zero = "0x0"; + String one = "0x1"; + String minus_one = "-0x1"; + + bitNotParsed(zero, minus_one); + bitNotParsed(one, "-0x2"); + bitNotParsed("0x5", "-0x6"); + bitNotParsed("0x50000000", "-0x50000001"); + bitNotParsed("0xFFFFFFF", "-0x10000000"); + bitNotParsed("0xFFFFFFFF", "-0x100000000"); + bitNotParsed("0xFFFFFFFFFFFFFF", "-0x100000000000000"); + bitNotParsed("0xFFFFFFFFFFFFFFFF", "-0x10000000000000000"); + bitNotParsed("0x1234567890ABCDEF012345678", "-0x1234567890ABCDEF012345679"); +} + +main() { + testBigintAddSub(); + testBigintLeftShift(); + testBigintRightShift(); + testBigintBitAnd(); + testBigintBitOr(); + testBigintBitXor(); + testBigintBitNot(); +} diff --git a/tests/corelib/big_integer_parsed_div_rem_vm_test.dart b/tests/corelib/big_integer_parsed_div_rem_vm_test.dart new file mode 100644 index 00000000000..551b7a7e882 --- /dev/null +++ b/tests/corelib/big_integer_parsed_div_rem_vm_test.dart @@ -0,0 +1,111 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// Testing Bigints with and without intrinsics. +// VMOptions= +// VMOptions=--no_intrinsify + +library big_integer_test; + +import "package:expect/expect.dart"; + +divRemParsed(String a, String b, String quotient, String remainder) { + int int_a = int.parse(a); + int int_b = int.parse(b); + int int_quotient = int.parse(quotient); + int int_remainder = int.parse(remainder); + int computed_quotient = int_a ~/ int_b; + Expect.equals(int_quotient, computed_quotient); + String str_quotient = computed_quotient >= 0 + ? "0x${computed_quotient.toRadixString(16)}" + : "-0x${(-computed_quotient).toRadixString(16)}"; + Expect.equals(quotient.toLowerCase(), str_quotient); + int computed_remainder = int_a.remainder(int_b); + Expect.equals(int_remainder, computed_remainder); + String str_remainder = computed_remainder >= 0 + ? "0x${computed_remainder.toRadixString(16)}" + : "-0x${(-computed_remainder).toRadixString(16)}"; + Expect.equals(remainder.toLowerCase(), str_remainder); +} + +testBigintDivideRemainder() { + String zero = "0x0"; + String one = "0x1"; + String minus_one = "-0x1"; + + divRemParsed(one, one, one, zero); + divRemParsed(zero, one, zero, zero); + divRemParsed(minus_one, one, minus_one, zero); + divRemParsed(one, "0x2", zero, one); + divRemParsed(minus_one, "0x7", zero, minus_one); + divRemParsed("0xB", "0x7", one, "0x4"); + divRemParsed("0x12345678", "0x7", "0x299C335", "0x5"); + divRemParsed("-0x12345678", "0x7", "-0x299C335", "-0x5"); + divRemParsed("0x12345678", "-0x7", "-0x299C335", "0x5"); + divRemParsed("-0x12345678", "-0x7", "0x299C335", "-0x5"); + divRemParsed("0x7", "0x12345678", zero, "0x7"); + divRemParsed("-0x7", "0x12345678", zero, "-0x7"); + divRemParsed("-0x7", "-0x12345678", zero, "-0x7"); + divRemParsed("0x7", "-0x12345678", zero, "0x7"); + divRemParsed("0x12345678", "0x7", "0x299C335", "0x5"); + divRemParsed("-0x12345678", "0x7", "-0x299C335", "-0x5"); + divRemParsed("0x12345678", "-0x7", "-0x299C335", "0x5"); + divRemParsed("-0x12345678", "-0x7", "0x299C335", "-0x5"); + divRemParsed( + "0x14B66DC327D3C88D7EAA988BBFFA9BBA877826E7EDAF373907A931FBFC3A25231DF7F2" + "516F511FB1638F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A" + "8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F" + "0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B" + "570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B57" + "0F4A8F0B570F4A8F0B570F4A8F0B570F35D89D93E776C67DD864B2034B5C739007933027" + "5CDFD41E07A15D0F5AD5256BED5F1CF91FBA375DE70", + "0x1234567890ABCDEF01234567890ABCDEF01234567890ABCDEF01234567890ABCDEF" + "01234567890ABCDEF", + "0x1234567890123456789012345678901234567890123456789012345678901234567890" + "123456789012345678901234567890123456789012345678901234567890123456789012" + "345678901234567890123456789012345678901234567890123456789012345678901234" + "567890123456789012345678901234567890123456789012345678901234567890123456" + "789012345678901234567890123456789012345678901234567890123456789012345678" + "90123456789012345678901234567890", + zero); + divRemParsed( + "0x14B66DC327D3C88D7EAA988BBFFA9BBA877826E7EDAF373907A931FBFC3A25231DF7F2" + "516F511FB1638F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A" + "8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F" + "0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B" + "570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B57" + "0F4A8F0B570F4A8F0B570F4A8F0B570F35D89D93E776C67DD864B2034B5C739007933027" + "5CDFD41E07A15D0F5AD5256BED5F1CF91FBA375DE71", + "0x1234567890ABCDEF01234567890ABCDEF01234567890ABCDEF01234567890ABCDEF" + "01234567890ABCDEF", + "0x1234567890123456789012345678901234567890123456789012345678901234567890" + "123456789012345678901234567890123456789012345678901234567890123456789012" + "345678901234567890123456789012345678901234567890123456789012345678901234" + "567890123456789012345678901234567890123456789012345678901234567890123456" + "789012345678901234567890123456789012345678901234567890123456789012345678" + "90123456789012345678901234567890", + one); + divRemParsed( + "0x14B66DC327D3C88D7EAA988BBFFA9BBA877826E7EDAF373907A931FBFC3A25231DF7F2" + "516F511FB1638F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A" + "8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F" + "0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B" + "570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B57" + "0F4A8F0B570F4A8F0B570F4A8F0B5710591E051CF233A56DEA99087BDC08417F08B6758E" + "E5EA90FCF7B39165D365D139DC60403E8743421AC5E", + "0x1234567890ABCDEF01234567890ABCDEF01234567890ABCDEF01234567890ABCDEF" + "01234567890ABCDEF", + "0x1234567890123456789012345678901234567890123456789012345678901234567890" + "123456789012345678901234567890123456789012345678901234567890123456789012" + "345678901234567890123456789012345678901234567890123456789012345678901234" + "567890123456789012345678901234567890123456789012345678901234567890123456" + "789012345678901234567890123456789012345678901234567890123456789012345678" + "90123456789012345678901234567890", + "0x1234567890ABCDEF01234567890ABCDEF01234567890ABCDEF01234567890ABCDEF" + "01234567890ABCDEE"); +} + +main() { + testBigintDivideRemainder(); +} diff --git a/tests/corelib/big_integer_parsed_mul_div_vm_test.dart b/tests/corelib/big_integer_parsed_mul_div_vm_test.dart new file mode 100644 index 00000000000..522c758365b --- /dev/null +++ b/tests/corelib/big_integer_parsed_mul_div_vm_test.dart @@ -0,0 +1,804 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// Testing Bigints with and without intrinsics. +// VMOptions= +// VMOptions=--no_intrinsify + +library big_integer_test; + +import "package:expect/expect.dart"; + +mulDivParsed(String a, String b, String product) { + int int_a = int.parse(a); + int int_b = int.parse(b); + int int_product = int.parse(product); + int computed_product = int_a * int_b; + Expect.equals(int_product, computed_product); + String str_product = computed_product >= 0 + ? "0x${computed_product.toRadixString(16)}" + : "-0x${(-computed_product).toRadixString(16)}"; + Expect.equals(product.toLowerCase(), str_product); + int computed_product2 = int_b * int_a; + Expect.equals(int_product, computed_product2); + String str_product2 = computed_product2 >= 0 + ? "0x${computed_product2.toRadixString(16)}" + : "-0x${(-computed_product2).toRadixString(16)}"; + Expect.equals(product.toLowerCase(), str_product2); + + if (int_a != 0) { + int computed_quotient1 = int_product ~/ int_a; + Expect.equals(int_b, computed_quotient1); + String str_quotient1 = computed_quotient1 >= 0 + ? "0x${computed_quotient1.toRadixString(16)}" + : "-0x${(-computed_quotient1).toRadixString(16)}"; + Expect.equals(b.toLowerCase(), str_quotient1); + } + + if (int_b != 0) { + int computed_quotient2 = int_product ~/ int_b; + Expect.equals(int_a, computed_quotient2); + String str_quotient2 = computed_quotient2 >= 0 + ? "0x${computed_quotient2.toRadixString(16)}" + : "-0x${(-computed_quotient2).toRadixString(16)}"; + Expect.equals(a.toLowerCase(), str_quotient2); + } +} + +testBigintMultiplyDivide() { + String zero = "0x0"; + String one = "0x1"; + String minus_one = "-0x1"; + + mulDivParsed(zero, zero, zero); + mulDivParsed(one, one, one); + mulDivParsed(one, zero, zero); + mulDivParsed(zero, one, zero); + mulDivParsed(one, minus_one, minus_one); + mulDivParsed(minus_one, minus_one, one); + mulDivParsed("0x42", one, "0x42"); + mulDivParsed("0x42", "0x2", "0x84"); + mulDivParsed("0xFFFF", "0x2", "0x1FFFE"); + mulDivParsed("0x3", "0x5", "0xF"); + mulDivParsed("0xFFFFF", "0x5", "0x4FFFFB"); + mulDivParsed("0xFFFFFFF", "0x5", "0x4FFFFFFB"); + mulDivParsed("0xFFFFFFFF", "0x5", "0x4FFFFFFFB"); + mulDivParsed("0xFFFFFFFFFFFFFFFF", "0x5", "0x4FFFFFFFFFFFFFFFB"); + mulDivParsed("0xFFFFFFFFFFFFFFFF", "0x3039", "0x3038FFFFFFFFFFFFCFC7"); + mulDivParsed("0xFFFFFFFFFFFFFFFF", "0xFFFFFFFFFFFFFFFFFFFFFFFFFF", + "0xFFFFFFFFFFFFFFFEFFFFFFFFFF0000000000000001"); + mulDivParsed( + "0xFFFFFFFFFFFFFFFF000000000000000000000000000000000000000000000", + "0xFFFFFFFFFFFFFFFFFFFFFFFFFF00000000000000000000000000000", + "0xFFFFFFFFFFFFFFFEFFFFFFFFFF000000000000000100000000000000" + "000000000000000000000000000000000000000000000000000000000000"); + mulDivParsed("0x10000001", "0x5", "0x50000005"); + mulDivParsed( + "0x1234567890ABCDEF01234567890ABCDEF01234567890ABCDEF" + "01234567890ABCDEF01234567890ABCDEF", + "0x1234567890ABCDEF01234567890ABCDEF01234567890ABCDEF" + "01234567890ABCDEF01234567890ABCDEF", + "0x14B66DC328828BCA670CBE52943AA3894CCCE15C8F5ED1E55F" + "328F6D3F579F992299850C4B5B95213EF3FB7B4E73B5F43D4299" + "5B9F6FD5441C275F2FF89F86F28F47A94CA37481090DCCCDCA6475F09A2F2A521"); + mulDivParsed( + "0x1234567890ABCDEF01234567890ABCDEF01234567890ABCDEF01234567890ABCDEF" + "01234567890ABCDEF", + "0x1234567890123456789012345678901234567890123456789012345678901234567890" + "123456789012345678901234567890123456789012345678901234567890123456789012" + "345678901234567890123456789012345678901234567890123456789012345678901234" + "567890123456789012345678901234567890123456789012345678901234567890123456" + "789012345678901234567890123456789012345678901234567890123456789012345678" + "90123456789012345678901234567890", + "0x14B66DC327D3C88D7EAA988BBFFA9BBA877826E7EDAF373907A931FBFC3A25231DF7F2" + "516F511FB1638F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A" + "8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F" + "0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B" + "570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B570F4A8F0B57" + "0F4A8F0B570F4A8F0B570F4A8F0B570F35D89D93E776C67DD864B2034B5C739007933027" + "5CDFD41E07A15D0F5AD5256BED5F1CF91FBA375DE70"); + mulDivParsed( + "0x1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFF", + "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", + "0x1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFDFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFF0000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000000001"); + mulDivParsed( + "0x1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFF", + "0x1FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFF", + "0x3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFC0000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000001"); + + // A 256 28-bit digits number squared. + mulDivParsed( + "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", + "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", + "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000001"); + + mulDivParsed( + "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", + "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF", + "0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF" + "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000001"); +} + +main() { + testBigintMultiplyDivide(); +} diff --git a/tests/corelib/bit_twiddling_bigint_test.dart b/tests/corelib/bit_twiddling_bigint_test.dart new file mode 100644 index 00000000000..a67ccae89e2 --- /dev/null +++ b/tests/corelib/bit_twiddling_bigint_test.dart @@ -0,0 +1,61 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. +// Testing Bigints. + +library bit_twiddling_test; + +import "package:expect/expect.dart"; + +// See bit_twiddling_test.dart first. This file contains only the tests that +// need Bigint or would fail in dart2js compatibility mode. + +testBitLength() { + check(int i, width) { + Expect.equals(width, i.bitLength, '$i.bitLength == $width'); + // (~i) written as (-i-1) to avoid issues with limited range of dart2js ops. + Expect.equals(width, (-i - 1).bitLength, '(~$i).bitLength == $width'); + } + + check(0xffffffffffffff, 56); + check(0xffffffffffffffff, 64); + check(0xffffffffffffffffff, 72); + check(0x1000000000000000000, 73); + check(0x1000000000000000001, 73); + + check(0xfffffffffffffffffffffffffffffffffffffe, 152); + check(0xffffffffffffffffffffffffffffffffffffff, 152); + check(0x100000000000000000000000000000000000000, 153); + check(0x100000000000000000000000000000000000001, 153); +} + +testToUnsigned() { + checkU(src, width, expected) { + Expect.equals(expected, src.toUnsigned(width)); + } + + checkU(0x100000100000000000001, 2, 1); + checkU(0x100000200000000000001, 60, 0x200000000000001); + checkU(0x100000200000000000001, 59, 0x200000000000001); + checkU(0x100000200000000000001, 58, 0x200000000000001); + checkU(0x100000200000000000001, 57, 1); +} + +testToSigned() { + checkS(src, width, expected) { + Expect.equals( + expected, src.toSigned(width), '$src.toSigned($width) == $expected'); + } + + checkS(0x100000100000000000001, 2, 1); + checkS(0x100000200000000000001, 60, 0x200000000000001); + checkS(0x100000200000000000001, 59, 0x200000000000001); + checkS(0x100000200000000000001, 58, -0x200000000000000 + 1); + checkS(0x100000200000000000001, 57, 1); +} + +main() { + testBitLength(); + testToUnsigned(); + testToSigned(); +} diff --git a/tests/corelib/bit_twiddling_test.dart b/tests/corelib/bit_twiddling_test.dart new file mode 100644 index 00000000000..b78d85e5251 --- /dev/null +++ b/tests/corelib/bit_twiddling_test.dart @@ -0,0 +1,173 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. +// Testing Bigints. + +library bit_twiddling_test; + +import "package:expect/expect.dart"; + +bool haveBigints() { + return 100000000000000000000 + 1 != 100000000000000000000; +} + +testBitLength() { + check(int i, width) { + Expect.equals(width, i.bitLength, '$i.bitLength == $width'); + // (~i) written as (-i-1) to avoid issues with limited range of dart2js ops. + Expect.equals(width, (-i - 1).bitLength, '(~$i).bitLength == $width'); + } + + check(0, 0); + check(1, 1); + check(2, 2); + check(3, 2); + check(4, 3); + check(5, 3); + check(6, 3); + check(7, 3); + check(8, 4); + check(127, 7); + check(128, 8); + check(129, 8); + check(2147483646, 31); + check(2147483647, 31); + check(2147483648, 32); + check(2147483649, 32); + check(4294967295, 32); + check(4294967296, 33); + check(0xffffffffff, 40); + check(0xfffffffffff, 44); + check(0xffffffffffff, 48); + check(0x1000000000000, 49); + check(0x1000000000001, 49); + check(0x1ffffffffffff, 49); + check(0x2000000000000, 50); + check(0x2000000000001, 50); + + if (haveBigints()) { + check(0xffffffffffffff, 56); + check(0xffffffffffffffff, 64); + check(0xffffffffffffffffff, 72); + check(0x1000000000000000000, 73); + check(0x1000000000000000001, 73); + + check(0xfffffffffffffffffffffffffffffffffffffe, 152); + check(0xffffffffffffffffffffffffffffffffffffff, 152); + check(0x100000000000000000000000000000000000000, 153); + check(0x100000000000000000000000000000000000001, 153); + } +} + +testToUnsigned() { + checkU(src, width, expected) { + Expect.equals(expected, src.toUnsigned(width)); + } + + checkU(1, 8, 1); + checkU(0xff, 8, 0xff); + checkU(0xffff, 8, 0xff); + checkU(-1, 8, 0xff); + checkU(0xffffffff, 32, 0xffffffff); + + checkU(0x7fffffff, 30, 0x3fffffff); + checkU(0x7fffffff, 31, 0x7fffffff); + checkU(0x7fffffff, 32, 0x7fffffff); + checkU(0x80000000, 30, 0); + checkU(0x80000000, 31, 0); + checkU(0x80000000, 32, 0x80000000); + checkU(0xffffffff, 30, 0x3fffffff); + checkU(0xffffffff, 31, 0x7fffffff); + checkU(0xffffffff, 32, 0xffffffff); + checkU(0x100000000, 30, 0); + checkU(0x100000000, 31, 0); + checkU(0x100000000, 32, 0); + checkU(0x1ffffffff, 30, 0x3fffffff); + checkU(0x1ffffffff, 31, 0x7fffffff); + checkU(0x1ffffffff, 32, 0xffffffff); + + checkU(-1, 0, 0); + checkU(0, 0, 0); + checkU(1, 0, 0); + checkU(2, 0, 0); + checkU(3, 0, 0); + + checkU(-1, 1, 1); + checkU(0, 1, 0); + checkU(1, 1, 1); + checkU(2, 1, 0); + checkU(3, 1, 1); + checkU(4, 1, 0); + + checkU(-1, 2, 3); + checkU(0, 2, 0); + checkU(1, 2, 1); + checkU(2, 2, 2); + checkU(3, 2, 3); + checkU(4, 2, 0); + + checkU(-1, 3, 7); + checkU(0, 3, 0); + checkU(1, 3, 1); + checkU(2, 3, 2); + checkU(3, 3, 3); + checkU(4, 3, 4); +} + +testToSigned() { + checkS(src, width, expected) { + Expect.equals( + expected, src.toSigned(width), '$src.toSigned($width) == $expected'); + } + + checkS(1, 8, 1); + checkS(0xff, 8, -1); + checkS(0xffff, 8, -1); + checkS(-1, 8, -1); + checkS(128, 8, -128); + checkS(0xffffffff, 32, -1); + + checkS(0x7fffffff, 30, -1); + checkS(0x7fffffff, 31, -1); + checkS(0x7fffffff, 32, 0x7fffffff); + checkS(0x80000000, 30, 0); + checkS(0x80000000, 31, 0); + checkS(0x80000000, 32, -2147483648); + checkS(0xffffffff, 30, -1); + checkS(0xffffffff, 31, -1); + checkS(0xffffffff, 32, -1); + + checkS(0x100000000, 30, 0); + checkS(0x100000000, 31, 0); + checkS(0x100000000, 32, 0); + checkS(0x1ffffffff, 30, -1); + checkS(0x1ffffffff, 31, -1); + checkS(0x1ffffffff, 32, -1); + + checkS(-1, 1, -1); + checkS(0, 1, 0); + checkS(1, 1, -1); // The only bit is the sign bit. + checkS(2, 1, 0); + checkS(3, 1, -1); + checkS(4, 1, 0); + + checkS(-1, 2, -1); + checkS(0, 2, 0); + checkS(1, 2, 1); + checkS(2, 2, -2); + checkS(3, 2, -1); + checkS(4, 2, 0); + + checkS(-1, 3, -1); + checkS(0, 3, 0); + checkS(1, 3, 1); + checkS(2, 3, 2); + checkS(3, 3, 3); + checkS(4, 3, -4); +} + +main() { + testBitLength(); + testToUnsigned(); + testToSigned(); +} diff --git a/tests/corelib/bool_from_environment2_test.dart b/tests/corelib/bool_from_environment2_test.dart new file mode 100644 index 00000000000..0329c544611 --- /dev/null +++ b/tests/corelib/bool_from_environment2_test.dart @@ -0,0 +1,11 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +main() { + const bool.fromEnvironment('NOT_FOUND', defaultValue: ''); // //# 01: compile-time error + const bool.fromEnvironment('NOT_FOUND', defaultValue: 1); // //# 02: compile-time error + const bool.fromEnvironment(null); // //# 03: compile-time error + const bool.fromEnvironment(1); // //# 04: compile-time error + const bool.fromEnvironment([]); // //# 05: compile-time error +} diff --git a/tests/corelib/bool_from_environment_test.dart b/tests/corelib/bool_from_environment_test.dart new file mode 100644 index 00000000000..5d01bde0994 --- /dev/null +++ b/tests/corelib/bool_from_environment_test.dart @@ -0,0 +1,15 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. +// SharedOptions=-Da=true -Db=false -Dc=NOTBOOL -Dd=True + +import "package:expect/expect.dart"; + +main() { + Expect.isTrue(const bool.fromEnvironment('a')); + Expect.isFalse(const bool.fromEnvironment('b')); + Expect.isTrue(const bool.fromEnvironment('c', defaultValue: true)); + Expect.isFalse(const bool.fromEnvironment('c', defaultValue: false)); + Expect.isFalse(const bool.fromEnvironment('d', defaultValue: false)); + Expect.equals(const bool.fromEnvironment('dart.isVM'), !identical(1.0, 1)); +} diff --git a/tests/corelib/bool_hashcode_test.dart b/tests/corelib/bool_hashcode_test.dart new file mode 100644 index 00000000000..d33b14a05d5 --- /dev/null +++ b/tests/corelib/bool_hashcode_test.dart @@ -0,0 +1,15 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +class BoolHashCodeTest { + static testMain() { + Expect.notEquals(true.hashCode, false.hashCode); + } +} + +main() { + BoolHashCodeTest.testMain(); +} diff --git a/tests/corelib/collection_from_test.dart b/tests/corelib/collection_from_test.dart new file mode 100644 index 00000000000..057d4e259ba --- /dev/null +++ b/tests/corelib/collection_from_test.dart @@ -0,0 +1,44 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +library collection.from.test; + +import "package:expect/expect.dart"; +import 'dart:collection' show Queue; + +class CollectionFromTest { + static testMain() { + var set = new Set(); + set.add(1); + set.add(2); + set.add(4); + check(set, new List.from(set)); + check(set, new List.from(set)); + check(set, new Queue.from(set)); + check(set, new Queue.from(set)); + check(set, new Set.from(set)); + check(set, new Set.from(set)); + } + + static check(Iterable initial, Iterable other) { + Expect.equals(3, initial.length); + Expect.equals(initial.length, other.length); + + int initialSum = 0; + int otherSum = 0; + + initial.forEach((e) { + initialSum += e; + }); + other.forEach((e) { + otherSum += e; + }); + Expect.equals(4 + 2 + 1, otherSum); + Expect.equals(otherSum, initialSum); + } +} + +main() { + CollectionFromTest.testMain(); +} diff --git a/tests/corelib/collection_length_test.dart b/tests/corelib/collection_length_test.dart new file mode 100644 index 00000000000..8d618fdb915 --- /dev/null +++ b/tests/corelib/collection_length_test.dart @@ -0,0 +1,76 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +library map_test; + +import 'dart:collection'; + +// Test that length/isEmpty opertions are constant time on +// maps, strings and collections. + +void testString(int n) { + String s = "x"; + String string = ""; + int length = n; + while (true) { + if ((length & 1) == 1) { + string += s; + } + length >>= 1; + if (length == 0) break; + s += s; + } + testLength(string, n); + testLength(string.codeUnits, n); +} + +void testMap(Map map, int n) { + for (int i = 0; i < n; i++) { + map[i] = i; + } + testLength(map, n); + testLength(map.keys, n); + testLength(map.values, n); +} + +void testCollection(var collection, n) { + for (int i = 0; i < n; i++) { + collection.add(i); + } + testLength(collection, n); +} + +void testList(List list, n) { + // Works even if list is fixed-length. + for (int i = 0; i < n; i++) { + list[i] = i; + } + testLength(list, n); +} + +void testLength(var lengthable, int size) { + print(lengthable.runtimeType); // Show what hangs the test. + int length = 0; + // If length, isEmpty or isNotEmpty is not a constant-time (or very fast) + // operation, this will timeout. + for (int i = 0; i < 100000; i++) { + if (!lengthable.isEmpty) length += lengthable.length; + if (lengthable.isNotEmpty) length += lengthable.length; + } + if (length != size * 200000) throw "Bad length: $length / size: $size"; +} + +main() { + const int N = 100000; + testMap(new HashMap(), N); + testMap(new LinkedHashMap(), N); + testMap(new SplayTreeMap(), N); + testCollection(new HashSet(), N); + testCollection(new LinkedHashSet(), N); + testCollection(new ListQueue(), N); + testCollection(new DoubleLinkedQueue(), N); + testList(new List()..length = N, N); + testList(new List(N), N); + testString(N); +} diff --git a/tests/corelib/collection_removes_test.dart b/tests/corelib/collection_removes_test.dart new file mode 100644 index 00000000000..793696df25a --- /dev/null +++ b/tests/corelib/collection_removes_test.dart @@ -0,0 +1,130 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'dart:collection'; +import "package:expect/expect.dart"; + +testRemove(base) { + int length = base.length; + for (int i = 0; i < length; i++) { + Expect.isFalse(base.isEmpty); + base.remove(base.first); + } + Expect.isTrue(base.isEmpty); +} + +testRemoveAll(base, Iterable removes) { + Set retained = new Set(); + for (var element in base) { + if (!removes.contains(element)) { + retained.add(element); + } + } + String name = "$base.removeAll($removes) -> $retained"; + base.removeAll(removes); + for (var value in base) { + Expect.isFalse(removes.contains(value), "$name: Found $value"); + } + for (var value in retained) { + Expect.isTrue(base.contains(value), "$name: Found $value"); + } +} + +testRetainAll(base, Iterable retains) { + Set retained = new Set(); + for (var element in base) { + if (retains.contains(element)) { + retained.add(element); + } + } + String name = "$base.retainAll($retains) -> $retained"; + base.retainAll(retains); + for (var value in base) { + Expect.isTrue(retains.contains(value), "$name: Found $value"); + } + for (var value in retained) { + Expect.isTrue(base.contains(value), "$name: Found $value"); + } +} + +testRemoveWhere(base, bool test(value)) { + Set retained = new Set(); + for (var element in base) { + if (!test(element)) { + retained.add(element); + } + } + String name = "$base.removeWhere(...) -> $retained"; + base.removeWhere(test); + for (var value in base) { + Expect.isFalse(test(value), "$name: Found $value"); + } + for (var value in retained) { + Expect.isTrue(base.contains(value), "$name: Found $value"); + } +} + +testRetainWhere(base, bool test(value)) { + Set retained = new Set(); + for (var element in base) { + if (test(element)) { + retained.add(element); + } + } + String name = "$base.retainWhere(...) -> $retained"; + base.retainWhere(test); + for (var value in base) { + Expect.isTrue(test(value), "$name: Found $value"); + } + for (var value in retained) { + Expect.isTrue(base.contains(value), "$name: Found $value"); + } +} + +void main() { + var collections = [ + [], + [1], + [2], + [1, 2], + [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], + [1, 3, 5, 7, 9], + [2, 4, 6, 8, 10] + ]; + for (var base in collections) { + for (var delta in collections) { + testRemove(base.toList()); + testRemove(base.toSet()); + + var deltaSet = delta.toSet(); + testRemoveWhere(base.toList(), deltaSet.contains); + testRetainWhere(base.toList(), (e) => !deltaSet.contains(e)); + + testRemoveAll(base.toSet(), delta); + testRemoveAll(base.toSet(), deltaSet); + testRetainAll(base.toSet(), delta); + testRetainAll(base.toSet(), deltaSet); + testRemoveWhere(base.toSet(), deltaSet.contains); + testRetainWhere(base.toSet(), (e) => !deltaSet.contains(e)); + + // Test the ListBase class's List implementation. + testRemoveWhere(new MyList(base.toList()), deltaSet.contains); + testRetainWhere(new MyList(base.toList()), (e) => !deltaSet.contains(e)); + } + } +} + +class MyList extends ListBase { + List _source; + MyList(this._source); + int get length => _source.length; + void set length(int length) { + _source.length = length; + } + + E operator [](int index) => _source[index]; + void operator []=(int index, E value) { + _source[index] = value; + } +} diff --git a/tests/corelib/collection_test.dart b/tests/corelib/collection_test.dart new file mode 100644 index 00000000000..bcbfd830a39 --- /dev/null +++ b/tests/corelib/collection_test.dart @@ -0,0 +1,41 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +library collection_test; + +import "package:expect/expect.dart"; +import 'dart:collection' show Queue; + +class CollectionTest { + CollectionTest(Iterable iterable) { + testFold(iterable); + } + + void testFold(Iterable iterable) { + Expect.equals(28, iterable.fold(0, (prev, element) => prev + element)); + Expect.equals(3024, iterable.fold(1, (prev, element) => prev * element)); + } +} + +main() { + final TEST_ELEMENTS = const [4, 2, 6, 7, 9]; + // Const list. + new CollectionTest(TEST_ELEMENTS); + + // Fixed size list. + var fixedList = new List(TEST_ELEMENTS.length); + for (int i = 0; i < TEST_ELEMENTS.length; i++) { + fixedList[i] = TEST_ELEMENTS[i]; + } + new CollectionTest(fixedList); + + // Growable list. + new CollectionTest(new List.from(TEST_ELEMENTS)); + + // Set. + new CollectionTest(new Set.from(TEST_ELEMENTS)); + + // Queue. + new CollectionTest(new Queue.from(TEST_ELEMENTS)); +} diff --git a/tests/corelib/collection_to_string_test.dart b/tests/corelib/collection_to_string_test.dart new file mode 100644 index 00000000000..1dc25339d58 --- /dev/null +++ b/tests/corelib/collection_to_string_test.dart @@ -0,0 +1,387 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/** + * Tests for the toString methods on collections and maps. + */ + +library collection_to_string; + +import "package:expect/expect.dart"; +import 'dart:collection' show Queue, LinkedHashMap; +import 'dart:math' as Math; + +// TODO(jjb): seed random number generator when API allows it + +const int NUM_TESTS = 300; +const int MAX_COLLECTION_SIZE = 7; + +Math.Random rand; + +main() { + rand = new Math.Random(); + smokeTest(); + exactTest(); + inexactTest(); +} + +/** + * Test a few simple examples. + */ +void smokeTest() { + // Non-const lists + Expect.equals([].toString(), '[]'); + Expect.equals([1].toString(), '[1]'); + Expect.equals(['Elvis'].toString(), '[Elvis]'); + Expect.equals([null].toString(), '[null]'); + Expect.equals([1, 2].toString(), '[1, 2]'); + Expect.equals(['I', 'II'].toString(), '[I, II]'); + Expect.equals( + [ + [1, 2], + [3, 4], + [5, 6] + ].toString(), + '[[1, 2], [3, 4], [5, 6]]'); + + // Const lists + Expect.equals((const []).toString(), '[]'); + Expect.equals((const [1]).toString(), '[1]'); + Expect.equals((const ['Elvis']).toString(), '[Elvis]'); + Expect.equals((const [null]).toString(), '[null]'); + Expect.equals((const [1, 2]).toString(), '[1, 2]'); + Expect.equals((const ['I', 'II']).toString(), '[I, II]'); + Expect.equals( + (const [ + const [1, 2], + const [3, 4], + const [5, 6] + ]) + .toString(), + '[[1, 2], [3, 4], [5, 6]]'); + + // Non-const maps - Note that all keys are strings; the spec currently demands this + Expect.equals({}.toString(), '{}'); + Expect.equals({'Elvis': 'King'}.toString(), '{Elvis: King}'); + Expect.equals({'Elvis': null}.toString(), '{Elvis: null}'); + Expect.equals({'I': 1, 'II': 2}.toString(), '{I: 1, II: 2}'); + Expect.equals( + { + 'X': {'I': 1, 'II': 2}, + 'Y': {'III': 3, 'IV': 4}, + 'Z': {'V': 5, 'VI': 6} + }.toString(), + '{X: {I: 1, II: 2}, Y: {III: 3, IV: 4}, Z: {V: 5, VI: 6}}'); + + // Const maps + Expect.equals(const {}.toString(), '{}'); + Expect.equals(const {'Elvis': 'King'}.toString(), '{Elvis: King}'); + Expect.equals({'Elvis': null}.toString(), '{Elvis: null}'); + Expect.equals(const {'I': 1, 'II': 2}.toString(), '{I: 1, II: 2}'); + Expect.equals( + const { + 'X': const {'I': 1, 'II': 2}, + 'Y': const {'III': 3, 'IV': 4}, + 'Z': const {'V': 5, 'VI': 6} + }.toString(), + '{X: {I: 1, II: 2}, Y: {III: 3, IV: 4}, Z: {V: 5, VI: 6}}'); +} + +// SERIOUS "BASHER" TESTS + +/** + * Generate a bunch of random collections (including Maps), and test that + * there string form is as expected. The collections include collections + * as elements, keys, and values, and include recursive references. + * + * This test restricts itself to collections with well-defined iteration + * orders (i.e., no HashSet, HashMap). + */ +void exactTest() { + for (int i = 0; i < NUM_TESTS; i++) { + // Choose a size from 0 to MAX_COLLECTION_SIZE, favoring larger sizes + int size = + Math.sqrt(random(MAX_COLLECTION_SIZE * MAX_COLLECTION_SIZE)).toInt(); + + StringBuffer stringRep = new StringBuffer(); + Object o = randomCollection(size, stringRep, exact: true); + print(stringRep); + print(o); + Expect.equals(o.toString(), stringRep.toString()); + } +} + +/** + * Generate a bunch of random collections (including Maps), and test that + * there string form is as expected. The collections include collections + * as elements, keys, and values, and include recursive references. + * + * This test includes collections with ill-defined iteration orders (i.e., + * HashSet, HashMap). As a consequence, it can't use equality tests on the + * string form. Instead, it performs equality tests on their "alphagrams." + * This might allow false positives, but it does give a fair amount of + * confidence. + */ +void inexactTest() { + for (int i = 0; i < NUM_TESTS; i++) { + // Choose a size from 0 to MAX_COLLECTION_SIZE, favoring larger sizes + int size = + Math.sqrt(random(MAX_COLLECTION_SIZE * MAX_COLLECTION_SIZE)).toInt(); + + StringBuffer stringRep = new StringBuffer(); + Object o = randomCollection(size, stringRep, exact: false); + print(stringRep); + print(o); + Expect.equals(alphagram(o.toString()), alphagram(stringRep.toString())); + } +} + +/** + * Return a random collection (or Map) of the specified size, placing its + * string representation into the given string buffer. + * + * If exact is true, the returned collections will not be, and will not contain + * a collection with ill-defined iteration order (i.e., a HashSet or HashMap). + */ +Object randomCollection(int size, StringBuffer stringRep, {bool exact}) { + return randomCollectionHelper(size, exact, stringRep, []); +} + +/** + * Return a random collection (or map) of the specified size, placing its + * string representation into the given string buffer. The beingMade + * parameter is a list of collections currently under construction, i.e., + * candidates for recursive references. + * + * If exact is true, the returned collections will not be, and will not contain + * a collection with ill-defined iteration order (i.e., a HashSet or HashMap). + */ +Object randomCollectionHelper( + int size, bool exact, StringBuffer stringRep, List beingMade) { + double interfaceFrac = rand.nextDouble(); + + if (exact) { + if (interfaceFrac < 1 / 3) { + return randomList(size, exact, stringRep, beingMade); + } else if (interfaceFrac < 2 / 3) { + return randomQueue(size, exact, stringRep, beingMade); + } else { + return randomMap(size, exact, stringRep, beingMade); + } + } else { + if (interfaceFrac < 1 / 4) { + return randomList(size, exact, stringRep, beingMade); + } else if (interfaceFrac < 2 / 4) { + return randomQueue(size, exact, stringRep, beingMade); + } else if (interfaceFrac < 3 / 4) { + return randomSet(size, exact, stringRep, beingMade); + } else { + return randomMap(size, exact, stringRep, beingMade); + } + } +} + +/** + * Return a random List of the specified size, placing its string + * representation into the given string buffer. The beingMade + * parameter is a list of collections currently under construction, i.e., + * candidates for recursive references. + * + * If exact is true, the returned collections will not be, and will not contain + * a collection with ill-defined iteration order (i.e., a HashSet or HashMap). + */ +List randomList(int size, bool exact, StringBuffer stringRep, List beingMade) { + return populateRandomCollection(size, exact, stringRep, beingMade, [], "[]"); +} + +/** + * Like randomList, but returns a queue. + */ +Queue randomQueue( + int size, bool exact, StringBuffer stringRep, List beingMade) { + return populateRandomCollection( + size, exact, stringRep, beingMade, new Queue(), "{}"); +} + +/** + * Like randomList, but returns a Set. + */ +Set randomSet(int size, bool exact, StringBuffer stringRep, List beingMade) { + // Until we have LinkedHashSet, method will only be called with exact==true + return populateRandomSet(size, exact, stringRep, beingMade, new Set()); +} + +/** + * Like randomList, but returns a map. + */ +Map randomMap(int size, bool exact, StringBuffer stringRep, List beingMade) { + if (exact) { + return populateRandomMap( + size, exact, stringRep, beingMade, new LinkedHashMap()); + } else { + return populateRandomMap(size, exact, stringRep, beingMade, + randomBool() ? new Map() : new LinkedHashMap()); + } +} + +/** + * Populates the given empty collection with elements, emitting the string + * representation of the collection to stringRep. The beingMade parameter is + * a list of collections currently under construction, i.e., candidates for + * recursive references. + * + * If exact is true, the elements of the returned collections will not be, + * and will not contain a collection with ill-defined iteration order + * (i.e., a HashSet or HashMap). + */ +populateRandomCollection(int size, bool exact, StringBuffer stringRep, + List beingMade, var coll, String delimiters) { + beingMade.add(coll); + int start = stringRep.length; + + stringRep.write(delimiters[0]); + + List indices = []; + for (int i = 0; i < size; i++) { + indices.add(stringRep.length); + if (i != 0) stringRep.write(', '); + coll.add(randomElement(random(size), exact, stringRep, beingMade)); + } + if (size > 5 && delimiters == "()") { + const int MAX_LENGTH = 80; + const int MIN_COUNT = 3; + const int MAX_COUNT = 100; + // It's an iterable, it may omit some elements. + int end = stringRep.length; + if (size > MAX_COUNT) { + // Last two elements are also omitted, just find the first three or + // first 60 characters. + for (int i = MIN_COUNT; i < size; i++) { + int startIndex = indices[i]; + if (startIndex - start > MAX_LENGTH - 6) { + // Limit - ", ...)".length. + String prefix = stringRep.toString().substring(0, startIndex); + stringRep.clear(); + stringRep.write(prefix); + stringRep.write(", ..."); + } + } + } else if (stringRep.length - start > MAX_LENGTH - 1) { + // 80 - ")".length. + // Last two elements are always included. Middle ones may be omitted. + int lastTwoLength = end - indices[indices.length - 2]; + // Try to find first element to omit. + for (int i = 3; i <= size - 3; i++) { + int elementEnd = indices[i + 1]; + int lengthAfter = elementEnd - start; + int ellipsisSize = 5; // ", ...".length + if (i == size - 3) ellipsisSize = 0; // No ellipsis if we hit the end. + if (lengthAfter + ellipsisSize + lastTwoLength > MAX_LENGTH - 1) { + // Omit this element and everything up to the last two. + int elementStart = indices[i]; + // Rewrite string buffer by copying it out, clearing, and putting + // the parts back in. + String buffer = stringRep.toString(); + String prefix = buffer.substring(0, elementStart); + String suffix = buffer.substring(end - lastTwoLength, end); + stringRep.clear(); + stringRep.write(prefix); + stringRep.write(", ..."); + stringRep.write(suffix); + break; + } + } + } + } + + stringRep.write(delimiters[1]); + beingMade.removeLast(); + return coll; +} + +/** Like populateRandomCollection, but for sets (elements must be hashable) */ +Set populateRandomSet( + int size, bool exact, StringBuffer stringRep, List beingMade, Set set) { + stringRep.write('{'); + + for (int i = 0; i < size; i++) { + if (i != 0) stringRep.write(', '); + set.add(i); + stringRep.write(i); + } + + stringRep.write('}'); + return set; +} + +/** Like populateRandomCollection, but for maps. */ +Map populateRandomMap( + int size, bool exact, StringBuffer stringRep, List beingMade, Map map) { + beingMade.add(map); + stringRep.write('{'); + + for (int i = 0; i < size; i++) { + if (i != 0) stringRep.write(', '); + + int key = i; // Ensures no duplicates + stringRep.write(key); + stringRep.write(': '); + Object val = randomElement(random(size), exact, stringRep, beingMade); + map[key] = val; + } + + stringRep.write('}'); + beingMade.removeLast(); + return map; +} + +/** + * Generates a random element which can be an int, a collection, or a map, + * and emits it to StringRep. The beingMade parameter is a list of collections + * currently under construction, i.e., candidates for recursive references. + * + * If exact is true, the returned element will not be, and will not contain + * a collection with ill-defined iteration order (i.e., a HashSet or HashMap). + */ +Object randomElement( + int size, bool exact, StringBuffer stringRep, List beingMade) { + Object result; + double elementTypeFrac = rand.nextDouble(); + if (elementTypeFrac < 1 / 3) { + result = random(1000); + stringRep.write(result); + } else if (elementTypeFrac < 2 / 3) { + // Element is a random (new) collection + result = randomCollectionHelper(size, exact, stringRep, beingMade); + } else { + // Element is a random recursive ref + result = beingMade[random(beingMade.length)]; + if (result is List) { + stringRep.write('[...]'); + } else if (result is Set || result is Map || result is Queue) { + stringRep.write('{...}'); + } else { + stringRep.write('(...)'); + } + } + return result; +} + +/** Returns a random int on [0, max) */ +int random(int max) { + return rand.nextInt(max); +} + +/** Returns a random boolean value. */ +bool randomBool() { + return rand.nextBool(); +} + +/** Returns the alphabetized characters in a string. */ +String alphagram(String s) { + // Calling [toList] to convert unmodifiable list to normal list. + List chars = s.codeUnits.toList(); + chars.sort((int a, int b) => a - b); + return new String.fromCharCodes(chars); +} diff --git a/tests/corelib/compare_to2_test.dart b/tests/corelib/compare_to2_test.dart new file mode 100644 index 00000000000..feac212ee9c --- /dev/null +++ b/tests/corelib/compare_to2_test.dart @@ -0,0 +1,94 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. +// Dart test for testing Math.min and Math.max. + +import "package:expect/expect.dart"; + +negate(x) => -x; + +main() { + // Test matrix: + var minNonZero = 5e-324; + var maxDenormal = 2.225073858507201e-308; + var minNormal = 2.2250738585072014e-308; + var maxFraction = 0.9999999999999999; + var minAbove1 = 1.0000000000000002; + var maxNonInt = 4503599627370495.5; + var maxNonIntFloorAsInt = maxNonInt.floor(); + var maxNonIntFloorAsDouble = maxNonIntFloorAsInt.toDouble(); + var maxExactIntAsDouble = 9007199254740992.0; + var maxExactIntAsInt = 9007199254740992; + var two53 = 1 << 53; // Same as maxExactIntAsInt. + var two53p1 = two53 + 1; + var maxFiniteAsDouble = 1.7976931348623157e+308; + var maxFiniteAsInt = maxFiniteAsDouble.truncate(); + int huge = 1 << 2000; + int hugeP1 = huge + 1; + var inf = double.INFINITY; + var nan = double.NAN; + var mnan = negate(nan); + var matrix = [ + -inf, + -hugeP1, + -huge, + [-maxFiniteAsDouble, -maxFiniteAsInt], + -two53p1, + [-two53, -maxExactIntAsInt, -maxExactIntAsDouble], + -maxNonInt, + [-maxNonIntFloorAsDouble, -maxNonIntFloorAsInt], + [-499.0, -499], + -minAbove1, + [-1.0, -1], + -maxFraction, + -minNormal, + -maxDenormal, + -minNonZero, + -0.0, + [0, 0, 0], + minNonZero, + maxDenormal, + minNormal, + maxFraction, + [1.0, 1], + minAbove1, + [499.0, 499], + [maxNonIntFloorAsDouble, maxNonIntFloorAsInt], + maxNonInt, + [two53, maxExactIntAsInt, maxExactIntAsDouble], + two53p1, + [maxFiniteAsDouble, maxFiniteAsInt], + huge, + hugeP1, + inf, + [nan, mnan], + ]; + + check(left, right, expectedResult) { + if (left is List) { + for (var x in left) check(x, right, expectedResult); + return; + } + if (right is List) { + for (var x in right) check(left, x, expectedResult); + return; + } + int actual = left.compareTo(right); + Expect.equals( + expectedResult, + actual, + "($left).compareTo($right) failed " + "(should have been $expectedResult, was $actual"); + } + + for (int i = 0; i < matrix.length; i++) { + for (int j = 0; j < matrix.length; j++) { + var left = matrix[i]; + var right = matrix[j]; + if (left is List) { + check(left, left, 0); + } + check(left, right, i == j ? 0 : (i < j ? -1 : 1)); + } + } +} diff --git a/tests/corelib/compare_to_test.dart b/tests/corelib/compare_to_test.dart new file mode 100644 index 00000000000..35d8f634179 --- /dev/null +++ b/tests/corelib/compare_to_test.dart @@ -0,0 +1,136 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. +// Dart test for testing Math.min and Math.max. + +import "package:expect/expect.dart"; + +negate(x) => -x; + +main() { + // Test matrix: + // -inf < -499.0 == -499 < -0.0 < 0.0 == 0 < 499.0 == 499 < +inf < -NaN, NaN. + var inf = double.INFINITY; + var nan = double.NAN; + var mnan = negate(nan); + + Expect.equals(0, (-inf).compareTo(-inf)); + Expect.equals(-1, (-inf).compareTo(-499.0)); + Expect.equals(-1, (-inf).compareTo(-499)); + Expect.equals(-1, (-inf).compareTo(-0.0)); + Expect.equals(-1, (-inf).compareTo(0)); + Expect.equals(-1, (-inf).compareTo(0.0)); + Expect.equals(-1, (-inf).compareTo(499.0)); + Expect.equals(-1, (-inf).compareTo(499)); + Expect.equals(-1, (-inf).compareTo(inf)); + Expect.equals(-1, (-inf).compareTo(nan)); + Expect.equals(-1, (-inf).compareTo(mnan)); + + Expect.equals(1, (-499.0).compareTo(-inf)); + Expect.equals(0, (-499.0).compareTo(-499.0)); + Expect.equals(0, (-499.0).compareTo(-499)); + Expect.equals(-1, (-499.0).compareTo(-0.0)); + Expect.equals(-1, (-499.0).compareTo(0)); + Expect.equals(-1, (-499.0).compareTo(0.0)); + Expect.equals(-1, (-499.0).compareTo(499.0)); + Expect.equals(-1, (-499.0).compareTo(499)); + Expect.equals(-1, (-499.0).compareTo(inf)); + Expect.equals(-1, (-499.0).compareTo(nan)); + Expect.equals(-1, (-499.0).compareTo(mnan)); + + Expect.equals(1, (-499).compareTo(-inf)); + Expect.equals(0, (-499).compareTo(-499.0)); + Expect.equals(0, (-499).compareTo(-499)); + Expect.equals(-1, (-499).compareTo(-0.0)); + Expect.equals(-1, (-499).compareTo(0)); + Expect.equals(-1, (-499).compareTo(0.0)); + Expect.equals(-1, (-499).compareTo(499.0)); + Expect.equals(-1, (-499).compareTo(499)); + Expect.equals(-1, (-499).compareTo(inf)); + Expect.equals(-1, (-499).compareTo(nan)); + Expect.equals(-1, (-499).compareTo(mnan)); + + Expect.equals(1, (-0.0).compareTo(-inf)); + Expect.equals(1, (-0.0).compareTo(-499.0)); + Expect.equals(1, (-0.0).compareTo(-499)); + Expect.equals(0, (-0.0).compareTo(-0.0)); + Expect.equals(-1, (-0.0).compareTo(0)); + Expect.equals(-1, (-0.0).compareTo(0.0)); + Expect.equals(-1, (-0.0).compareTo(499.0)); + Expect.equals(-1, (-0.0).compareTo(499)); + Expect.equals(-1, (-0.0).compareTo(inf)); + Expect.equals(-1, (-0.0).compareTo(nan)); + Expect.equals(-1, (-0.0).compareTo(mnan)); + + Expect.equals(1, (0).compareTo(-inf)); + Expect.equals(1, (0).compareTo(-499.0)); + Expect.equals(1, (0).compareTo(-499)); + Expect.equals(1, (0).compareTo(-0.0)); + Expect.equals(0, (0).compareTo(0)); + Expect.equals(0, (0).compareTo(0.0)); + Expect.equals(-1, (0).compareTo(499.0)); + Expect.equals(-1, (0).compareTo(499)); + Expect.equals(-1, (0).compareTo(inf)); + Expect.equals(-1, (0).compareTo(nan)); + Expect.equals(-1, (0).compareTo(mnan)); + + Expect.equals(1, (0.0).compareTo(-inf)); + Expect.equals(1, (0.0).compareTo(-499.0)); + Expect.equals(1, (0.0).compareTo(-499)); + Expect.equals(1, (0.0).compareTo(-0.0)); + Expect.equals(0, (0.0).compareTo(0)); + Expect.equals(0, (0.0).compareTo(0.0)); + Expect.equals(-1, (0.0).compareTo(499.0)); + Expect.equals(-1, (0.0).compareTo(499)); + Expect.equals(-1, (0.0).compareTo(inf)); + Expect.equals(-1, (0.0).compareTo(nan)); + Expect.equals(-1, (0.0).compareTo(mnan)); + + Expect.equals(1, (499.0).compareTo(-inf)); + Expect.equals(1, (499.0).compareTo(-499.0)); + Expect.equals(1, (499.0).compareTo(-499)); + Expect.equals(1, (499.0).compareTo(-0.0)); + Expect.equals(1, (499.0).compareTo(0)); + Expect.equals(1, (499.0).compareTo(0.0)); + Expect.equals(0, (499.0).compareTo(499.0)); + Expect.equals(0, (499.0).compareTo(499)); + Expect.equals(-1, (499.0).compareTo(inf)); + Expect.equals(-1, (499.0).compareTo(nan)); + Expect.equals(-1, (499.0).compareTo(mnan)); + + Expect.equals(1, (499).compareTo(-inf)); + Expect.equals(1, (499).compareTo(-499.0)); + Expect.equals(1, (499).compareTo(-499)); + Expect.equals(1, (499).compareTo(-0.0)); + Expect.equals(1, (499).compareTo(0)); + Expect.equals(1, (499).compareTo(0.0)); + Expect.equals(0, (499).compareTo(499.0)); + Expect.equals(0, (499).compareTo(499)); + Expect.equals(-1, (499).compareTo(inf)); + Expect.equals(-1, (499).compareTo(nan)); + Expect.equals(-1, (499).compareTo(mnan)); + + Expect.equals(1, inf.compareTo(-inf)); + Expect.equals(1, inf.compareTo(-499.0)); + Expect.equals(1, inf.compareTo(-499)); + Expect.equals(1, inf.compareTo(-0.0)); + Expect.equals(1, inf.compareTo(0)); + Expect.equals(1, inf.compareTo(0.0)); + Expect.equals(1, inf.compareTo(499.0)); + Expect.equals(1, inf.compareTo(499)); + Expect.equals(0, inf.compareTo(inf)); + Expect.equals(-1, inf.compareTo(nan)); + Expect.equals(-1, inf.compareTo(mnan)); + + Expect.equals(1, nan.compareTo(-inf)); + Expect.equals(1, nan.compareTo(-499.0)); + Expect.equals(1, nan.compareTo(-499)); + Expect.equals(1, nan.compareTo(-0.0)); + Expect.equals(1, nan.compareTo(0)); + Expect.equals(1, nan.compareTo(0.0)); + Expect.equals(1, nan.compareTo(499.0)); + Expect.equals(1, nan.compareTo(499)); + Expect.equals(1, nan.compareTo(inf)); + Expect.equals(0, nan.compareTo(nan)); + Expect.equals(0, nan.compareTo(mnan)); +} diff --git a/tests/corelib/const_list_literal_test.dart b/tests/corelib/const_list_literal_test.dart new file mode 100644 index 00000000000..cf61c4f5701 --- /dev/null +++ b/tests/corelib/const_list_literal_test.dart @@ -0,0 +1,80 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +// Test that a final list literal is not expandable nor modifiable. + +class ConstListLiteralTest { + static void testMain() { + var list = const [4, 2, 3]; + Expect.equals(3, list.length); + + var exception = null; + try { + list.add(4); + } on UnsupportedError catch (e) { + exception = e; + } + Expect.equals(true, exception != null); + Expect.equals(3, list.length); + exception = null; + + exception = null; + try { + list.addAll([4, 5]); + } on UnsupportedError catch (e) { + exception = e; + } + Expect.equals(true, exception != null); + Expect.equals(3, list.length); + + exception = null; + try { + list[0] = 0; + } on UnsupportedError catch (e) { + exception = e; + } + Expect.equals(true, exception != null); + Expect.equals(3, list.length); + + exception = null; + try { + list.sort((a, b) => a - b); + } on UnsupportedError catch (e) { + exception = e; + } + Expect.equals(true, exception != null); + Expect.equals(3, list.length); + Expect.equals(4, list[0]); + Expect.equals(2, list[1]); + Expect.equals(3, list[2]); + + exception = null; + try { + list.setRange(0, 1, [1], 0); + } on UnsupportedError catch (e) { + exception = e; + } + Expect.equals(true, exception != null); + Expect.equals(3, list.length); + Expect.equals(4, list[0]); + Expect.equals(2, list[1]); + Expect.equals(3, list[2]); + + // Note: the next check is a regression test for dart2js. The immutable list + // overrides the 'length' property of List, but relies on using the native + // 'forEach' construct in Array. This test ensures that our strategy works + // correctly. + int x = 0; + list.forEach((e) { + x += e; + }); + Expect.equals(9, x); + } +} + +main() { + ConstListLiteralTest.testMain(); +} diff --git a/tests/corelib/const_list_remove_range_test.dart b/tests/corelib/const_list_remove_range_test.dart new file mode 100644 index 00000000000..ff53be59d13 --- /dev/null +++ b/tests/corelib/const_list_remove_range_test.dart @@ -0,0 +1,27 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + testImmutable(const []); + testImmutable(const [1]); + testImmutable(const [1, 2]); +} + +void expectUOE(Function f) { + Expect.throws(f, (e) => e is UnsupportedError); +} + +testImmutable(var list) { + expectUOE(() { + list.removeRange(0, 0); + }); + expectUOE(() { + list.removeRange(0, 1); + }); + expectUOE(() { + list.removeRange(-1, 1); + }); +} diff --git a/tests/corelib/const_list_set_range_test.dart b/tests/corelib/const_list_set_range_test.dart new file mode 100644 index 00000000000..e82b2552d11 --- /dev/null +++ b/tests/corelib/const_list_set_range_test.dart @@ -0,0 +1,51 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + testImmutable(const []); + testImmutable(const [1]); + testImmutable(const [1, 2]); +} + +void expectUOE(Function f) { + Expect.throws(f, (e) => e is UnsupportedError); +} + +testImmutable(var list) { + expectUOE(() { + list.setRange(0, 0, const []); + }); + expectUOE(() { + list.setRange(0, 1, const [], 1); + }); + expectUOE(() { + list.setRange(0, 1, const []); + }); + expectUOE(() { + list.setRange(0, 0, []); + }); + expectUOE(() { + list.setRange(0, 1, [], 1); + }); + expectUOE(() { + list.setRange(0, 1, []); + }); + expectUOE(() { + list.setRange(0, 0, const [1]); + }); + expectUOE(() { + list.setRange(0, 1, const [1]); + }); + expectUOE(() { + list.setRange(0, 0, [1]); + }); + expectUOE(() { + list.setRange(0, 1, [1]); + }); + expectUOE(() { + list.setRange(0, 1, [1], 1); + }); +} diff --git a/tests/corelib/core_runtime_types_test.dart b/tests/corelib/core_runtime_types_test.dart new file mode 100644 index 00000000000..2da72f7b870 --- /dev/null +++ b/tests/corelib/core_runtime_types_test.dart @@ -0,0 +1,342 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +/** + * A test of simple runtime behavior on numbers, strings and lists with + * a focus on both correct behavior and runtime errors. + * + * This file is written to use minimal type declarations to match a + * typical dynamic language coding style. + */ +class CoreRuntimeTypesTest { + static testMain() { + testBooleanOperators(); + testRationalOperators(); + testIntegerOperators(); + testOperatorErrors(); + testRationalMethods(); + testIntegerMethods(); + testStringOperators(); + testStringMethods(); + testListOperators(); + testListMethods(); + testMapOperators(); + testMapMethods(); + testLiterals(); + testDateMethods(); + } + + static assertEquals(a, b) { + Expect.equals(b, a); + } + + static assertListEquals(List a, List b) { + Expect.equals(b.length, a.length); + for (int i = 0; i < a.length; i++) { + Expect.equals(b[i], a[i]); + } + } + + static assertListContains(List a, List b) { + a.sort((x, y) => x.compareTo(y)); + b.sort((x, y) => x.compareTo(y)); + assertListEquals(a, b); + } + + static assertTypeError(void f()) { + Expect.throws( + f, + (exception) => + (exception is TypeError) || + (exception is NoSuchMethodError) || + (exception is ArgumentError)); + } + + static testBooleanOperators() { + var x = true, y = false; + assertEquals(x, true); + assertEquals(y, false); + assertEquals(x, !y); + assertEquals(!x, y); + } + + static testRationalOperators() { + var x = 10, y = 20; + assertEquals(x + y, 30); + assertEquals(x - y, -10); + assertEquals(x * y, 200); + assertEquals(x / y, 0.5); + assertEquals(x ~/ y, 0); + assertEquals(x % y, 10); + } + + static testIntegerOperators() { + var x = 18, y = 17; + assertEquals(x | y, 19); + assertEquals(x & y, 16); + assertEquals(x ^ y, 3); + assertEquals(2 >> 1, 1); + assertEquals(1 << 1, 2); + } + + static testOperatorErrors() { + var objs = [ + 1, + '2', + [3], + null, + true, + new Map() + ]; + for (var i = 0; i < objs.length; i++) { + for (var j = i + 1; j < objs.length; j++) { + testBinaryOperatorErrors(objs[i], objs[j]); + // Allow "String * int". + if (j > 2) testBinaryOperatorErrors(objs[j], objs[i]); + } + if (objs[i] != 1) { + testUnaryOperatorErrors(objs[i]); + } + } + } + + static testBinaryOperatorErrors(x, y) { + assertTypeError(() { + x - y; + }); + assertTypeError(() { + x * y; + }); + assertTypeError(() { + x / y; + }); + assertTypeError(() { + x | y; + }); + assertTypeError(() { + x ^ y; + }); + assertTypeError(() { + x & y; + }); + assertTypeError(() { + x << y; + }); + assertTypeError(() { + x >> y; + }); + assertTypeError(() { + x ~/ y; + }); + assertTypeError(() { + x % y; + }); + + testComparisonOperatorErrors(x, y); + } + + static testComparisonOperatorErrors(x, y) { + assertEquals(x == y, false); + assertEquals(x != y, true); + assertTypeError(() { + x < y; + }); + assertTypeError(() { + x <= y; + }); + assertTypeError(() { + x > y; + }); + assertTypeError(() { + x >= y; + }); + } + + static testUnaryOperatorErrors(x) { + // TODO(jimhug): Add guard for 'is num' when 'is' is working + assertTypeError(() { + ~x; + }); + assertTypeError(() { + -x; + }); + // TODO(jimhug): Add check for !x as an error when x is not a bool + } + + static testRationalMethods() { + var x = 10.6; + assertEquals(x.abs(), 10.6); + assertEquals((-x).abs(), 10.6); + assertEquals(x.round(), 11); + assertEquals(x.floor(), 10); + assertEquals(x.ceil(), 11); + } + + // TODO(jimhug): Determine correct behavior for mixing ints and floats. + static testIntegerMethods() { + var y = 9; + assertEquals(y.isEven, false); + assertEquals(y.isOdd, true); + assertEquals(y.toRadixString(2), '1001'); + assertEquals(y.toRadixString(3), '100'); + assertEquals(y.toRadixString(16), '9'); + assertEquals((0).toRadixString(16), '0'); + try { + y.toRadixString(0); + Expect.fail("Illegal radix 0 accepted."); + } catch (e) {} + try { + y.toRadixString(-1); + Expect.fail("Illegal radix -1 accepted."); + } catch (e) {} + } + + static testStringOperators() { + var s = "abcdef"; + assertEquals(s, "abcdef"); + assertEquals(s.codeUnitAt(0), 97); + assertEquals(s[0], 'a'); + assertEquals(s.length, 6); + assertTypeError(() { + s[null]; + }); + assertTypeError(() { + s['hello']; + }); + assertTypeError(() { + s[0] = 'x'; + }); + } + + // TODO(jimhug): Fill out full set of string methods. + static testStringMethods() { + var s = "abcdef"; + assertEquals(s.isEmpty, false); + assertEquals(s.isNotEmpty, true); + assertEquals(s.startsWith("abc"), true); + assertEquals(s.endsWith("def"), true); + assertEquals(s.startsWith("aa"), false); + assertEquals(s.endsWith("ff"), false); + assertEquals(s.contains('cd', 0), true); + assertEquals(s.contains('cd', 2), true); + assertEquals(s.contains('cd', 3), false); + assertEquals(s.indexOf('cd', 2), 2); + assertEquals(s.indexOf('cd', 3), -1); + + assertTypeError(() { + s.startsWith(1); + }); + assertTypeError(() { + s.endsWith(1); + }); + } + + static testListOperators() { + var a = [1, 2, 3, 4]; + assertEquals(a[0], 1); + assertTypeError(() { + a['0']; + }); + a[0] = 42; + assertEquals(a[0], 42); + assertTypeError(() { + a['0'] = 99; + }); + assertEquals(a.length, 4); + } + + // TODO(jimhug): Fill out full set of list methods. + static testListMethods() { + var a = [1, 2, 3, 4]; + assertEquals(a.isEmpty, false); + assertEquals(a.length, 4); + var exception = null; + a.clear(); + assertEquals(a.length, 0); + } + + static testMapOperators() { + var d = new Map(); + d['a'] = 1; + d['b'] = 2; + assertEquals(d['a'], 1); + assertEquals(d['b'], 2); + assertEquals(d['c'], null); + } + + static testMapMethods() { + var d = new Map(); + d['a'] = 1; + d['b'] = 2; + assertEquals(d.containsValue(2), true); + assertEquals(d.containsValue(3), false); + assertEquals(d.containsKey('a'), true); + assertEquals(d.containsKey('c'), false); + assertEquals(d.keys.length, 2); + assertEquals(d.values.length, 2); + + assertEquals(d.remove('c'), null); + assertEquals(d.remove('b'), 2); + assertEquals(d.keys.single, 'a'); + assertEquals(d.values.single, 1); + + d['c'] = 3; + d['f'] = 4; + assertEquals(d.keys.length, 3); + assertEquals(d.values.length, 3); + assertListContains(d.keys.toList(), ['a', 'c', 'f']); + assertListContains(d.values.toList(), [1, 3, 4]); + + var count = 0; + d.forEach((key, value) { + count++; + assertEquals(value, d[key]); + }); + assertEquals(count, 3); + + d = {'a': 1, 'b': 2}; + assertEquals(d.containsValue(2), true); + assertEquals(d.containsValue(3), false); + assertEquals(d.containsKey('a'), true); + assertEquals(d.containsKey('c'), false); + assertEquals(d.keys.length, 2); + assertEquals(d.values.length, 2); + + d['g'] = null; + assertEquals(d.containsKey('g'), true); + assertEquals(d['g'], null); + } + + static testDateMethods() { + var msec = 115201000; + var d = new DateTime.fromMillisecondsSinceEpoch(msec, isUtc: true); + assertEquals(d.second, 1); + assertEquals(d.year, 1970); + + d = new DateTime.now(); + assertEquals(d.year >= 1970, true); + } + + static testLiterals() { + true.toString(); + 1.0.toString(); + .5.toString(); + 1.toString(); + if (false) { + // Depends on http://b/4198808. + null.toString(); + } + '${null}'.toString(); + '${true}'.toString(); + '${false}'.toString(); + ''.toString(); + ''.endsWith(''); + } +} + +main() { + CoreRuntimeTypesTest.testMain(); +} diff --git a/tests/corelib/corelib.status b/tests/corelib/corelib.status new file mode 100644 index 00000000000..99a6c0d3eb3 --- /dev/null +++ b/tests/corelib/corelib.status @@ -0,0 +1,787 @@ +# Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +# for details. All rights reserved. Use of this source code is governed by a +# BSD-style license that can be found in the LICENSE file. + +[ $strong ] +*: SkipByDesign # tests/corelib_strong has the strong mode versions of these tests. + +[ $compiler == none || $compiler == precompiler || $compiler == app_jit ] +compare_to2_test: Fail # Bug 4018 +symbol_test/01: Fail, Pass # bug 11669 +unicode_test: Fail # Bug 6706 + +# With the exception of 'void', new Symbol() should not accept reserved words. +symbol_reserved_word_test/05: CompileTimeError # bug 20191 +symbol_reserved_word_test/06: RuntimeError # bug 11669 +symbol_reserved_word_test/09: RuntimeError # bug 11669 +symbol_reserved_word_test/12: RuntimeError # bug 11669 + +symbol_test/none: Fail # bug 11669 +symbol_operator_test/03: Fail # bug 11669 +string_case_test/01: Fail # Bug 18061 + +[ $compiler == none && ($runtime == vm || $runtime == flutter)] +string_trimlr_test/02: RuntimeError # Issue 29060 + +[ $compiler == precompiler || $compiler == app_jit ] +string_trimlr_test/02: RuntimeError # Issue 29060 + +# #void should be a valid symbol. +[ $compiler == none || $compiler == precompiler || $compiler == app_jit || $compiler == dart2js ] +symbol_reserved_word_test/02: CompileTimeError # bug 20191 + +# With the exception of 'void', const Symbol() should not accept reserved +# words. +symbol_reserved_word_test/04: MissingCompileTimeError # bug 11669, 19972 +symbol_reserved_word_test/07: MissingCompileTimeError # bug 11669, 19972 +symbol_reserved_word_test/10: MissingCompileTimeError # bug 11669, 19972 + +[ $compiler == dart2js && ! $dart2js_with_kernel ] +double_parse_test/01: Pass, Fail # JS implementations disagree on U+0085 being whitespace. +int_modulo_arith_test/bignum: RuntimeError # No bigints. +int_modulo_arith_test/modPow: RuntimeError # No bigints. +int_parse_radix_test/01: Pass, Fail # JS implementations disagree on U+0085 being whitespace. +int_parse_radix_test/02: Fail # No bigints. +integer_to_radix_string_test: RuntimeError # issue 22045 +list_unmodifiable_test: Pass, RuntimeError # Issue 28712 +symbol_reserved_word_test/03: RuntimeError # bug 19972, new Symbol('void') should be allowed. +symbol_reserved_word_test/05: Crash # bug 20191 + +[ $compiler == dart2js && $fast_startup ] +apply3_test: Fail # mirrors not supported + +[ ($compiler == none || $compiler == precompiler || $compiler == app_jit) && $runtime != drt ] +symbol_test/02: MissingCompileTimeError # bug 11669 +symbol_test/03: MissingCompileTimeError # bug 11669 + +[ $runtime == ff || $runtime == jsshell ] +# Firefox takes advantage of the ECMAScript number parsing cop-out clause +# (presumably added to allow Mozilla's existing behavior) +# and only looks at the first 20 significant digits. +# The Dart VM and the other ECMAScript implementations follow the correct +# IEEE-754 rounding algorithm. +double_parse_test/02: Fail, OK + +[ $runtime == safari || $runtime == safarimobilesim ] +string_trimlr_test/02: RuntimeError # Uses Unicode 6.2.0 or earlier. + +[ $runtime == ff ] +double_round3_test: Pass, Fail, OK # Fails on ff 34, passes on ff 35. Runtime rounds 0.49999999999999994 to 1. +double_round_to_double2_test: Pass, Fail, OK # Fails on ff 34, passes on ff 35. Runtime rounds 0.49999999999999994 to 1. + +[ $compiler == dart2js && $runtime == drt && $csp && $minified ] +core_runtime_types_test: Pass, Fail # Issue 27913 + +[ $compiler == dart2js && ! $dart2js_with_kernel ] +error_stack_trace1_test: RuntimeError # Issue 12399 +hash_set_test/01: RuntimeError # Issue 11551 +integer_to_string_test/01: RuntimeError # Issue 1533 +iterable_return_type_test/01: RuntimeError # Issue 20085 +iterable_return_type_test/02: RuntimeError # Dart2js does not support Uint64*. +iterable_to_list_test/01: RuntimeError # Issue 26501 + +big_integer_*: Skip # VM specific test. +bit_twiddling_bigint_test: RuntimeError # Requires bigint support. +compare_to2_test: RuntimeError, OK # Requires bigint support. +string_base_vm_test: RuntimeError, OK # VM specific test. +nan_infinity_test/01: Fail # Issue 11551 +regexp/pcre_test: Pass, Slow # Issue 21593 +regress_r21715_test: RuntimeError # Requires bigint support. + +[ $compiler == dart2js && $runtime == none ] +*: Fail, Pass # TODO(ahe): Triage these tests. + +[ $compiler == dart2js && $runtime == chromeOnAndroid ] +list_as_map_test: Pass, Slow # TODO(kasperl): Please triage. +string_trimlr_test/02: RuntimeError # Uses Unicode 6.2.0 or earlier. + +[ $compiler == dart2js && $runtime == drt ] +string_trimlr_test/02: RuntimeError # Uses Unicode 6.2.0 or earlier. + +[ $compiler == dart2js && $runtime == safarimobilesim ] +string_split_test: RuntimeError # Issue 21431 + +[ $compiler == dart2js && $runtime == safarimobilesim ] +list_test/01: Fail # Safari bug: Array(-2) seen as dead code. +string_trimlr_test/01: Fail +string_trimlr_test/02: RuntimeError # Uses Unicode 6.2.0 or earlier. + +[ $compiler == dart2js && ($runtime == ff || $runtime == jsshell) ] +string_case_test/01: Fail, OK # Bug in Firefox. + +# Analyzer's implementation of fromEnvironment assumes that undefined +# environment variables have an unspecified value (rather than being +# null) because it is expected that the user will supply a value when +# the code is run. This means that it produces slightly different +# error messages than the VM and Dart2js. +[ $compiler == dart2analyzer && $checked ] +from_environment_const_type_undefined_test/09: CompileTimeError +from_environment_const_type_undefined_test/11: CompileTimeError +from_environment_const_type_undefined_test/12: CompileTimeError +from_environment_const_type_undefined_test/13: CompileTimeError +from_environment_const_type_undefined_test/14: CompileTimeError +from_environment_const_type_undefined_test/16: CompileTimeError + +[ $compiler == dart2analyzer ] +int_parse_radix_bad_handler_test: fail +hash_set_type_check_test: StaticWarning, OK # Tests failing type tests. +error_stack_trace_test: StaticWarning, OK # Test generates errors on purpose. +iterable_element_at_test: StaticWarning, OK # Test generates errors on purpose. +num_clamp_test: StaticWarning, OK # Test generates errors on purpose. +string_test: StaticWarning, OK # Test generates error on purpose. +duration2_test: StaticWarning, OK # Test generates error on purpose. + +[ $compiler == dart2analyzer && $builder_tag == strong ] +*: Skip # Issue 28649 + +[ $system == windows && $arch == x64 ] +stopwatch_test: Skip # Flaky test due to expected performance behaviour. + +[ $runtime != d8 && $runtime != vm && $runtime != dart_precompiled ] +# The regexp tests are not verified to work on non d8/vm platforms yet. +regexp/*: Skip + +[ $runtime == d8 ] +uri_base_test: RuntimeError # d8 preamble uses custom URI scheme "org-dartlang-d8-preamble:". + +[ $runtime == vm || $runtime == dart_precompiled || $runtime == flutter] +regexp/global_test: Skip # Timeout. Issue 21709 and 21708 +regexp/pcre_test: Pass, Slow, Timeout # Issues 21593 and 22008 +regexp/capture-3: Pass, Slow, Timeout # Issues 21593 and 22008 + +[ $runtime != vm && $runtime != dart_precompiled && $compiler != dart2analyzer] +data_resource_test: RuntimeError # Issue 23825 (not implemented yet). +file_resource_test: Skip, OK # VM specific test, uses dart:io. +http_resource_test: Skip, OK # VM specific test, uses dart:io. + +[ $compiler == dart2js && ! $browser ] +package_resource_test: RuntimeError # Issue 26842 + +[ $mode == debug ] +regexp/pcre_test: Pass, Slow # Timeout. Issue 22008 + +[ ($runtime == vm || $runtime == dart_precompiled) && $arch == simarmv5te ] +int_parse_radix_test/*: Pass, Slow +big_integer_parsed_mul_div_vm_test: Pass, Slow + +[ $compiler == precompiler ] +apply3_test: SkipByDesign # Imports dart:mirrors +big_integer_huge_mul_vm_test: Pass, Timeout # --no_intrinsify +big_integer_parsed_mul_div_vm_test: Pass, Timeout # --no_intrinsify +int_parse_radix_test: Pass, Timeout # --no_intrinsify +regexp/stack-overflow_test: RuntimeError, OK # Smaller limit with irregex interpreter + +[ $compiler == precompiler || $compiler == app_jit ] +data_resource_test: Skip # Resolve URI not supported yet in product mode. +package_resource_test: Skip # Resolve URI not supported yet in product mode. +file_resource_test: Skip # Resolve URI not supported yet in product mode. +http_resource_test: Skip # Resolve URI not supported yet in product mode. + +[ $arch == simdbc || $arch == simdbc64 ] +regexp/stack-overflow_test: RuntimeError, OK # Smaller limit with irregex interpreter + +[ $hot_reload || $hot_reload_rollback ] +big_integer_parsed_mul_div_vm_test: Pass, Slow # Slow. +big_integer_huge_mul_vm_test: Pass, Slow # Slow + +[ $compiler == dart2js && $dart2js_with_kernel ] +error_stack_trace1_test: Pass # Issue 27394 +symbol_reserved_word_test/03: Pass # Issue 27394 +map_test: Crash # Issue 27394 +regexp/pcre_test: RuntimeError # Issue 27394 +symbol_operator_test/03: RuntimeError # Issue 27394 +symbol_reserved_word_test/06: RuntimeError # Issue 27394 +symbol_reserved_word_test/09: RuntimeError # Issue 27394 +symbol_reserved_word_test/12: RuntimeError # Issue 27394 +symbol_test/none: RuntimeError # Issue 27394 + +[ $compiler == dart2js && $dart2js_with_kernel_in_ssa && $host_checked && $dart2js_with_kernel ] +regress/4562_test/01: Crash # Issue 27394 + +[ ($compiler == dartk || $compiler == dartkp) && ($runtime == vm || $runtime == dart_precompiled) ] +bool_from_environment2_test/01: MissingCompileTimeError +bool_from_environment2_test/02: MissingCompileTimeError +bool_from_environment2_test/03: MissingCompileTimeError +bool_from_environment2_test/04: MissingCompileTimeError +bool_from_environment2_test/05: MissingCompileTimeError +compare_to2_test: RuntimeError +int_from_environment3_test/01: MissingCompileTimeError +int_from_environment3_test/02: MissingCompileTimeError +int_from_environment3_test/03: MissingCompileTimeError +int_from_environment3_test/04: MissingCompileTimeError +int_from_environment3_test/05: MissingCompileTimeError +string_case_test/01: RuntimeError +string_from_environment3_test/01: MissingCompileTimeError +string_from_environment3_test/02: MissingCompileTimeError +string_from_environment3_test/03: MissingCompileTimeError +string_from_environment3_test/04: MissingCompileTimeError +string_from_environment3_test/05: MissingCompileTimeError +string_trimlr_test/02: RuntimeError +symbol_operator_test/03: RuntimeError +symbol_reserved_word_test/04: MissingCompileTimeError +symbol_reserved_word_test/06: RuntimeError +symbol_reserved_word_test/07: MissingCompileTimeError +symbol_reserved_word_test/09: RuntimeError +symbol_reserved_word_test/10: MissingCompileTimeError +symbol_reserved_word_test/12: RuntimeError +symbol_test/01: MissingCompileTimeError +symbol_test/02: MissingCompileTimeError +symbol_test/03: MissingCompileTimeError +symbol_test/none: RuntimeError +unicode_test: Fail # Bug 6706 + +[ $compiler == dart2js && $dart2js_with_kernel && $host_checked ] +big_integer_parsed_div_rem_vm_test: RuntimeError +big_integer_parsed_mul_div_vm_test: RuntimeError +const_list_literal_test: Crash +const_list_remove_range_test: Crash +const_list_set_range_test: Crash +core_runtime_types_test: Crash +data_uri_test: Crash +date_time2_test: Crash +date_time3_test: Crash +date_time4_test: Crash +date_time7_test: Crash +date_time_parse_test: Crash +date_time_test: Crash +double_floor2_test: Crash +double_parse_test/01: Crash +double_parse_test/02: Crash +double_parse_test/03: Crash +double_parse_test/none: Crash +double_round2_test: Crash +double_truncate2_test: Crash +duration2_test: Crash +duration_big_num_test: Crash +duration_double_multiplication_test: Crash +duration_test: Crash +error_stack_trace1_test: Pass # Issue 27394 +error_stack_trace2_test: Crash +error_stack_trace_test: Crash +exception_implementation_test: Crash +expando_test: Crash +for_in_test: Crash +has_next_iterator_test: Crash +hash_map2_test: Crash +hash_set_test/01: Crash +hash_set_test/none: Crash +hash_set_type_check_test: Crash +hashcode_test: Crash +hidden_library2_test/01: Crash +hidden_library2_test/none: Crash +indexed_list_access_test: Crash +int_from_environment3_test/01: MissingCompileTimeError +int_from_environment3_test/02: MissingCompileTimeError +int_from_environment3_test/03: MissingCompileTimeError +int_from_environment3_test/04: MissingCompileTimeError +int_from_environment3_test/05: Crash +int_modulo_arith_test/bignum: Crash +int_modulo_arith_test/modPow: Crash +int_modulo_arith_test/none: Crash +int_parse_radix_bad_handler_test: Crash +int_parse_radix_test/01: Crash +int_parse_radix_test/02: Crash +int_parse_radix_test/none: Crash +integer_to_radix_string_test: Crash +integer_to_string_test/01: RuntimeError +is_operator_basic_types_test: Crash +iterable_contains2_test: Crash +iterable_contains_test: Crash +iterable_element_at_test: Crash +iterable_empty_test: Crash +iterable_expand_test: Crash +iterable_first_test: Crash +iterable_first_where_test: Crash +iterable_fold_test: Crash +iterable_generate_test/01: Crash +iterable_generate_test/none: Crash +iterable_join_test: Crash +iterable_last_test: Crash +iterable_last_where_test: Crash +iterable_length_test: Crash +iterable_mapping_test: Crash +iterable_reduce_test: Crash +iterable_return_type_test/01: Crash +iterable_return_type_test/02: Crash +iterable_return_type_test/none: Crash +iterable_single_test: Crash +iterable_single_where_test: Crash +iterable_skip_test: Crash +iterable_skip_while_test: Crash +iterable_take_test: Crash +iterable_take_while_test: Crash +iterable_test: Crash +iterable_to_list_test/01: Crash +iterable_to_list_test/none: Crash +iterable_to_set_test: Crash +iterable_tostring_test: Crash +json_map_test: Crash +linked_hash_map_from_iterable_test: Crash +linked_hash_map_from_iterables_test: Crash +linked_hash_map_test: Crash +list_as_map_test: Crash +list_contains_argument_order_test: Crash +list_fill_range_test: Crash +list_first_test: Crash +list_fixed_test: Crash +list_for_each_test: Crash +list_get_range_test: Crash +list_growable_test: Crash +list_index_of2_test: RuntimeError +list_insert_all_test: Crash +list_insert_test: Crash +list_iterators_test: Crash +list_last_test: Crash +list_map_test: Crash +list_remove_range_test: Crash +list_removeat_test: Crash +list_replace_range_test: Crash +list_reversed_test: Crash +list_set_all_test: Crash +list_set_range_test: Crash +list_sort_test: RuntimeError +list_sublist_test: Crash +list_test/01: Crash +list_test/none: Crash +list_to_string2_test: Crash +list_to_string_test: Crash +list_unmodifiable_test: Crash +main_test: Crash +map_contains_value_test: Crash +map_from_iterable_test: Crash +map_from_iterables_test: Crash +map_from_test: Crash +map_keys2_test: Crash +map_keys_test: Crash +map_test: Crash +map_to_string_test: Crash +map_values2_test: Crash +map_values3_test: Crash +map_values4_test: Crash +map_values_test: Crash +maps_test: Crash +nan_infinity_test/01: RuntimeError +null_nosuchmethod_test: Crash +null_test: Crash +num_clamp_test: Crash +num_parse_test/01: Crash +num_parse_test/none: Crash +queue_first_test: Crash +queue_iterator_test: Crash +queue_last_test: Crash +queue_single_test: Crash +queue_test: Crash +range_error_test: Crash +reg_exp4_test: Crash +reg_exp5_test: Crash +reg_exp_all_matches_test: Crash +reg_exp_start_end_test: Crash +regexp/ascii-regexp-subject_test: Crash +regexp/bol-with-multiline_test: Crash +regexp/capture-3_test: Crash +regexp/capture_test: Crash +regexp/compile-crash_test: Crash +regexp/compile_test: Crash +regexp/early-acid3-86_test: Crash +regexp/ecma-regex-examples_test: Crash +regexp/extended-characters-more_test: Crash +regexp/global_test: Crash +regexp/indexof_test: Crash +regexp/invalid-range-in-class_test: Crash +regexp/issue_19193_test: Crash +regexp/lastindex_test: Crash +regexp/lookahead_test: Crash +regexp/multiline_test: Crash +regexp/negative-special-characters_test: Crash +regexp/no-extensions_test: Crash +regexp/non-capturing-groups_test: Crash +regexp/parentheses_test: Crash +regexp/pcre-test-4_test: Crash +regexp/pcre_test: Crash +regexp/range-out-of-order_test: Crash +regexp/regexp_kde_test: Crash +regexp/regexp_test: Crash +regexp/regress-regexp-codeflush_test: Crash +regexp/standalones_test: Crash +regexp/toString_test: Crash +regexp/unicode-handling_test: Crash +regexp/unicodeCaseInsensitive_test: Crash +regress_11099_test: Crash +regress_r21715_test: RuntimeError +safe_to_string_test: Crash +set_containsAll_test: Crash +set_contains_test: Crash +set_intersection_test: Crash +set_iterator_test: Crash +set_removeAll_test: Crash +set_remove_test: Crash +set_retainAll_test: Crash +set_test: Crash +set_to_string_test: Crash +shuffle_test: Crash +sort_test: Crash +sort_test: RuntimeError +splay_tree_from_iterable_test: Crash +splay_tree_from_iterables_test: Crash +splay_tree_test: Crash +stacktrace_current_test: Crash +stacktrace_fromstring_test: Crash +stopwatch2_test: Crash +string_base_vm_test: Crash +string_buffer_test: Crash +string_codeunits_test: Crash +string_from_environment3_test/01: MissingCompileTimeError +string_from_environment3_test/02: MissingCompileTimeError +string_from_environment3_test/03: MissingCompileTimeError +string_from_environment3_test/04: MissingCompileTimeError +string_from_environment3_test/05: Crash +string_from_list_test: Crash +string_fromcharcode_test: Crash +string_fromcharcodes_test: Crash +string_operations_with_null_test: Crash +string_pattern_test: Crash +string_replace_all_test: Crash +string_replace_dollar_test: Crash +string_replace_test: Crash +string_runes_test: Crash +string_source_test: Crash +string_split_test: Crash +string_substring_test: Crash +string_test: Crash +string_to_lower_case_test: Crash +string_trimlr_test/01: Crash +string_trimlr_test/02: Crash +string_trimlr_test/none: Crash +symbol_operator_test/03: Crash +symbol_operator_test/none: Crash +symbol_reserved_word_test/04: MissingCompileTimeError +symbol_reserved_word_test/05: Crash +symbol_reserved_word_test/06: Crash +symbol_reserved_word_test/07: MissingCompileTimeError +symbol_reserved_word_test/09: Crash +symbol_reserved_word_test/10: MissingCompileTimeError +symbol_reserved_word_test/12: Crash +symbol_test/01: Crash +symbol_test/02: Crash +symbol_test/03: Crash +symbol_test/none: Crash + +[ $compiler == dart2js && $dart2js_with_kernel && $host_checked ] +hash_map_test: Crash +list_sort_test: Crash +map_contains_key_test: Crash +map_index_test: Crash +map_remove_test: Crash +regress_11099_test: Crash +safe_to_string_test: Crash +sort_test: Crash + +[ $compiler == dart2js && $dart2js_with_kernel && $minified ] +big_integer_parsed_div_rem_vm_test: RuntimeError +big_integer_parsed_mul_div_vm_test: RuntimeError +const_list_literal_test: Crash +const_list_remove_range_test: Crash +const_list_set_range_test: Crash +core_runtime_types_test: Crash +data_uri_test: Crash +date_time2_test: Crash +date_time3_test: Crash +date_time4_test: Crash +date_time7_test: Crash +date_time_parse_test: Crash +date_time_test: Crash +double_ceil2_test: Crash +double_floor2_test: Crash +double_parse_test/01: Crash +double_parse_test/02: Crash +double_parse_test/03: Crash +double_parse_test/none: Crash +double_round2_test: Crash +double_round3_test: Crash +double_round4_test: Crash +double_round_test: Crash +double_round_to_double2_test: Crash +double_round_to_double3_test: Crash +double_round_to_double_test: Crash +double_truncate2_test: Crash +double_truncate_test: Crash +double_truncate_to_double_test: Crash +duration2_test: Crash +duration_big_num_test: Crash +duration_double_multiplication_test: Crash +duration_test: Crash +error_stack_trace1_test: Crash +error_stack_trace1_test: Pass # Issue 27394 +error_stack_trace2_test: Crash +error_stack_trace_test: Crash +errors_test: Crash +exception_implementation_test: Crash +expando_test: Crash +expression_test: Crash +for_in_test: Crash +format_exception_test: Crash +from_environment_const_type_test/01: Crash +from_environment_const_type_test/02: Crash +from_environment_const_type_test/03: Crash +from_environment_const_type_test/04: Crash +from_environment_const_type_test/05: Crash +from_environment_const_type_test/06: Crash +from_environment_const_type_test/07: Crash +from_environment_const_type_test/08: Crash +from_environment_const_type_test/09: Crash +from_environment_const_type_test/10: Crash +from_environment_const_type_test/11: Crash +from_environment_const_type_test/12: Crash +from_environment_const_type_test/13: Crash +from_environment_const_type_test/14: Crash +from_environment_const_type_test/15: Crash +from_environment_const_type_test/16: Crash +from_environment_const_type_test/none: Crash +from_environment_const_type_undefined_test/01: Crash +from_environment_const_type_undefined_test/02: Crash +from_environment_const_type_undefined_test/03: Crash +from_environment_const_type_undefined_test/04: Crash +from_environment_const_type_undefined_test/05: Crash +from_environment_const_type_undefined_test/06: Crash +from_environment_const_type_undefined_test/07: Crash +from_environment_const_type_undefined_test/08: Crash +from_environment_const_type_undefined_test/09: Crash +from_environment_const_type_undefined_test/10: Crash +from_environment_const_type_undefined_test/11: Crash +from_environment_const_type_undefined_test/12: Crash +from_environment_const_type_undefined_test/13: Crash +from_environment_const_type_undefined_test/14: Crash +from_environment_const_type_undefined_test/15: Crash +from_environment_const_type_undefined_test/16: Crash +from_environment_const_type_undefined_test/none: Crash +growable_list_test: Crash +has_next_iterator_test: Crash +hash_map2_test: Crash +int_parse_radix_bad_handler_test: Crash +int_parse_radix_test/01: Crash +int_parse_radix_test/02: Crash +int_parse_radix_test/none: Crash +hash_map_test: Crash +hashcode_boxed_test: Crash +int_ceil_test: Crash +int_ceil_to_double_test: Crash +int_floor_test: Crash +int_floor_to_double_test: Crash +int_from_environment2_test: Crash +int_from_environment_test: Crash +int_round_test: Crash +int_round_to_double_test: Crash +int_to_int_test: Crash +int_truncate_test: Crash +int_truncate_to_double_test: Crash +integer_to_radix_string_test: Crash +integer_to_string_test/01: RuntimeError +is_operator_basic_types_test: Crash +iterable_contains2_test: Crash +iterable_contains_test: Crash +iterable_element_at_test: Crash +iterable_empty_test: Crash +iterable_expand_test: Crash +iterable_first_test: Crash +iterable_first_where_test: Crash +iterable_fold_test: Crash +iterable_generate_test/01: Crash +iterable_generate_test/none: Crash +iterable_join_test: Crash +iterable_last_test: Crash +iterable_last_where_test: Crash +iterable_length_test: Crash +iterable_mapping_test: Crash +iterable_reduce_test: Crash +iterable_return_type_test/01: Crash +iterable_return_type_test/02: Crash +iterable_return_type_test/none: Crash +iterable_single_test: Crash +iterable_single_where_test: Crash +iterable_skip_test: Crash +iterable_skip_while_test: Crash +iterable_take_test: Crash +iterable_take_while_test: Crash +iterable_test: Crash +iterable_to_list_test/01: Crash +iterable_to_list_test/none: Crash +iterable_to_set_test: Crash +iterable_tostring_test: Crash +json_map_test: Crash +linked_hash_map_from_iterable_test: Crash +linked_hash_map_from_iterables_test: Crash +linked_hash_map_test: Crash +list_as_map_test: Crash +list_contains_argument_order_test: Crash +list_fill_range_test: Crash +list_filled_type_argument_test: Crash +list_first_test: Crash +list_fixed_test: Crash +list_for_each_test: Crash +list_get_range_test: Crash +list_growable_test: Crash +list_index_of2_test: Crash +list_index_of_test: Crash +list_literal_is_growable_test: Crash +list_literal_test: Crash +list_sort_test: Crash +map_contains_key_test: Crash +map_index_test: Crash +map_remove_test: Crash +nan_infinity_test/01: Crash +nan_infinity_test/none: Crash +num_sign_test: Crash +print_test/01: Crash +print_test/none: Crash +reg_exp1_test: Crash +reg_exp_first_match_test: Crash +reg_exp_group_test: Crash +reg_exp_groups_test: Crash +reg_exp_has_match_test: Crash +reg_exp_pattern_test: Crash +reg_exp_string_match_test: Crash +regexp/UC16_test: Crash +regexp/alternative-length-miscalculation_test: Crash +regexp/alternatives_test: Crash +regexp/assertion_test: Crash +regexp/backreferences_test: Crash +regexp/bol-with-multiline_test: Crash +regexp/bol_test: Crash +regexp/captures_test: Crash +regexp/char-insensitive_test: Crash +regexp/character-match-out-of-order_test: Crash +regexp/constructor_test: Crash +regexp/default_arguments_test: Crash +regexp/dotstar_test: Crash +regexp/extended-characters-match_test: Crash +regexp/find-first-asserted_test: Crash +regexp/look-ahead_test: Crash +regexp/loop-capture_test: Crash +regexp/malformed-escapes_test: Crash +regexp/many-brackets_test: Crash +regexp/non-bmp_test: Crash +regexp/non-capturing-backtracking_test: Crash +regexp/non-character_test: Crash +regexp/non-greedy-parentheses_test: Crash +regexp/norepeat_test: Crash +regexp/overflow_test: Crash +regexp/parentheses_test: Crash +regexp/quantified-assertions_test: Crash +regexp/range-bound-ffff_test: Crash +regexp/ranges-and-escaped-hyphens_test: Crash +regexp/regress-6-9-regexp_test: Crash +regexp/regress-regexp-construct-result_test: Crash +regexp/repeat-match-waldemar_test: Crash +regexp/results-cache_test: Crash +regexp/stack-overflow2_test: Crash +regexp/stack-overflow_test: Crash +regexp/zero-length-alternatives_test: Crash +regress_11099_test: Crash +regress_r21715_test: RuntimeError +safe_to_string_test: Crash +set_containsAll_test: Crash +set_contains_test: Crash +set_intersection_test: Crash +set_iterator_test: Crash +set_removeAll_test: Crash +set_remove_test: Crash +set_retainAll_test: Crash +set_test: Crash +set_to_string_test: Crash +shuffle_test: Crash +sort_test: RuntimeError +splay_tree_from_iterable_test: Crash +splay_tree_from_iterables_test: Crash +splay_tree_test: Crash +stacktrace_current_test: Crash +stacktrace_fromstring_test: Crash +stopwatch2_test: Crash +string_base_vm_test: Crash +string_buffer_test: Crash +string_codeunits_test: Crash +string_from_environment3_test/01: MissingCompileTimeError +string_from_environment3_test/02: MissingCompileTimeError +string_from_environment3_test/03: MissingCompileTimeError +string_from_environment3_test/04: MissingCompileTimeError +string_from_environment3_test/05: Crash +string_from_list_test: Crash +string_fromcharcode_test: Crash +string_fromcharcodes_test: Crash +string_operations_with_null_test: Crash +string_pattern_test: Crash +string_replace_all_test: Crash +string_replace_dollar_test: Crash +string_replace_test: Crash +string_runes_test: Crash +string_source_test: Crash +string_split_test: Crash +string_substring_test: Crash +string_test: Crash +string_to_lower_case_test: Crash +string_trimlr_test/01: Crash +string_trimlr_test/02: Crash +string_trimlr_test/none: Crash +symbol_operator_test/03: Crash +symbol_operator_test/none: Crash +symbol_reserved_word_test/04: MissingCompileTimeError +symbol_reserved_word_test/05: Crash +symbol_reserved_word_test/06: Crash +symbol_reserved_word_test/07: MissingCompileTimeError +symbol_reserved_word_test/09: Crash +symbol_reserved_word_test/10: MissingCompileTimeError +symbol_reserved_word_test/12: Crash + +# dartk: checked mode failures +[ $checked && ($compiler == dartk || $compiler == dartkp) ] +symbol_test/01: Pass +symbol_test/02: Pass +from_environment_const_type_test/02: MissingCompileTimeError +from_environment_const_type_test/03: MissingCompileTimeError +from_environment_const_type_test/04: MissingCompileTimeError +from_environment_const_type_test/06: MissingCompileTimeError +from_environment_const_type_test/07: MissingCompileTimeError +from_environment_const_type_test/08: MissingCompileTimeError +from_environment_const_type_test/09: MissingCompileTimeError +from_environment_const_type_test/11: MissingCompileTimeError +from_environment_const_type_test/12: MissingCompileTimeError +from_environment_const_type_test/13: MissingCompileTimeError +from_environment_const_type_test/14: MissingCompileTimeError +from_environment_const_type_test/16: MissingCompileTimeError +from_environment_const_type_undefined_test/02: MissingCompileTimeError +from_environment_const_type_undefined_test/03: MissingCompileTimeError +from_environment_const_type_undefined_test/04: MissingCompileTimeError +from_environment_const_type_undefined_test/06: MissingCompileTimeError +from_environment_const_type_undefined_test/07: MissingCompileTimeError +from_environment_const_type_undefined_test/08: MissingCompileTimeError + +[ $runtime == flutter ] + +# No support for mirrors +apply3_test: CompileTimeError + +# Possible bugs +bool_from_environment_test: Fail # Flutter Issue 9111 +format_exception_test: RuntimeError # Flutter Issue 9111 +from_environment_const_type_test/01: Fail # Flutter Issue 9111 +from_environment_const_type_test/02: MissingCompileTimeError # Flutter Issue 9111 +from_environment_const_type_test/03: MissingCompileTimeError # Flutter Issue 9111 +from_environment_const_type_test/04: MissingCompileTimeError # Flutter Issue 9111 +from_environment_const_type_test/05: Fail # Flutter Issue 9111 +from_environment_const_type_test/06: MissingCompileTimeError # Flutter Issue 9111 +from_environment_const_type_test/07: MissingCompileTimeError # Flutter Issue 9111 +from_environment_const_type_test/08: MissingCompileTimeError # Flutter Issue 9111 +from_environment_const_type_test/09: MissingCompileTimeError # Flutter Issue 9111 +from_environment_const_type_test/10: Fail # Flutter Issue 9111 +from_environment_const_type_test/11: MissingCompileTimeError # Flutter Issue 9111 +from_environment_const_type_test/12: MissingCompileTimeError # Flutter Issue 9111 +from_environment_const_type_test/13: MissingCompileTimeError # Flutter Issue 9111 +from_environment_const_type_test/14: MissingCompileTimeError # Flutter Issue 9111 +from_environment_const_type_test/15: Fail # Flutter Issue 9111 +from_environment_const_type_test/16: MissingCompileTimeError # Flutter Issue 9111 +from_environment_const_type_test/none: Fail # Flutter Issue 9111 +int_from_environment2_test: Fail # Flutter Issue 9111 +int_from_environment_test: Fail # Flutter Issue 9111 +main_test: RuntimeError # Flutter Issue 9111 +string_from_environment2_test: Fail # Flutter Issue 9111 +string_from_environment_test: Fail # Flutter Issue 9111 +string_trimlr_test/02: RuntimeError # Flutter Issue 9111 diff --git a/tests/corelib/data_uri_test.dart b/tests/corelib/data_uri_test.dart new file mode 100644 index 00000000000..baa60fc47c9 --- /dev/null +++ b/tests/corelib/data_uri_test.dart @@ -0,0 +1,335 @@ +// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; +import "dart:convert"; +import "dart:typed_data"; + +main() { + testMediaType(); + + testRoundTrip(""); + testRoundTrip("a"); + testRoundTrip("ab"); + testRoundTrip("abc"); + testRoundTrip("abcd"); + testRoundTrip("Content with special%25 characters: # ? = % # ? = %"); + testRoundTrip("blåbærgrød", UTF8); + testRoundTrip("blåbærgrød", LATIN1); + + testUriEquals("data:,abc?d"); + testUriEquals("DATA:,ABC?D"); + testUriEquals("data:,a%20bc?d"); + testUriEquals("DATA:,A%20BC?D"); + testUriEquals("data:,abc?d%23e"); // # must and will be is escaped. + + // Test that UriData.uri normalizes path and query. + + testUtf8Encoding("\u1000\uffff"); + testBytes(); + testInvalidCharacters(); + testNormalization(); + testErrors(); +} + +void testMediaType() { + for (var mimeType in ["", "text/plain", "text/javascript"]) { + for (var charset in ["", ";charset=US-ASCII", ";charset=UTF-8"]) { + for (var base64 in ["", ";base64"]) { + bool isBase64 = base64.isNotEmpty; + var text = "data:$mimeType$charset$base64,"; + var uri = UriData.parse(text); + + String expectedCharset = + charset.isEmpty ? "US-ASCII" : charset.substring(9); + String expectedMimeType = mimeType.isEmpty ? "text/plain" : mimeType; + + Expect.equals(text, "$uri"); + Expect.equals(expectedMimeType, uri.mimeType); + Expect.equals(expectedCharset, uri.charset); + Expect.equals(isBase64, uri.isBase64); + } + } + } +} + +void testRoundTrip(String content, [Encoding encoding]) { + UriData dataUri = new UriData.fromString(content, encoding: encoding); + Expect.isFalse(dataUri.isBase64); + Uri uri = dataUri.uri; + expectUriEquals(new Uri.dataFromString(content, encoding: encoding), uri); + + if (encoding != null) { + UriData dataUriParams = + new UriData.fromString(content, parameters: {"charset": encoding.name}); + Expect.equals("$dataUri", "$dataUriParams"); + } + + Expect.equals(encoding ?? ASCII, Encoding.getByName(dataUri.charset)); + Expect.equals(content, dataUri.contentAsString(encoding: encoding)); + Expect.equals(content, dataUri.contentAsString()); + Expect.equals(content, (encoding ?? ASCII).decode(dataUri.contentAsBytes())); + + uri = dataUri.uri; + Expect.equals(uri.toString(), dataUri.toString()); + Expect.equals(dataUri.toString(), new UriData.fromUri(uri).toString()); + + dataUri = new UriData.fromBytes(content.codeUnits); + Expect.listEquals(content.codeUnits, dataUri.contentAsBytes()); + Expect.equals(content, dataUri.contentAsString(encoding: LATIN1)); + + uri = dataUri.uri; + Expect.equals(uri.toString(), dataUri.toString()); + Expect.equals(dataUri.toString(), new UriData.fromUri(uri).toString()); + // Check that the URI is properly normalized. + expectUriEquals(uri, Uri.parse("$uri")); +} + +void testUtf8Encoding(String content) { + UriData uri = new UriData.fromString(content, encoding: UTF8); + Expect.equals(content, uri.contentAsString(encoding: UTF8)); + Expect.listEquals(UTF8.encode(content), uri.contentAsBytes()); +} + +void testInvalidCharacters() { + // SPACE, CTL and tspecial, plus '%' and '#' (URI gen-delim) + // This contains all ASCII character that are not valid in attribute/value + // parts. + var invalid = + '\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x7f' + ' ()<>@,;:"/[]?=%#\x80\u{1000}\u{10000}'; + var invalidNoSlash = invalid.replaceAll('/', ''); + var dataUri = new UriData.fromString(invalid, + encoding: UTF8, + mimeType: "$invalidNoSlash/$invalidNoSlash", + parameters: {invalid: invalid}); + + Expect.equals(invalid, dataUri.contentAsString()); + Expect.equals("$invalidNoSlash/$invalidNoSlash", dataUri.mimeType); + Expect.equals(invalid, dataUri.parameters[invalid]); + + var uri = dataUri.uri; + Expect.equals("$uri", "$dataUri"); + expectUriEquals(uri, Uri.parse("$uri")); // Check that it's canonicalized. + Expect.equals("$dataUri", new UriData.fromUri(uri).toString()); +} + +void testBytes() { + void testList(List list) { + var dataUri = new UriData.fromBytes(list); + Expect.equals("application/octet-stream", dataUri.mimeType); + Expect.isTrue(dataUri.isBase64); + Expect.listEquals(list, dataUri.contentAsBytes()); + + dataUri = new UriData.fromBytes(list, percentEncoded: true); + Expect.equals("application/octet-stream", dataUri.mimeType); + Expect.isFalse(dataUri.isBase64); + Expect.listEquals(list, dataUri.contentAsBytes()); + + var string = new String.fromCharCodes(list); + + dataUri = new UriData.fromString(string, encoding: LATIN1); + Expect.equals("text/plain", dataUri.mimeType); + Expect.isFalse(dataUri.isBase64); + Expect.listEquals(list, dataUri.contentAsBytes()); + + dataUri = new UriData.fromString(string, encoding: LATIN1, base64: true); + Expect.equals("text/plain", dataUri.mimeType); + Expect.isTrue(dataUri.isBase64); + Expect.listEquals(list, dataUri.contentAsBytes()); + } + + void testLists(List list) { + testList(list); + for (int i = 0; i < 27; i++) { + testList(list.sublist(i, i + i)); // All lengths from 0 to 27. + } + } + + var bytes = new Uint8List(512); + for (int i = 0; i < bytes.length; i++) { + bytes[i] = i; + } + testLists(bytes); + testLists(new List.from(bytes)); + testLists(new List.unmodifiable(bytes)); +} + +void testNormalization() { + // Base-64 normalization. + + // Normalized URI-alphabet characters. + Expect.equals( + "data:;base64,AA/+", UriData.parse("data:;base64,AA_-").toString()); + // Normalized escapes. + Expect.equals( + "data:;base64,AB==", UriData.parse("data:;base64,A%42=%3D").toString()); + Expect.equals("data:;base64,/+/+", + UriData.parse("data:;base64,%5F%2D%2F%2B").toString()); + // Normalized padded data. + Expect.equals( + "data:;base64,AA==", UriData.parse("data:;base64,AA%3D%3D").toString()); + Expect.equals( + "data:;base64,AAA=", UriData.parse("data:;base64,AAA%3D").toString()); + // Normalized unpadded data. + Expect.equals( + "data:;base64,AA==", UriData.parse("data:;base64,AA").toString()); + Expect.equals( + "data:;base64,AAA=", UriData.parse("data:;base64,AAA").toString()); + + // "URI normalization" of non-base64 content. + var uri = UriData.parse("data:,\x20\xa0"); + Expect.equals("data:,%20%C2%A0", uri.toString()); + uri = UriData.parse("data:,x://x@y:[z]:42/p/./?q=x&y=z#?#\u1234\u{12345}"); + Expect.equals( + "data:,x://x@y:%5Bz%5D:42/p/./?q=x&y=z%23?%23%E1%88%B4%F0%92%8D%85", + uri.toString()); +} + +bool badArgument(e) => e is ArgumentError; +bool badFormat(e) => e is FormatException; + +void testErrors() { + // Invalid constructor parameters. + Expect.throws(() { + new UriData.fromBytes([], mimeType: "noslash"); + }, badArgument); + Expect.throws(() { + new UriData.fromBytes([257]); + }, badArgument); + Expect.throws(() { + new UriData.fromBytes([-1]); + }, badArgument); + Expect.throws(() { + new UriData.fromBytes([0x10000000]); + }, badArgument); + Expect.throws(() { + new UriData.fromString("", mimeType: "noslash"); + }, badArgument); + + Expect.throws(() { + new Uri.dataFromBytes([], mimeType: "noslash"); + }, badArgument); + Expect.throws(() { + new Uri.dataFromBytes([257]); + }, badArgument); + Expect.throws(() { + new Uri.dataFromBytes([-1]); + }, badArgument); + Expect.throws(() { + new Uri.dataFromBytes([0x10000000]); + }, badArgument); + Expect.throws(() { + new Uri.dataFromString("", mimeType: "noslash"); + }, badArgument); + + // Empty parameters allowed, not an error. + var uri = new UriData.fromString("", mimeType: "", parameters: {}); + Expect.equals("data:,", "$uri"); + // Empty parameter key or value is an error. + Expect.throws( + () => new UriData.fromString("", parameters: {"": "X"}), badArgument); + Expect.throws( + () => new UriData.fromString("", parameters: {"X": ""}), badArgument); + + // Not recognizing charset is an error. + uri = UriData.parse("data:;charset=arglebargle,X"); + Expect.throws(() { + uri.contentAsString(); + }); + // Doesn't throw if we specify the encoding. + Expect.equals("X", uri.contentAsString(encoding: ASCII)); + + // Parse format. + Expect.throws(() { + UriData.parse("notdata:,"); + }, badFormat); + Expect.throws(() { + UriData.parse("text/plain,noscheme"); + }, badFormat); + Expect.throws(() { + UriData.parse("data:noseparator"); + }, badFormat); + Expect.throws(() { + UriData.parse("data:noslash,text"); + }, badFormat); + Expect.throws(() { + UriData.parse("data:type/sub;noequals,text"); + }, badFormat); + Expect.throws(() { + UriData.parse("data:type/sub;knocomma="); + }, badFormat); + Expect.throws(() { + UriData.parse("data:type/sub;k=v;nocomma"); + }, badFormat); + Expect.throws(() { + UriData.parse("data:type/sub;k=nocomma"); + }, badFormat); + Expect.throws(() { + UriData.parse("data:type/sub;k=v;base64"); + }, badFormat); + + void formatError(String input) { + Expect.throws(() => UriData.parse("data:;base64,$input"), badFormat, input); + } + + // Invalid base64 format (detected when parsed). + for (var a = 0; a <= 4; a++) { + for (var p = 0; p <= 4; p++) { + // Base-64 encoding must have length divisible by four and no more + // than two padding characters at the end. + if (p < 3 && (a + p) % 4 == 0) continue; + if (p == 0 && a > 1) continue; + formatError("A" * a + "=" * p); + formatError("A" * a + "%3D" * p); + } + } + // Invalid base64 encoding: padding not at end. + formatError("AA=A"); + formatError("A=AA"); + formatError("=AAA"); + formatError("A==A"); + formatError("==AA"); + formatError("===A"); + formatError("AAA%3D="); + formatError("A%3D=="); + + // Invalid unpadded data. + formatError("A"); + formatError("AAAAA"); + + // Invalid characters. + formatError("AAA*"); + formatError("AAA\x00"); + formatError("AAA\\"); + formatError("AAA,"); + + // Invalid escapes. + formatError("AAA%25"); + formatError("AAA%7F"); + formatError("AAA%7F"); +} + +/// Checks that two [Uri]s are exactly the same. +expectUriEquals(Uri expect, Uri actual) { + Expect.equals(expect.scheme, actual.scheme, "scheme"); + Expect.equals(expect.hasAuthority, actual.hasAuthority, "hasAuthority"); + Expect.equals(expect.userInfo, actual.userInfo, "userInfo"); + Expect.equals(expect.host, actual.host, "host"); + Expect.equals(expect.hasPort, actual.hasPort, "hasPort"); + Expect.equals(expect.port, actual.port, "port"); + Expect.equals(expect.port, actual.port, "port"); + Expect.equals(expect.hasQuery, actual.hasQuery, "hasQuery"); + Expect.equals(expect.query, actual.query, "query"); + Expect.equals(expect.hasFragment, actual.hasFragment, "hasFragment"); + Expect.equals(expect.fragment, actual.fragment, "fragment"); +} + +void testUriEquals(String uriText) { + var data = UriData.parse(uriText); + var uri = Uri.parse(uriText); + Expect.equals(data.uri, uri); + Expect.equals(data.toString(), uri.data.toString()); + Expect.equals(data.toString(), uri.toString()); +} diff --git a/tests/corelib/date_time10_test.dart b/tests/corelib/date_time10_test.dart new file mode 100644 index 00000000000..3d7d34e0091 --- /dev/null +++ b/tests/corelib/date_time10_test.dart @@ -0,0 +1,54 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +// Make sure the years in the range of single digits are handled correctly with +// month roll-over. (This tests an edge condition when delegating to +// JavaScript's Date constructor.) + +void check(String expected, DateTime actual) { + Expect.equals(expected, actual.toString()); +} + +testUtc() { + check("0099-01-01 00:00:00.000Z", new DateTime.utc(99, 1)); + check("0100-01-01 00:00:00.000Z", new DateTime.utc(99, 1 + 12)); + check("0000-01-01 00:00:00.000Z", new DateTime.utc(0, 1)); + check("-0001-01-01 00:00:00.000Z", new DateTime.utc(0, 1 - 12)); + + check("0099-03-02 00:00:00.000Z", new DateTime.utc(99, 2, 30)); + check("0100-03-02 00:00:00.000Z", new DateTime.utc(99, 2 + 12, 30)); + + check("0004-03-01 00:00:00.000Z", new DateTime.utc(3, 2 + 12, 30)); + check("0004-03-01 00:00:00.000Z", new DateTime.utc(4, 2, 30)); + check("0004-03-01 00:00:00.000Z", new DateTime.utc(5, 2 - 12, 30)); + + check("0005-03-02 00:00:00.000Z", new DateTime.utc(4, 2 + 12, 30)); + check("0005-03-02 00:00:00.000Z", new DateTime.utc(5, 2, 30)); + check("0005-03-02 00:00:00.000Z", new DateTime.utc(6, 2 - 12, 30)); +} + +testLocal() { + check("0099-01-01 00:00:00.000", new DateTime(99, 1)); + check("0100-01-01 00:00:00.000", new DateTime(99, 1 + 12)); + check("0000-01-01 00:00:00.000", new DateTime(0, 1)); + check("-0001-01-01 00:00:00.000", new DateTime(0, 1 - 12)); + + check("0099-03-02 00:00:00.000", new DateTime(99, 2, 30)); + check("0100-03-02 00:00:00.000", new DateTime(99, 2 + 12, 30)); + + check("0004-03-01 00:00:00.000", new DateTime(3, 2 + 12, 30)); + check("0004-03-01 00:00:00.000", new DateTime(4, 2, 30)); + check("0004-03-01 00:00:00.000", new DateTime(5, 2 - 12, 30)); + + check("0005-03-02 00:00:00.000", new DateTime(4, 2 + 12, 30)); + check("0005-03-02 00:00:00.000", new DateTime(5, 2, 30)); + check("0005-03-02 00:00:00.000", new DateTime(6, 2 - 12, 30)); +} + +main() { + testUtc(); + testLocal(); +} diff --git a/tests/corelib/date_time2_test.dart b/tests/corelib/date_time2_test.dart new file mode 100644 index 00000000000..6a0bb87dae5 --- /dev/null +++ b/tests/corelib/date_time2_test.dart @@ -0,0 +1,16 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +// Dart test program for DateTime's hashCode. + +main() { + var d = DateTime.parse("2000-01-01T00:00:00Z"); + var d2 = DateTime.parse("2000-01-01T00:00:01Z"); + // There is no guarantee that the hashcode for these two dates is different, + // but in the worst case we will have to fix this test. + // The important test here is, that DateTime . + Expect.isFalse(d.hashCode == d2.hashCode); +} diff --git a/tests/corelib/date_time3_test.dart b/tests/corelib/date_time3_test.dart new file mode 100644 index 00000000000..557eedee15f --- /dev/null +++ b/tests/corelib/date_time3_test.dart @@ -0,0 +1,14 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +// At some point dart was emitting a bad padding 0 for Dates where the ms were +// ending with 10. + +main() { + String s = "2012-01-30 08:30:00.010"; + DateTime d = DateTime.parse(s); + Expect.equals(s, d.toString()); +} diff --git a/tests/corelib/date_time4_test.dart b/tests/corelib/date_time4_test.dart new file mode 100644 index 00000000000..4342019f8c6 --- /dev/null +++ b/tests/corelib/date_time4_test.dart @@ -0,0 +1,104 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +// Test fromString with 6 digits after the decimal point. + +bool get supportsMicroseconds => + new DateTime.fromMicrosecondsSinceEpoch(1).microsecondsSinceEpoch == 1; + +main() { + if (supportsMicroseconds) { + testMicrosecondPrecision(); + } else { + testMillisecondPrecision(); + } +} + +void testMillisecondPrecision() { + // We only support milliseconds. If the user supplies more data (the "51" + // here), we round. + DateTime dt1 = DateTime.parse("1999-01-02 23:59:59.999519"); + Expect.equals(1999, dt1.year); + Expect.equals(1, dt1.month); + Expect.equals(3, dt1.day); + Expect.equals(0, dt1.hour); + Expect.equals(0, dt1.minute); + Expect.equals(0, dt1.second); + Expect.equals(0, dt1.millisecond); + Expect.equals(false, dt1.isUtc); + dt1 = DateTime.parse("1999-01-02 23:58:59.999519Z"); + Expect.equals(1999, dt1.year); + Expect.equals(1, dt1.month); + Expect.equals(2, dt1.day); + Expect.equals(23, dt1.hour); + Expect.equals(59, dt1.minute); + Expect.equals(0, dt1.second); + Expect.equals(0, dt1.millisecond); + Expect.equals(true, dt1.isUtc); + dt1 = DateTime.parse("0009-09-09 09:09:09.009411Z"); + Expect.equals(9, dt1.year); + Expect.equals(9, dt1.month); + Expect.equals(9, dt1.day); + Expect.equals(9, dt1.hour); + Expect.equals(9, dt1.minute); + Expect.equals(9, dt1.second); + Expect.equals(9, dt1.millisecond); + Expect.equals(true, dt1.isUtc); + String svnDate = "2012-03-30T04:28:13.752341Z"; + dt1 = DateTime.parse(svnDate); + Expect.equals(2012, dt1.year); + Expect.equals(3, dt1.month); + Expect.equals(30, dt1.day); + Expect.equals(4, dt1.hour); + Expect.equals(28, dt1.minute); + Expect.equals(13, dt1.second); + Expect.equals(752, dt1.millisecond); + Expect.equals(true, dt1.isUtc); +} + +void testMicrosecondPrecision() { + DateTime dt1 = DateTime.parse("1999-01-02 23:59:59.999519"); + Expect.equals(1999, dt1.year); + Expect.equals(1, dt1.month); + Expect.equals(2, dt1.day); + Expect.equals(23, dt1.hour); + Expect.equals(59, dt1.minute); + Expect.equals(59, dt1.second); + Expect.equals(999, dt1.millisecond); + Expect.equals(519, dt1.microsecond); + Expect.equals(false, dt1.isUtc); + dt1 = DateTime.parse("1999-01-02 23:58:59.999519Z"); + Expect.equals(1999, dt1.year); + Expect.equals(1, dt1.month); + Expect.equals(2, dt1.day); + Expect.equals(23, dt1.hour); + Expect.equals(58, dt1.minute); + Expect.equals(59, dt1.second); + Expect.equals(999, dt1.millisecond); + Expect.equals(519, dt1.microsecond); + Expect.equals(true, dt1.isUtc); + dt1 = DateTime.parse("0009-09-09 09:09:09.009411Z"); + Expect.equals(9, dt1.year); + Expect.equals(9, dt1.month); + Expect.equals(9, dt1.day); + Expect.equals(9, dt1.hour); + Expect.equals(9, dt1.minute); + Expect.equals(9, dt1.second); + Expect.equals(9, dt1.millisecond); + Expect.equals(411, dt1.microsecond); + Expect.equals(true, dt1.isUtc); + String svnDate = "2012-03-30T04:28:13.752341Z"; + dt1 = DateTime.parse(svnDate); + Expect.equals(2012, dt1.year); + Expect.equals(3, dt1.month); + Expect.equals(30, dt1.day); + Expect.equals(4, dt1.hour); + Expect.equals(28, dt1.minute); + Expect.equals(13, dt1.second); + Expect.equals(752, dt1.millisecond); + Expect.equals(341, dt1.microsecond); + Expect.equals(true, dt1.isUtc); +} diff --git a/tests/corelib/date_time5_test.dart b/tests/corelib/date_time5_test.dart new file mode 100644 index 00000000000..abf893d51e1 --- /dev/null +++ b/tests/corelib/date_time5_test.dart @@ -0,0 +1,81 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +// Test DateTime constructor with optional arguments. + +main() { + var d = new DateTime(2012); + Expect.equals(2012, d.year); + Expect.equals(1, d.month); + Expect.equals(1, d.day); + Expect.equals(0, d.hour); + Expect.equals(0, d.minute); + Expect.equals(0, d.second); + Expect.equals(0, d.millisecond); + + d = new DateTime(2012, 1, 28); + Expect.equals(2012, d.year); + Expect.equals(1, d.month); + Expect.equals(28, d.day); + Expect.equals(0, d.hour); + Expect.equals(0, d.minute); + Expect.equals(0, d.second); + Expect.equals(0, d.millisecond); + + d = new DateTime(1970, 3); + Expect.equals(1970, d.year); + Expect.equals(3, d.month); + Expect.equals(1, d.day); + Expect.equals(0, d.hour); + Expect.equals(0, d.minute); + Expect.equals(0, d.second); + Expect.equals(0, d.millisecond); + + d = new DateTime(1970, 3, 1, 11); + Expect.equals(1970, d.year); + Expect.equals(3, d.month); + Expect.equals(1, d.day); + Expect.equals(11, d.hour); + Expect.equals(0, d.minute); + Expect.equals(0, d.second); + Expect.equals(0, d.millisecond); + + d = new DateTime(0, 12, 24, 0, 12); + Expect.equals(0, d.year); + Expect.equals(12, d.month); + Expect.equals(24, d.day); + Expect.equals(0, d.hour); + Expect.equals(12, d.minute); + Expect.equals(0, d.second); + Expect.equals(0, d.millisecond); + + d = new DateTime(-1, 2, 2, 3, 0, 0, 4); + Expect.equals(-1, d.year); + Expect.equals(2, d.month); + Expect.equals(2, d.day); + Expect.equals(3, d.hour); + Expect.equals(0, d.minute); + Expect.equals(0, d.second); + Expect.equals(4, d.millisecond); + + d = new DateTime(-1, 2, 2, 3, 0, 4); + Expect.equals(-1, d.year); + Expect.equals(2, d.month); + Expect.equals(2, d.day); + Expect.equals(3, d.hour); + Expect.equals(0, d.minute); + Expect.equals(4, d.second); + Expect.equals(0, d.millisecond); + + d = new DateTime(2012, 5, 15, 13, 21, 33, 12); + Expect.equals(2012, d.year); + Expect.equals(5, d.month); + Expect.equals(15, d.day); + Expect.equals(13, d.hour); + Expect.equals(21, d.minute); + Expect.equals(33, d.second); + Expect.equals(12, d.millisecond); +} diff --git a/tests/corelib/date_time6_test.dart b/tests/corelib/date_time6_test.dart new file mode 100644 index 00000000000..c065705bafc --- /dev/null +++ b/tests/corelib/date_time6_test.dart @@ -0,0 +1,31 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +// Test DateTime comparison operators. + +main() { + var d = new DateTime.fromMillisecondsSinceEpoch(0, isUtc: true); + var d2 = new DateTime.fromMillisecondsSinceEpoch(1, isUtc: true); + Expect.isTrue(d.isBefore(d2)); + Expect.isTrue(!d.isAfter(d2)); + Expect.isTrue(d2.isAfter(d)); + Expect.isTrue(!d2.isBefore(d)); + Expect.isFalse(d2.isBefore(d)); + Expect.isFalse(!d2.isAfter(d)); + Expect.isFalse(d.isAfter(d2)); + Expect.isFalse(!d.isBefore(d2)); + + d = new DateTime.fromMillisecondsSinceEpoch(-1, isUtc: true); + d2 = new DateTime.fromMillisecondsSinceEpoch(0, isUtc: true); + Expect.isTrue(d.isBefore(d2)); + Expect.isTrue(!d.isAfter(d2)); + Expect.isTrue(d2.isAfter(d)); + Expect.isTrue(!d2.isBefore(d)); + Expect.isFalse(d2.isBefore(d)); + Expect.isFalse(!d2.isAfter(d)); + Expect.isFalse(d.isAfter(d2)); + Expect.isFalse(!d.isBefore(d2)); +} diff --git a/tests/corelib/date_time7_test.dart b/tests/corelib/date_time7_test.dart new file mode 100644 index 00000000000..b14eb7da18e --- /dev/null +++ b/tests/corelib/date_time7_test.dart @@ -0,0 +1,50 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +// Test DateTime timeZoneName and timeZoneOffset getters. + +testUtc() { + var d = DateTime.parse("2012-03-04T03:25:38.123Z"); + Expect.equals("UTC", d.timeZoneName); + Expect.equals(0, d.timeZoneOffset.inSeconds); +} + +testLocal() { + checkOffset(String name, Duration offset) { + // Timezone abbreviations are not in bijection with their timezones. + // For example AST stands for "Arab Standard Time" (UTC+03), as well as + // "Arabian Standard Time" (UTC+04), or PST stands for Pacific Standard Time + // and Philippine Standard Time. + // + // Hardcode some common timezones. + if (name == "CET") { + Expect.equals(1, offset.inHours); + } else if (name == "CEST") { + Expect.equals(2, offset.inHours); + } else if (name == "GMT") { + Expect.equals(0, offset.inSeconds); + } else if (name == "EST") { + Expect.equals(-5, offset.inHours); + } else if (name == "EDT") { + Expect.equals(-4, offset.inHours); + } else if (name == "PDT") { + Expect.equals(-7, offset.inHours); + } + } + + var d = DateTime.parse("2012-01-02T13:45:23"); + String name = d.timeZoneName; + checkOffset(name, d.timeZoneOffset); + + d = DateTime.parse("2012-07-02T13:45:23"); + name = d.timeZoneName; + checkOffset(name, d.timeZoneOffset); +} + +main() { + testUtc(); + testLocal(); +} diff --git a/tests/corelib/date_time8_test.dart b/tests/corelib/date_time8_test.dart new file mode 100644 index 00000000000..85d573f56b8 --- /dev/null +++ b/tests/corelib/date_time8_test.dart @@ -0,0 +1,22 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +// Make sure the year 0 is correctly printed. + +testUtc() { + var d = new DateTime.utc(0, 1, 1); + Expect.equals("0000-01-01 00:00:00.000Z", d.toString()); +} + +testLocal() { + var d = new DateTime(0, 1, 1); + Expect.equals("0000-01-01 00:00:00.000", d.toString()); +} + +main() { + testUtc(); + testLocal(); +} diff --git a/tests/corelib/date_time9_test.dart b/tests/corelib/date_time9_test.dart new file mode 100644 index 00000000000..9475775e7f5 --- /dev/null +++ b/tests/corelib/date_time9_test.dart @@ -0,0 +1,42 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + var dt = new DateTime.now(); + Expect.isTrue(dt is Comparable); + + var dt2 = new DateTime.fromMillisecondsSinceEpoch(100); + var dt3 = new DateTime.fromMillisecondsSinceEpoch(200, isUtc: true); + var dt3b = new DateTime.fromMillisecondsSinceEpoch(200); + var dt4 = new DateTime.fromMillisecondsSinceEpoch(300); + var dt5 = new DateTime.fromMillisecondsSinceEpoch(400, isUtc: true); + var dt5b = new DateTime.fromMillisecondsSinceEpoch(400); + + Expect.isTrue(dt2.compareTo(dt2) == 0); + Expect.isTrue(dt3.compareTo(dt3) == 0); + Expect.isTrue(dt3b.compareTo(dt3b) == 0); + Expect.isTrue(dt4.compareTo(dt4) == 0); + Expect.isTrue(dt5.compareTo(dt5) == 0); + Expect.isTrue(dt5b.compareTo(dt5b) == 0); + + // Time zones don't have any effect. + Expect.isTrue(dt3.compareTo(dt3b) == 0); + Expect.isTrue(dt5.compareTo(dt5b) == 0); + + Expect.isTrue(dt2.compareTo(dt3) < 0); + Expect.isTrue(dt3.compareTo(dt4) < 0); + Expect.isTrue(dt4.compareTo(dt5) < 0); + + Expect.isTrue(dt2.compareTo(dt3b) < 0); + Expect.isTrue(dt4.compareTo(dt5b) < 0); + + Expect.isTrue(dt3.compareTo(dt2) > 0); + Expect.isTrue(dt4.compareTo(dt3) > 0); + Expect.isTrue(dt5.compareTo(dt4) > 0); + + Expect.isTrue(dt3b.compareTo(dt2) > 0); + Expect.isTrue(dt5b.compareTo(dt4) > 0); +} diff --git a/tests/corelib/date_time_parse_test.dart b/tests/corelib/date_time_parse_test.dart new file mode 100644 index 00000000000..74cc78fd65d --- /dev/null +++ b/tests/corelib/date_time_parse_test.dart @@ -0,0 +1,52 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +check(DateTime expected, String str) { + DateTime actual = DateTime.parse(str); + Expect.equals(expected, actual); // Only checks if they are at the same time. + Expect.equals(expected.isUtc, actual.isUtc); +} + +bool get supportsMicroseconds => + new DateTime.fromMicrosecondsSinceEpoch(1).microsecondsSinceEpoch == 1; + +main() { + check(new DateTime(2012, 02, 27, 13, 27), "2012-02-27 13:27:00"); + if (supportsMicroseconds) { + check(new DateTime.utc(2012, 02, 27, 13, 27, 0, 123, 456), + "2012-02-27 13:27:00.123456z"); + } else { + check(new DateTime.utc(2012, 02, 27, 13, 27, 0, 123, 456), + "2012-02-27 13:27:00.123z"); + } + check(new DateTime(2012, 02, 27, 13, 27), "20120227 13:27:00"); + check(new DateTime(2012, 02, 27, 13, 27), "20120227T132700"); + check(new DateTime(2012, 02, 27), "20120227"); + check(new DateTime(2012, 02, 27), "+20120227"); + check(new DateTime.utc(2012, 02, 27, 14), "2012-02-27T14Z"); + check(new DateTime.utc(-12345, 1, 1), "-123450101 00:00:00 Z"); + check(new DateTime.utc(2012, 02, 27, 14), "2012-02-27T14+00"); + check(new DateTime.utc(2012, 02, 27, 14), "2012-02-27T14+0000"); + check(new DateTime.utc(2012, 02, 27, 14), "2012-02-27T14+00:00"); + check(new DateTime.utc(2012, 02, 27, 14), "2012-02-27T14 +00:00"); + + check(new DateTime.utc(2015, 02, 14, 13, 0, 0, 0), "2015-02-15T00:00+11"); + check(new DateTime.utc(2015, 02, 14, 13, 0, 0, 0), "2015-02-15T00:00:00+11"); + check( + new DateTime.utc(2015, 02, 14, 13, 0, 0, 0), "2015-02-15T00:00:00+11:00"); + + if (supportsMicroseconds) { + check(new DateTime.utc(2015, 02, 15, 0, 0, 0, 500, 500), + "2015-02-15T00:00:00.500500Z"); + check(new DateTime.utc(2015, 02, 15, 0, 0, 0, 511, 500), + "2015-02-15T00:00:00.511500Z"); + } else { + check(new DateTime.utc(2015, 02, 15, 0, 0, 0, 501), + "2015-02-15T00:00:00.501Z"); + check(new DateTime.utc(2015, 02, 15, 0, 0, 0, 512), + "2015-02-15T00:00:00.512Z"); + } +} diff --git a/tests/corelib/date_time_test.dart b/tests/corelib/date_time_test.dart new file mode 100644 index 00000000000..8a1d73196ef --- /dev/null +++ b/tests/corelib/date_time_test.dart @@ -0,0 +1,1380 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +// Dart test program for DateTime. + +bool get supportsMicroseconds => + new DateTime.fromMicrosecondsSinceEpoch(1).microsecondsSinceEpoch == 1; + +// Identical to _MAX_MILLISECONDS_SINCE_EPOCH in date_time.dart +const int _MAX_MILLISECONDS = 8640000000000000; + +// Tests if the time moves eventually forward. +void testNow() { + var t1 = new DateTime.now(); + bool timeMovedForward = false; + const int N = 1000000; + outer: + while (true) { + for (int i = N; i > 0; i--) { + var t2 = new DateTime.now(); + if (t1.millisecondsSinceEpoch < t2.millisecondsSinceEpoch) { + break outer; + } + } + print("testNow: No Date.now() progress in $N loops. Time: $t1"); + } + Expect.isFalse(t1.isUtc); +} + +void testMillisecondsSinceEpoch() { + var dt1 = new DateTime.now(); + var millisecondsSinceEpoch = dt1.millisecondsSinceEpoch; + var dt2 = new DateTime.fromMillisecondsSinceEpoch(millisecondsSinceEpoch); + Expect.equals(millisecondsSinceEpoch, dt2.millisecondsSinceEpoch); +} + +void testMicrosecondsSinceEpoch() { + var dt1 = new DateTime.fromMillisecondsSinceEpoch(1); + var microsecondsSinceEpoch = dt1.microsecondsSinceEpoch; + var dt2 = new DateTime.fromMicrosecondsSinceEpoch(microsecondsSinceEpoch); + Expect.equals(microsecondsSinceEpoch, dt2.microsecondsSinceEpoch); + + dt1 = new DateTime.now(); + microsecondsSinceEpoch = dt1.microsecondsSinceEpoch; + dt2 = new DateTime.fromMicrosecondsSinceEpoch(microsecondsSinceEpoch); + Expect.equals(microsecondsSinceEpoch, dt2.microsecondsSinceEpoch); +} + +void testFarAwayDates() { + DateTime dt = + new DateTime.fromMillisecondsSinceEpoch(1000000000000001, isUtc: true); + Expect.equals(33658, dt.year); + Expect.equals(9, dt.month); + Expect.equals(27, dt.day); + Expect.equals(1, dt.hour); + Expect.equals(46, dt.minute); + Expect.equals(40, dt.second); + Expect.equals(1, dt.millisecond); + Expect.equals(0, dt.microsecond); + dt = new DateTime.fromMillisecondsSinceEpoch(-1000000000000001, isUtc: true); + Expect.equals(-29719, dt.year); + Expect.equals(4, dt.month); + Expect.equals(5, dt.day); + Expect.equals(22, dt.hour); + Expect.equals(13, dt.minute); + Expect.equals(19, dt.second); + Expect.equals(999, dt.millisecond); + Expect.equals(0, dt.microsecond); + // Same with local zone. + dt = new DateTime.fromMillisecondsSinceEpoch(1000000000000001); + Expect.equals(33658, dt.year); + Expect.equals(9, dt.month); + Expect.equals(true, dt.day == 27 || dt.day == 26); + // Not much we can test for local hour. + Expect.equals(true, dt.hour >= 0 && dt.hour < 24); + // Timezones can have offsets down to 15 minute. + Expect.equals(true, dt.minute % 15 == 46 % 15); + Expect.equals(40, dt.second); + Expect.equals(1, dt.millisecond); + Expect.equals(0, dt.microsecond); + dt = new DateTime.fromMillisecondsSinceEpoch(-1000000000000001); + Expect.equals(-29719, dt.year); + Expect.equals(4, dt.month); + Expect.equals(true, 5 == dt.day || 6 == dt.day); + // Not much we can test for local hour. + Expect.equals(true, dt.hour >= 0 && dt.hour < 24); + // Timezones can have offsets down to 15 minute. + Expect.equals(true, dt.minute % 15 == 13); + Expect.equals(19, dt.second); + Expect.equals(999, dt.millisecond); + Expect.equals(0, dt.microsecond); + + if (!supportsMicroseconds) return; + dt = + new DateTime.fromMicrosecondsSinceEpoch(1000000000000000001, isUtc: true); + Expect.equals(33658, dt.year); + Expect.equals(9, dt.month); + Expect.equals(27, dt.day); + Expect.equals(1, dt.hour); + Expect.equals(46, dt.minute); + Expect.equals(40, dt.second); + Expect.equals(0, dt.millisecond); + Expect.equals(1, dt.microsecond); + dt = new DateTime.fromMicrosecondsSinceEpoch(-1000000000000000001, + isUtc: true); + Expect.equals(-29719, dt.year); + Expect.equals(4, dt.month); + Expect.equals(5, dt.day); + Expect.equals(22, dt.hour); + Expect.equals(13, dt.minute); + Expect.equals(19, dt.second); + Expect.equals(999, dt.millisecond); + Expect.equals(999, dt.microsecond); + // Same with local zone. + dt = new DateTime.fromMicrosecondsSinceEpoch(1000000000000000001); + Expect.equals(33658, dt.year); + Expect.equals(9, dt.month); + Expect.equals(true, dt.day == 27 || dt.day == 26); + // Not much we can test for local hour. + Expect.equals(true, dt.hour >= 0 && dt.hour < 24); + // Timezones can have offsets down to 15 minute. + Expect.equals(true, dt.minute % 15 == 46 % 15); + Expect.equals(40, dt.second); + Expect.equals(0, dt.millisecond); + Expect.equals(1, dt.microsecond); + dt = new DateTime.fromMicrosecondsSinceEpoch(-1000000000000000001); + Expect.equals(-29719, dt.year); + Expect.equals(4, dt.month); + Expect.equals(true, 5 == dt.day || 6 == dt.day); + // Not much we can test for local hour. + Expect.equals(true, dt.hour >= 0 && dt.hour < 24); + // Timezones can have offsets down to 15 minute. + Expect.equals(true, dt.minute % 15 == 13); + Expect.equals(19, dt.second); + Expect.equals(999, dt.millisecond); + Expect.equals(999, dt.microsecond); +} + +void testEquivalentYears() { + // All hardcoded values come from V8. This means that the values are not + // necessarily correct (see limitations of DateTime object in + // EcmaScript 15.9.1 and in particular 15.9.1.8/9). + DateTime dt = + new DateTime.fromMillisecondsSinceEpoch(-31485600000, isUtc: true); + Expect.equals(1969, dt.year); + Expect.equals(1, dt.month); + Expect.equals(1, dt.day); + Expect.equals(14, dt.hour); + Expect.equals(0, dt.minute); + Expect.equals(0, dt.second); + Expect.equals(0, dt.millisecond); + Expect.equals(0, dt.microsecond); + dt = new DateTime.fromMillisecondsSinceEpoch(-63108000000, isUtc: true); + Expect.equals(1968, dt.year); + Expect.equals(1, dt.month); + Expect.equals(1, dt.day); + Expect.equals(14, dt.hour); + Expect.equals(0, dt.minute); + Expect.equals(0, dt.second); + Expect.equals(0, dt.millisecond); + Expect.equals(0, dt.microsecond); + dt = new DateTime.fromMillisecondsSinceEpoch(-94644000000, isUtc: true); + Expect.equals(1967, dt.year); + Expect.equals(1, dt.month); + Expect.equals(1, dt.day); + Expect.equals(14, dt.hour); + Expect.equals(0, dt.minute); + Expect.equals(0, dt.second); + Expect.equals(0, dt.millisecond); + Expect.equals(0, dt.microsecond); + dt = new DateTime.fromMillisecondsSinceEpoch(-126180000000, isUtc: true); + Expect.equals(1966, dt.year); + Expect.equals(1, dt.month); + Expect.equals(1, dt.day); + Expect.equals(14, dt.hour); + Expect.equals(0, dt.minute); + Expect.equals(0, dt.second); + Expect.equals(0, dt.millisecond); + Expect.equals(0, dt.microsecond); + dt = new DateTime.fromMillisecondsSinceEpoch(-157716000000, isUtc: true); + Expect.equals(1965, dt.year); + Expect.equals(1, dt.month); + Expect.equals(1, dt.day); + Expect.equals(14, dt.hour); + Expect.equals(0, dt.minute); + Expect.equals(0, dt.second); + Expect.equals(0, dt.millisecond); + Expect.equals(0, dt.microsecond); + dt = new DateTime.fromMillisecondsSinceEpoch(-2177402400000, isUtc: true); + Expect.equals(1901, dt.year); + Expect.equals(1, dt.month); + Expect.equals(1, dt.day); + Expect.equals(14, dt.hour); + Expect.equals(0, dt.minute); + Expect.equals(0, dt.second); + Expect.equals(0, dt.millisecond); + Expect.equals(0, dt.microsecond); + dt = new DateTime.fromMillisecondsSinceEpoch(-5333076000000, isUtc: true); + Expect.equals(1801, dt.year); + Expect.equals(1, dt.month); + Expect.equals(1, dt.day); + Expect.equals(14, dt.hour); + Expect.equals(0, dt.minute); + Expect.equals(0, dt.second); + Expect.equals(0, dt.millisecond); + Expect.equals(0, dt.microsecond); + dt = new DateTime.fromMillisecondsSinceEpoch(-8520285600000, isUtc: true); + Expect.equals(1700, dt.year); + Expect.equals(1, dt.month); + Expect.equals(1, dt.day); + Expect.equals(14, dt.hour); + Expect.equals(0, dt.minute); + Expect.equals(0, dt.second); + Expect.equals(0, dt.millisecond); + Expect.equals(0, dt.microsecond); + dt = new DateTime.fromMillisecondsSinceEpoch(-14831719200000, isUtc: true); + Expect.equals(1500, dt.year); + Expect.equals(1, dt.month); + Expect.equals(1, dt.day); + Expect.equals(14, dt.hour); + Expect.equals(0, dt.minute); + Expect.equals(0, dt.second); + Expect.equals(0, dt.millisecond); + Expect.equals(0, dt.microsecond); + dt = new DateTime.fromMillisecondsSinceEpoch(-59011408800000, isUtc: true); + Expect.equals(100, dt.year); + Expect.equals(1, dt.month); + Expect.equals(1, dt.day); + Expect.equals(14, dt.hour); + Expect.equals(0, dt.minute); + Expect.equals(0, dt.second); + Expect.equals(0, dt.millisecond); + Expect.equals(0, dt.microsecond); + dt = new DateTime.fromMillisecondsSinceEpoch(-62011408800000, isUtc: true); + Expect.equals(4, dt.year); + Expect.equals(12, dt.month); + Expect.equals(8, dt.day); + Expect.equals(8, dt.hour); + Expect.equals(40, dt.minute); + Expect.equals(0, dt.second); + Expect.equals(0, dt.millisecond); + Expect.equals(0, dt.microsecond); + dt = new DateTime.fromMillisecondsSinceEpoch(-64011408800000, isUtc: true); + Expect.equals(-59, dt.year); + Expect.equals(7, dt.month); + Expect.equals(24, dt.day); + Expect.equals(5, dt.hour); + Expect.equals(6, dt.minute); + Expect.equals(40, dt.second); + Expect.equals(0, dt.millisecond); + Expect.equals(0, dt.microsecond); + final int SECONDS_YEAR_2035 = 2051222400; + dt = new DateTime.fromMillisecondsSinceEpoch(SECONDS_YEAR_2035 * 1000 + 1, + isUtc: true); + Expect.equals(2035, dt.year); + Expect.equals(1, dt.month); + Expect.equals(1, dt.day); + Expect.equals(0, dt.hour); + Expect.equals(0, dt.minute); + Expect.equals(0, dt.second); + Expect.equals(1, dt.millisecond); + Expect.equals(0, dt.microsecond); + dt = new DateTime.fromMillisecondsSinceEpoch(SECONDS_YEAR_2035 * 1000 - 1, + isUtc: true); + Expect.equals(2034, dt.year); + Expect.equals(12, dt.month); + Expect.equals(31, dt.day); + Expect.equals(23, dt.hour); + Expect.equals(59, dt.minute); + Expect.equals(59, dt.second); + Expect.equals(999, dt.millisecond); + Expect.equals(0, dt.microsecond); + + dt = new DateTime.utc(2035, 1, 1, 0, 0, 0, 1); + Expect.equals(SECONDS_YEAR_2035 * 1000 + 1, dt.millisecondsSinceEpoch); + dt = new DateTime.utc(2034, 12, 31, 23, 59, 59, 999); + Expect.equals(SECONDS_YEAR_2035 * 1000 - 1, dt.millisecondsSinceEpoch); + dt = new DateTime.fromMillisecondsSinceEpoch(SECONDS_YEAR_2035 * 1000 + 1); + Expect.equals( + true, + (2035 == dt.year && 1 == dt.month && 1 == dt.day) || + (2034 == dt.year && 12 == dt.month && 31 == dt.day)); + Expect.equals(0, dt.second); + Expect.equals(1, dt.millisecond); + DateTime dt2 = new DateTime( + dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, dt.millisecond); + Expect.equals(dt.millisecondsSinceEpoch, dt2.millisecondsSinceEpoch); + dt = new DateTime.fromMillisecondsSinceEpoch(SECONDS_YEAR_2035 * 1000 - 1); + Expect.equals( + true, + (2035 == dt.year && 1 == dt.month && 1 == dt.day) || + (2034 == dt.year && 12 == dt.month && 31 == dt.day)); + Expect.equals(59, dt.second); + Expect.equals(999, dt.millisecond); + Expect.equals(0, dt.microsecond); + + dt2 = new DateTime( + dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, dt.millisecond); + Expect.equals(dt.millisecondsSinceEpoch, dt2.millisecondsSinceEpoch); + dt = new DateTime.fromMillisecondsSinceEpoch(2100000000 * 1000, isUtc: true); + Expect.equals(2036, dt.year); + Expect.equals(7, dt.month); + Expect.equals(18, dt.day); + Expect.equals(13, dt.hour); + Expect.equals(20, dt.minute); + Expect.equals(0, dt.second); + Expect.equals(0, dt.millisecond); + Expect.equals(0, dt.microsecond); + + // Internally this will use the maximum value for the native calls. + dt = new DateTime(2036, 7, 18, 13, 20); + Expect.equals(2036, dt.year); + Expect.equals(7, dt.month); + Expect.equals(18, dt.day); + Expect.equals(13, dt.hour); + Expect.equals(20, dt.minute); + Expect.equals(0, dt.second); + Expect.equals(0, dt.millisecond); + Expect.equals(0, dt.microsecond); + Expect.equals("2036-07-18 13:20:00.000", dt.toString()); + + if (!supportsMicroseconds) return; + + dt = new DateTime.utc(2035, 1, 1, 0, 0, 0, 0, 1); + Expect.equals(SECONDS_YEAR_2035 * 1000000 + 1, dt.microsecondsSinceEpoch); + dt = new DateTime.utc(2034, 12, 31, 23, 59, 59, 999, 999); + Expect.equals(SECONDS_YEAR_2035 * 1000000 - 1, dt.microsecondsSinceEpoch); + dt = new DateTime.fromMicrosecondsSinceEpoch(SECONDS_YEAR_2035 * 1000000 + 1); + Expect.equals( + true, + (2035 == dt.year && 1 == dt.month && 1 == dt.day) || + (2034 == dt.year && 12 == dt.month && 31 == dt.day)); + Expect.equals(0, dt.second); + Expect.equals(0, dt.millisecond); + Expect.equals(1, dt.microsecond); + dt2 = new DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, + dt.millisecond, dt.microsecond); + Expect.equals(dt.microsecondsSinceEpoch, dt2.microsecondsSinceEpoch); + dt = new DateTime.fromMicrosecondsSinceEpoch(SECONDS_YEAR_2035 * 1000000 - 1); + Expect.equals( + true, + (2035 == dt.year && 1 == dt.month && 1 == dt.day) || + (2034 == dt.year && 12 == dt.month && 31 == dt.day)); + Expect.equals(59, dt.second); + Expect.equals(999, dt.millisecond); + Expect.equals(999, dt.microsecond); + + dt2 = new DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second, + dt.millisecond, dt.microsecond); + Expect.equals(dt.millisecondsSinceEpoch, dt2.millisecondsSinceEpoch); + dt = new DateTime.fromMicrosecondsSinceEpoch(2100000000 * 1000000, + isUtc: true); + Expect.equals(2036, dt.year); + Expect.equals(7, dt.month); + Expect.equals(18, dt.day); + Expect.equals(13, dt.hour); + Expect.equals(20, dt.minute); + Expect.equals(0, dt.second); + Expect.equals(0, dt.millisecond); + Expect.equals(0, dt.microsecond); +} + +void testExtremes() { + var dt = + new DateTime.fromMillisecondsSinceEpoch(_MAX_MILLISECONDS, isUtc: true); + Expect.equals(275760, dt.year); + Expect.equals(9, dt.month); + Expect.equals(13, dt.day); + Expect.equals(0, dt.hour); + Expect.equals(0, dt.minute); + Expect.equals(0, dt.second); + Expect.equals(0, dt.millisecond); + Expect.equals(0, dt.microsecond); + dt = new DateTime.fromMillisecondsSinceEpoch(-_MAX_MILLISECONDS, isUtc: true); + Expect.equals(-271821, dt.year); + Expect.equals(4, dt.month); + Expect.equals(20, dt.day); + Expect.equals(0, dt.hour); + Expect.equals(0, dt.minute); + Expect.equals(0, dt.second); + Expect.equals(0, dt.millisecond); + Expect.equals(0, dt.microsecond); + // Make sure that we can build the extreme dates in local too. + dt = new DateTime.fromMillisecondsSinceEpoch(_MAX_MILLISECONDS); + dt = new DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute); + Expect.equals(_MAX_MILLISECONDS, dt.millisecondsSinceEpoch); + dt = new DateTime.fromMillisecondsSinceEpoch(-_MAX_MILLISECONDS); + dt = new DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute); + Expect.equals(-_MAX_MILLISECONDS, dt.millisecondsSinceEpoch); + Expect.throws(() => new DateTime.fromMillisecondsSinceEpoch( + _MAX_MILLISECONDS + 1, + isUtc: true)); + Expect.throws(() => new DateTime.fromMillisecondsSinceEpoch( + -_MAX_MILLISECONDS - 1, + isUtc: true)); + Expect.throws( + () => new DateTime.fromMillisecondsSinceEpoch(_MAX_MILLISECONDS + 1)); + Expect.throws( + () => new DateTime.fromMillisecondsSinceEpoch(-_MAX_MILLISECONDS - 1)); + dt = new DateTime.fromMillisecondsSinceEpoch(_MAX_MILLISECONDS); + Expect.throws( + () => new DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute, 0, 1)); + dt = new DateTime.fromMillisecondsSinceEpoch(_MAX_MILLISECONDS, isUtc: true); + Expect.throws(() => + new DateTime.utc(dt.year, dt.month, dt.day, dt.hour, dt.minute, 0, 1)); + dt = new DateTime.fromMillisecondsSinceEpoch(-_MAX_MILLISECONDS); + Expect.throws( + () => new DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute, 0, -1)); + dt = new DateTime.fromMillisecondsSinceEpoch(-_MAX_MILLISECONDS, isUtc: true); + Expect.throws(() => + new DateTime.utc(dt.year, dt.month, dt.day, dt.hour, dt.minute, 0, -1)); + + if (!supportsMicroseconds) return; + + dt = new DateTime.fromMicrosecondsSinceEpoch(_MAX_MILLISECONDS * 1000); + dt = new DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute); + Expect.equals(_MAX_MILLISECONDS * 1000, dt.microsecondsSinceEpoch); + dt = new DateTime.fromMicrosecondsSinceEpoch(-_MAX_MILLISECONDS * 1000); + dt = new DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute); + Expect.equals(-_MAX_MILLISECONDS * 1000, dt.microsecondsSinceEpoch); + Expect.throws(() => new DateTime.fromMicrosecondsSinceEpoch( + _MAX_MILLISECONDS * 1000 + 1, + isUtc: true)); + Expect.throws(() => new DateTime.fromMicrosecondsSinceEpoch( + -_MAX_MILLISECONDS * 1000 - 1, + isUtc: true)); + Expect.throws(() => + new DateTime.fromMicrosecondsSinceEpoch(_MAX_MILLISECONDS * 1000 + 1)); + Expect.throws(() => + new DateTime.fromMicrosecondsSinceEpoch(-_MAX_MILLISECONDS * 1000 - 1)); + dt = new DateTime.fromMillisecondsSinceEpoch(_MAX_MILLISECONDS); + Expect.throws(() => + new DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute, 0, 0, 1)); + dt = new DateTime.fromMillisecondsSinceEpoch(_MAX_MILLISECONDS, isUtc: true); + Expect.throws(() => + new DateTime.utc(dt.year, dt.month, dt.day, dt.hour, dt.minute, 0, 0, 1)); + dt = new DateTime.fromMillisecondsSinceEpoch(-_MAX_MILLISECONDS); + Expect.throws(() => + new DateTime(dt.year, dt.month, dt.day, dt.hour, dt.minute, 0, 0, -1)); + dt = new DateTime.fromMillisecondsSinceEpoch(-_MAX_MILLISECONDS, isUtc: true); + Expect.throws(() => new DateTime.utc( + dt.year, dt.month, dt.day, dt.hour, dt.minute, 0, 0, -1)); +} + +void testUTCGetters() { + var dt = new DateTime.fromMillisecondsSinceEpoch(1305140315000, isUtc: true); + Expect.equals(2011, dt.year); + Expect.equals(5, dt.month); + Expect.equals(11, dt.day); + Expect.equals(18, dt.hour); + Expect.equals(58, dt.minute); + Expect.equals(35, dt.second); + Expect.equals(0, dt.millisecond); + Expect.equals(0, dt.microsecond); + Expect.equals(true, dt.isUtc); + Expect.equals(1305140315000, dt.millisecondsSinceEpoch); + dt = new DateTime.fromMillisecondsSinceEpoch(-9999999, isUtc: true); + Expect.equals(1969, dt.year); + Expect.equals(12, dt.month); + Expect.equals(31, dt.day); + Expect.equals(21, dt.hour); + Expect.equals(13, dt.minute); + Expect.equals(20, dt.second); + Expect.equals(1, dt.millisecond); + Expect.equals(0, dt.microsecond); + + if (!supportsMicroseconds) return; + + dt = new DateTime.fromMicrosecondsSinceEpoch(-9999999999, isUtc: true); + Expect.equals(1969, dt.year); + Expect.equals(12, dt.month); + Expect.equals(31, dt.day); + Expect.equals(21, dt.hour); + Expect.equals(13, dt.minute); + Expect.equals(20, dt.second); + Expect.equals(0, dt.millisecond); + Expect.equals(1, dt.microsecond); +} + +void testLocalGetters() { + var dt1 = new DateTime.fromMillisecondsSinceEpoch(1305140315000); + var dt2 = new DateTime.utc(dt1.year, dt1.month, dt1.day, dt1.hour, dt1.minute, + dt1.second, dt1.millisecond, dt1.microsecond); + Duration zoneOffset = dt1.difference(dt2); + Expect.equals(true, zoneOffset.inDays == 0); + Expect.equals(true, zoneOffset.inHours.abs() <= 12); + Expect.equals(dt1.year, dt2.year); + Expect.equals(dt1.month, dt2.month); + Expect.equals(true, (dt1.day - dt2.day).abs() <= 1); + Expect.equals(true, dt1.hour < 24); + // There are timezones with 0.5 or 0.25 hour offsets. + Expect.equals( + true, + (dt1.minute == dt2.minute) || + ((dt1.minute - dt2.minute).abs() == 30) || + ((dt1.minute - dt2.minute).abs() == 15)); + Expect.equals(dt1.second, dt2.second); + Expect.equals(dt1.millisecond, dt2.millisecond); + Expect.equals(dt1.microsecond, dt2.microsecond); +} + +void testConstructors() { + var dt0 = new DateTime.utc(2011, 5, 11, 18, 58, 35, 0, 0); + var dt0b = new DateTime.utc(2011, 5, 11, 18, 58, 35, 0, 0).toLocal(); + Expect.equals(1305140315000, dt0.millisecondsSinceEpoch); + var dt1 = new DateTime.fromMillisecondsSinceEpoch(1305140315000); + Expect.equals(dt1.millisecondsSinceEpoch, dt0.millisecondsSinceEpoch); + Expect.equals(dt1.microsecondsSinceEpoch, dt0.microsecondsSinceEpoch); + Expect.equals(false, dt1 == dt0); + Expect.equals(true, dt1 == dt0b); + var dt3 = new DateTime(dt1.year, dt1.month, dt1.day, dt1.hour, dt1.minute, + dt1.second, dt1.millisecond, dt1.microsecond); + Expect.equals(dt1.millisecondsSinceEpoch, dt3.millisecondsSinceEpoch); + Expect.equals(dt1.microsecondsSinceEpoch, dt3.microsecondsSinceEpoch); + Expect.equals(false, dt3 == dt0); + Expect.equals(true, dt1 == dt3); + dt3 = new DateTime(dt1.year, dt1.month, dt1.day, dt1.hour, dt1.minute, + dt1.second, dt1.millisecond, dt1.microsecond); + Expect.equals(dt1.millisecondsSinceEpoch, dt3.millisecondsSinceEpoch); + Expect.equals(dt1.microsecondsSinceEpoch, dt3.microsecondsSinceEpoch); + Expect.equals(true, dt1 == dt3); + var dt2 = dt1.toLocal(); + dt3 = new DateTime(2011, 5, dt1.day, dt1.hour, dt1.minute, 35, 0, 0); + Expect.equals(dt2.millisecondsSinceEpoch, dt3.millisecondsSinceEpoch); + Expect.equals(dt2.microsecondsSinceEpoch, dt3.microsecondsSinceEpoch); + Expect.equals(true, dt2 == dt3); + dt1 = new DateTime.fromMillisecondsSinceEpoch(-9999999, isUtc: true); + dt3 = new DateTime.utc(dt1.year, dt1.month, dt1.day, dt1.hour, dt1.minute, + dt1.second, dt1.millisecond); + Expect.equals(dt1.millisecondsSinceEpoch, dt3.millisecondsSinceEpoch); + Expect.equals(dt1.microsecondsSinceEpoch, dt3.microsecondsSinceEpoch); + dt3 = new DateTime.utc(99, 1, 2, 10, 11, 12, 0); + Expect.equals(99, dt3.year); + Expect.equals(1, dt3.month); + Expect.equals(2, dt3.day); + Expect.equals(10, dt3.hour); + Expect.equals(11, dt3.minute); + Expect.equals(12, dt3.second); + Expect.equals(0, dt3.millisecond); + Expect.equals(0, dt3.microsecond); + Expect.equals(true, dt3.isUtc); + var dt4 = new DateTime(99, 1, 2); + Expect.equals(99, dt4.year); + Expect.equals(1, dt4.month); + Expect.equals(2, dt4.day); + Expect.equals(0, dt4.hour); + Expect.equals(0, dt4.minute); + Expect.equals(0, dt4.second); + Expect.equals(0, dt4.millisecond); + Expect.equals(0, dt4.microsecond); + Expect.isFalse(dt4.isUtc); + var dt5 = new DateTime.utc(99, 1, 2); + Expect.equals(99, dt5.year); + Expect.equals(1, dt5.month); + Expect.equals(2, dt5.day); + Expect.equals(0, dt5.hour); + Expect.equals(0, dt5.minute); + Expect.equals(0, dt5.second); + Expect.equals(0, dt5.millisecond); + Expect.equals(0, dt5.microsecond); + Expect.isTrue(dt5.isUtc); + var dt6 = new DateTime(2012, 2, 27, 13, 27, 0); + Expect.equals(2012, dt6.year); + Expect.equals(2, dt6.month); + Expect.equals(27, dt6.day); + Expect.equals(13, dt6.hour); + Expect.equals(27, dt6.minute); + Expect.equals(0, dt6.second); + Expect.equals(0, dt6.millisecond); + Expect.equals(0, dt6.microsecond); + Expect.isFalse(dt6.isUtc); + var dt7 = new DateTime.utc(2012, 2, 27, 13, 27, 0); + Expect.equals(2012, dt7.year); + Expect.equals(2, dt7.month); + Expect.equals(27, dt7.day); + Expect.equals(13, dt7.hour); + Expect.equals(27, dt7.minute); + Expect.equals(0, dt7.second); + Expect.equals(0, dt7.millisecond); + Expect.equals(0, dt7.microsecond); + Expect.isTrue(dt7.isUtc); +} + +void testChangeTimeZone() { + var dt1 = new DateTime.fromMillisecondsSinceEpoch(1305140315000); + var dt2 = dt1.toUtc(); + Expect.equals(dt1.millisecondsSinceEpoch, dt2.millisecondsSinceEpoch); + var dt3 = new DateTime.fromMillisecondsSinceEpoch(1305140315000, isUtc: true); + Expect.equals(dt1.millisecondsSinceEpoch, dt3.millisecondsSinceEpoch); + Expect.equals(dt2.year, dt3.year); + Expect.equals(dt2.month, dt3.month); + Expect.equals(dt2.day, dt3.day); + Expect.equals(dt2.hour, dt3.hour); + Expect.equals(dt2.minute, dt3.minute); + Expect.equals(dt2.second, dt3.second); + Expect.equals(dt2.millisecond, dt3.millisecond); + Expect.equals(dt2.microsecond, dt3.microsecond); + var dt4 = dt3.toLocal(); + Expect.equals(dt1.year, dt4.year); + Expect.equals(dt1.month, dt4.month); + Expect.equals(dt1.day, dt4.day); + Expect.equals(dt1.hour, dt4.hour); + Expect.equals(dt1.minute, dt4.minute); + Expect.equals(dt1.second, dt4.second); + Expect.equals(dt1.millisecond, dt4.millisecond); + Expect.equals(dt1.microsecond, dt4.microsecond); +} + +void testSubAdd() { + var dt1 = new DateTime.fromMillisecondsSinceEpoch(1305140315000, isUtc: true); + var dt2 = dt1.add( + new Duration(milliseconds: 3 * Duration.MILLISECONDS_PER_SECOND + 5)); + Expect.equals(dt1.year, dt2.year); + Expect.equals(dt1.month, dt2.month); + Expect.equals(dt1.day, dt2.day); + Expect.equals(dt1.hour, dt2.hour); + Expect.equals(dt1.minute, dt2.minute); + Expect.equals(dt1.second + 3, dt2.second); + Expect.equals(dt1.millisecond + 5, dt2.millisecond); + Expect.equals(dt1.microsecond, dt2.microsecond); + var dt3 = dt2.subtract( + new Duration(milliseconds: 3 * Duration.MILLISECONDS_PER_SECOND + 5)); + Expect.equals(true, dt1 == dt3); + Expect.equals(false, dt1 == dt2); + + if (!supportsMicroseconds) return; + + dt1 = new DateTime.fromMillisecondsSinceEpoch(1305140315000, isUtc: true); + dt2 = dt1.add( + new Duration(microseconds: 3 * Duration.MICROSECONDS_PER_SECOND + 5)); + Expect.equals(dt1.year, dt2.year); + Expect.equals(dt1.month, dt2.month); + Expect.equals(dt1.day, dt2.day); + Expect.equals(dt1.hour, dt2.hour); + Expect.equals(dt1.minute, dt2.minute); + Expect.equals(dt1.second + 3, dt2.second); + Expect.equals(dt1.millisecond, dt2.millisecond); + Expect.equals(dt1.microsecond + 5, dt2.microsecond); + dt3 = dt2.subtract( + new Duration(microseconds: 3 * Duration.MICROSECONDS_PER_SECOND + 5)); + Expect.equals(true, dt1 == dt3); + Expect.equals(false, dt1 == dt2); +} + +void testUnderflowAndOverflow() { + int microsecond = supportsMicroseconds ? 499 : 0; + final dtBase = new DateTime(2012, 6, 20, 12, 30, 30, 500, microsecond); + + // Millisecond + print(" >>> Millisecond+"); + var dt = new DateTime(dtBase.year, dtBase.month, dtBase.day, dtBase.hour, + dtBase.minute, dtBase.second, 1000, dtBase.microsecond); + Expect.equals(dtBase.year, dt.year); + Expect.equals(dtBase.month, dt.month); + Expect.equals(dtBase.day, dt.day); + Expect.equals(dtBase.hour, dt.hour); + Expect.equals(dtBase.minute, dt.minute); + Expect.equals(dtBase.second + 1, dt.second); + Expect.equals(0, dt.millisecond); + Expect.equals(dtBase.microsecond, dt.microsecond); + + print(" >>> Millisecond-"); + dt = new DateTime(dtBase.year, dtBase.month, dtBase.day, dtBase.hour, + dtBase.minute, dtBase.second, -1000, dtBase.microsecond); + Expect.equals(dtBase.year, dt.year); + Expect.equals(dtBase.month, dt.month); + Expect.equals(dtBase.day, dt.day); + Expect.equals(dtBase.hour, dt.hour); + Expect.equals(dtBase.minute, dt.minute); + Expect.equals(dtBase.second - 1, dt.second); + Expect.equals(0, dt.millisecond); + Expect.equals(dtBase.microsecond, dt.microsecond); + + // Second + print(" >>> Second+"); + dt = new DateTime(dtBase.year, dtBase.month, dtBase.day, dtBase.hour, + dtBase.minute, 60, dtBase.millisecond, dtBase.microsecond); + Expect.equals(dtBase.year, dt.year); + Expect.equals(dtBase.month, dt.month); + Expect.equals(dtBase.day, dt.day); + Expect.equals(dtBase.hour, dt.hour); + Expect.equals(dtBase.minute + 1, dt.minute); + Expect.equals(0, dt.second); + Expect.equals(dtBase.millisecond, dt.millisecond); + Expect.equals(dtBase.microsecond, dt.microsecond); + + print(" >>> Second-"); + dt = new DateTime(dtBase.year, dtBase.month, dtBase.day, dtBase.hour, + dtBase.minute, -60, dtBase.millisecond, dtBase.microsecond); + Expect.equals(dtBase.year, dt.year); + Expect.equals(dtBase.month, dt.month); + Expect.equals(dtBase.day, dt.day); + Expect.equals(dtBase.hour, dt.hour); + Expect.equals(dtBase.minute - 1, dt.minute); + Expect.equals(0, dt.second); + Expect.equals(dtBase.millisecond, dt.millisecond); + Expect.equals(dtBase.microsecond, dt.microsecond); + + // Minute + print(" >>> Minute+"); + dt = new DateTime(dtBase.year, dtBase.month, dtBase.day, dtBase.hour, 60, + dtBase.second, dtBase.millisecond, dtBase.microsecond); + Expect.equals(dtBase.year, dt.year); + Expect.equals(dtBase.month, dt.month); + Expect.equals(dtBase.day, dt.day); + Expect.equals(dtBase.hour + 1, dt.hour); + Expect.equals(0, dt.minute); + Expect.equals(dtBase.second, dt.second); + Expect.equals(dtBase.millisecond, dt.millisecond); + Expect.equals(dtBase.microsecond, dt.microsecond); + + print(" >>> Minute-"); + dt = new DateTime(dtBase.year, dtBase.month, dtBase.day, dtBase.hour, -60, + dtBase.second, dtBase.millisecond, dtBase.microsecond); + Expect.equals(dtBase.year, dt.year); + Expect.equals(dtBase.month, dt.month); + Expect.equals(dtBase.day, dt.day); + Expect.equals(dtBase.hour - 1, dt.hour); + Expect.equals(0, dt.minute); + Expect.equals(dtBase.second, dt.second); + Expect.equals(dtBase.millisecond, dt.millisecond); + Expect.equals(dtBase.microsecond, dt.microsecond); + + // Hour + print(" >>> Hour+"); + dt = new DateTime(dtBase.year, dtBase.month, dtBase.day, 24, dtBase.minute, + dtBase.second, dtBase.millisecond, dtBase.microsecond); + Expect.equals(dtBase.year, dt.year); + Expect.equals(dtBase.month, dt.month); + Expect.equals(dtBase.day + 1, dt.day); + Expect.equals(0, dt.hour); + Expect.equals(dtBase.minute, dt.minute); + Expect.equals(dtBase.second, dt.second); + Expect.equals(dtBase.millisecond, dt.millisecond); + Expect.equals(dtBase.microsecond, dt.microsecond); + + print(" >>> Hour-"); + dt = new DateTime(dtBase.year, dtBase.month, dtBase.day, -24, dtBase.minute, + dtBase.second, dtBase.millisecond, dtBase.microsecond); + Expect.equals(dtBase.year, dt.year); + Expect.equals(dtBase.month, dt.month); + Expect.equals(dtBase.day - 1, dt.day); + Expect.equals(0, dt.hour); + Expect.equals(dtBase.minute, dt.minute); + Expect.equals(dtBase.second, dt.second); + Expect.equals(dtBase.millisecond, dt.millisecond); + Expect.equals(dtBase.microsecond, dt.microsecond); + + // Day + print(" >>> Day+"); + dt = new DateTime(dtBase.year, dtBase.month, 31, dtBase.hour, dtBase.minute, + dtBase.second, dtBase.millisecond, dtBase.microsecond); + Expect.equals(dtBase.year, dt.year); + Expect.equals(dtBase.month + 1, dt.month); + Expect.equals(1, dt.day); + Expect.equals(dtBase.hour, dt.hour); + Expect.equals(dtBase.minute, dt.minute); + Expect.equals(dtBase.second, dt.second); + Expect.equals(dtBase.millisecond, dt.millisecond); + Expect.equals(dtBase.microsecond, dt.microsecond); + + print(" >>> Day-"); + dt = new DateTime(dtBase.year, dtBase.month, -30, dtBase.hour, dtBase.minute, + dtBase.second, dtBase.millisecond, dtBase.microsecond); + Expect.equals(dtBase.year, dt.year); + Expect.equals(dtBase.month - 1, dt.month); + Expect.equals(1, dt.day); + Expect.equals(dtBase.hour, dt.hour); + Expect.equals(dtBase.minute, dt.minute); + Expect.equals(dtBase.second, dt.second); + Expect.equals(dtBase.millisecond, dt.millisecond); + Expect.equals(dtBase.microsecond, dt.microsecond); + + // Month + print(" >>> Month+"); + dt = new DateTime(dtBase.year, 13, dtBase.day, dtBase.hour, dtBase.minute, + dtBase.second, dtBase.millisecond, dtBase.microsecond); + Expect.equals(dtBase.year + 1, dt.year); + Expect.equals(1, dt.month); + Expect.equals(dtBase.day, dt.day); + Expect.equals(dtBase.hour, dt.hour); + Expect.equals(dtBase.minute, dt.minute); + Expect.equals(dtBase.second, dt.second); + Expect.equals(dtBase.millisecond, dt.millisecond); + Expect.equals(dtBase.microsecond, dt.microsecond); + + print(" >>> Month-"); + dt = new DateTime(dtBase.year, -11, dtBase.day, dtBase.hour, dtBase.minute, + dtBase.second, dtBase.millisecond, dtBase.microsecond); + Expect.equals(dtBase.year - 1, dt.year); + Expect.equals(1, dt.month); + Expect.equals(dtBase.day, dt.day); + Expect.equals(dtBase.hour, dt.hour); + Expect.equals(dtBase.minute, dt.minute); + Expect.equals(dtBase.second, dt.second); + Expect.equals(dtBase.millisecond, dt.millisecond); + Expect.equals(dtBase.microsecond, dt.microsecond); + + // Flowing all the way up the chain. + print(" >>> Flow+"); + var dtBase1 = new DateTime(2012, 12, 31, 23, 59, 59, 999, 000); + var dtTick = new DateTime( + dtBase1.year, + dtBase1.month, + dtBase1.day, + dtBase1.hour, + dtBase1.minute, + dtBase1.second, + dtBase1.millisecond + 1, + dtBase1.microsecond); + Expect.equals(dtBase1.year + 1, dtTick.year); + Expect.equals(1, dtTick.month); + Expect.equals(1, dtTick.day); + Expect.equals(0, dtTick.hour); + Expect.equals(0, dtTick.minute); + Expect.equals(0, dtTick.second); + Expect.equals(0, dtTick.millisecond); + Expect.equals(0, dtTick.microsecond); + + print(" >>> Flow-"); + dtBase1 = new DateTime(2012, 1, 1, 0, 0, 0, 0); + dtTick = new DateTime( + dtBase1.year, + dtBase1.month, + dtBase1.day, + dtBase1.hour, + dtBase1.minute, + dtBase1.second, + dtBase1.millisecond - 1, + dtBase1.microsecond); + Expect.equals(dtBase1.year - 1, dtTick.year); + Expect.equals(12, dtTick.month); + Expect.equals(31, dtTick.day); + Expect.equals(23, dtTick.hour); + Expect.equals(59, dtTick.minute); + Expect.equals(59, dtTick.second); + Expect.equals(999, dtTick.millisecond); + Expect.equals(0, dtTick.microsecond); + + print(" >>> extra underflow"); + dtTick = new DateTime(dtBase1.year, dtBase1.month, dtBase1.day, -17520, + dtBase1.minute, dtBase1.second, dtBase1.millisecond, dtBase1.microsecond); + Expect.equals(dtBase1.year - 2, dtTick.year); + Expect.equals(dtBase1.month, dtTick.month); + Expect.equals(dtBase1.day, dtTick.day); + Expect.equals(dtBase1.hour, dtTick.hour); + Expect.equals(dtBase1.minute, dtTick.minute); + Expect.equals(dtBase1.second, dtTick.second); + Expect.equals(dtBase1.millisecond, dtTick.millisecond); + Expect.equals(dtBase1.microsecond, dtTick.microsecond); + + if (!supportsMicroseconds) return; + + // Microsecond + print(" >>> Microsecond+"); + dt = new DateTime(dtBase.year, dtBase.month, dtBase.day, dtBase.hour, + dtBase.minute, dtBase.second, dtBase.millisecond, 1000); + Expect.equals(dtBase.year, dt.year); + Expect.equals(dtBase.month, dt.month); + Expect.equals(dtBase.day, dt.day); + Expect.equals(dtBase.hour, dt.hour); + Expect.equals(dtBase.minute, dt.minute); + Expect.equals(dtBase.second, dt.second); + Expect.equals(dtBase.millisecond + 1, dt.millisecond); + Expect.equals(0, dt.microsecond); + + print(" >>> Microsecond-"); + dt = new DateTime(dtBase.year, dtBase.month, dtBase.day, dtBase.hour, + dtBase.minute, dtBase.second, dtBase.millisecond, -1000); + Expect.equals(dtBase.year, dt.year); + Expect.equals(dtBase.month, dt.month); + Expect.equals(dtBase.day, dt.day); + Expect.equals(dtBase.hour, dt.hour); + Expect.equals(dtBase.minute, dt.minute); + Expect.equals(dtBase.second, dt.second); + Expect.equals(dtBase.millisecond - 1, dt.millisecond); + Expect.equals(0, dt.microsecond); + + // Flowing all the way up the chain. + print(" >>> Flow+ 2"); + dtBase1 = new DateTime(2012, 12, 31, 23, 59, 59, 999, 999); + dtTick = new DateTime( + dtBase1.year, + dtBase1.month, + dtBase1.day, + dtBase1.hour, + dtBase1.minute, + dtBase1.second, + dtBase1.millisecond, + dtBase1.microsecond + 1); + Expect.equals(dtBase1.year + 1, dtTick.year); + Expect.equals(1, dtTick.month); + Expect.equals(1, dtTick.day); + Expect.equals(0, dtTick.hour); + Expect.equals(0, dtTick.minute); + Expect.equals(0, dtTick.second); + Expect.equals(0, dtTick.millisecond); + Expect.equals(0, dtTick.microsecond); + + print(" >>> Flow- 2"); + dtBase1 = new DateTime(2012, 1, 1, 0, 0, 0, 0, 0); + dtTick = new DateTime( + dtBase1.year, + dtBase1.month, + dtBase1.day, + dtBase1.hour, + dtBase1.minute, + dtBase1.second, + dtBase1.millisecond, + dtBase1.microsecond - 1); + Expect.equals(dtBase1.year - 1, dtTick.year); + Expect.equals(12, dtTick.month); + Expect.equals(31, dtTick.day); + Expect.equals(23, dtTick.hour); + Expect.equals(59, dtTick.minute); + Expect.equals(59, dtTick.second); + Expect.equals(999, dtTick.millisecond); + Expect.equals(999, dtTick.microsecond); +} + +void testDateStrings() { + // TODO(floitsch): Clean up the DateTime API that deals with strings. + var dt1 = DateTime.parse("2011-05-11 18:58:35Z"); + Expect.equals(1305140315000, dt1.millisecondsSinceEpoch); + Expect.isTrue(dt1.isUtc); + dt1 = DateTime.parse("20110511 18:58:35z"); + Expect.equals(1305140315000, dt1.millisecondsSinceEpoch); + Expect.isTrue(dt1.isUtc); + dt1 = DateTime.parse("+20110511 18:58:35z"); + Expect.equals(1305140315000, dt1.millisecondsSinceEpoch); + Expect.isTrue(dt1.isUtc); + var str = dt1.toString(); + var dt2 = DateTime.parse(str); + Expect.equals(true, dt1 == dt2); + var dt3 = dt1.toUtc(); + str = dt3.toString(); + Expect.equals("2011-05-11 18:58:35.000Z", str); + var dt4 = DateTime.parse("-1234-01-01 00:00:00Z"); + Expect.equals(-1234, dt4.year); + Expect.equals(1, dt4.month); + Expect.equals(1, dt4.day); + Expect.equals(0, dt4.hour); + Expect.equals(0, dt4.minute); + Expect.equals(0, dt4.second); + Expect.equals(0, dt4.millisecond); + Expect.equals(0, dt4.microsecond); + Expect.isTrue(dt4.isUtc); + var dt5 = DateTime.parse("0099-01-02"); + Expect.equals(99, dt5.year); + Expect.equals(1, dt5.month); + Expect.equals(2, dt5.day); + Expect.equals(0, dt5.hour); + Expect.equals(0, dt5.minute); + Expect.equals(0, dt5.second); + Expect.equals(0, dt5.millisecond); + Expect.equals(0, dt5.microsecond); + Expect.isFalse(dt5.isUtc); + var dt6 = DateTime.parse("2012-01-01 00:00:10.012"); + Expect.equals(12, dt6.millisecond); + Expect.equals(0, dt6.microsecond); + dt6 = DateTime.parse("2012-01-01 00:00:10.003"); + Expect.equals(3, dt6.millisecond); + Expect.equals(0, dt6.microsecond); + dt6 = DateTime.parse("2012-01-01 00:00:10.5"); + Expect.equals(500, dt6.millisecond); + Expect.equals(0, dt6.microsecond); + dt6 = DateTime.parse("2012-01-01 00:00:10.003Z"); + Expect.equals(3, dt6.millisecond); + Expect.equals(0, dt6.microsecond); + dt6 = DateTime.parse("2012-01-01 00:00:10.5z"); + Expect.equals(500, dt6.millisecond); + Expect.equals(0, dt6.microsecond); + var dt7 = DateTime.parse("2011-05-11T18:58:35Z"); + Expect.equals(1305140315000, dt7.millisecondsSinceEpoch); + var dt8 = DateTime.parse("-1234-01-01T00:00:00Z"); + Expect.equals(-1234, dt8.year); + Expect.equals(1, dt8.month); + Expect.equals(1, dt8.day); + Expect.equals(0, dt8.hour); + Expect.equals(0, dt8.minute); + Expect.equals(0, dt8.second); + Expect.equals(0, dt8.millisecond); + Expect.equals(0, dt8.microsecond); + Expect.isTrue(dt8.isUtc); + var dt9 = DateTime.parse("-1234-01-01T00:00:00"); + Expect.equals(-1234, dt9.year); + Expect.equals(1, dt9.month); + Expect.equals(1, dt9.day); + Expect.equals(0, dt9.hour); + Expect.equals(0, dt9.minute); + Expect.equals(0, dt9.second); + Expect.equals(0, dt9.millisecond); + Expect.equals(0, dt9.microsecond); + Expect.isFalse(dt9.isUtc); + var dt10 = DateTime.parse("-12340101"); + Expect.equals(-1234, dt10.year); + Expect.equals(1, dt10.month); + Expect.equals(1, dt10.day); + Expect.equals(0, dt10.hour); + Expect.equals(0, dt10.minute); + Expect.equals(0, dt10.second); + Expect.equals(0, dt10.millisecond); + Expect.equals(0, dt10.microsecond); + Expect.isFalse(dt10.isUtc); + dt1 = DateTime.parse("2012-02-27 13:27:00"); + Expect.equals(2012, dt1.year); + Expect.equals(2, dt1.month); + Expect.equals(27, dt1.day); + Expect.equals(13, dt1.hour); + Expect.equals(27, dt1.minute); + Expect.equals(0, dt1.second); + Expect.equals(0, dt1.millisecond); + Expect.equals(0, dt1.microsecond); + Expect.equals(false, dt1.isUtc); + dt1 = DateTime.parse("2012-02-27 13:27:00.423z"); + Expect.equals(2012, dt1.year); + Expect.equals(2, dt1.month); + Expect.equals(27, dt1.day); + Expect.equals(13, dt1.hour); + Expect.equals(27, dt1.minute); + Expect.equals(0, dt1.second); + Expect.equals(423, dt1.millisecond); + Expect.equals(0, dt1.microsecond); + Expect.equals(true, dt1.isUtc); + dt1 = DateTime.parse("20120227 13:27:00"); + Expect.equals(2012, dt1.year); + Expect.equals(2, dt1.month); + Expect.equals(27, dt1.day); + Expect.equals(13, dt1.hour); + Expect.equals(27, dt1.minute); + Expect.equals(0, dt1.second); + Expect.equals(0, dt1.millisecond); + Expect.equals(0, dt1.microsecond); + Expect.equals(false, dt1.isUtc); + dt1 = DateTime.parse("20120227T132700"); + Expect.equals(2012, dt1.year); + Expect.equals(2, dt1.month); + Expect.equals(27, dt1.day); + Expect.equals(13, dt1.hour); + Expect.equals(27, dt1.minute); + Expect.equals(0, dt1.second); + Expect.equals(0, dt1.millisecond); + Expect.equals(0, dt1.microsecond); + Expect.equals(false, dt1.isUtc); + dt1 = DateTime.parse("20120227"); + Expect.equals(2012, dt1.year); + Expect.equals(2, dt1.month); + Expect.equals(27, dt1.day); + Expect.equals(0, dt1.hour); + Expect.equals(0, dt1.minute); + Expect.equals(0, dt1.second); + Expect.equals(0, dt1.millisecond); + Expect.equals(0, dt1.microsecond); + Expect.equals(false, dt1.isUtc); + dt1 = DateTime.parse("2012-02-27T14Z"); + Expect.equals(2012, dt1.year); + Expect.equals(2, dt1.month); + Expect.equals(27, dt1.day); + Expect.equals(14, dt1.hour); + Expect.equals(0, dt1.minute); + Expect.equals(0, dt1.second); + Expect.equals(0, dt1.millisecond); + Expect.equals(0, dt1.microsecond); + Expect.equals(true, dt1.isUtc); + dt1 = DateTime.parse("-123450101 00:00:00 Z"); + Expect.equals(-12345, dt1.year); + Expect.equals(1, dt1.month); + Expect.equals(1, dt1.day); + Expect.equals(0, dt1.hour); + Expect.equals(0, dt1.minute); + Expect.equals(0, dt1.second); + Expect.equals(0, dt1.millisecond); + Expect.equals(0, dt1.microsecond); + Expect.equals(true, dt1.isUtc); + dt1 = DateTime.parse("1999-01-02 23:59:59.99951"); + if (supportsMicroseconds) { + Expect.equals(1999, dt1.year); + Expect.equals(1, dt1.month); + Expect.equals(2, dt1.day); + Expect.equals(23, dt1.hour); + Expect.equals(59, dt1.minute); + Expect.equals(59, dt1.second); + Expect.equals(999, dt1.millisecond); + Expect.equals(510, dt1.microsecond); + } else { + // We only support millisecond. If the user supplies more data (the "51" + // here), we round. + Expect.equals(1999, dt1.year); + Expect.equals(1, dt1.month); + Expect.equals(3, dt1.day); + Expect.equals(0, dt1.hour); + Expect.equals(0, dt1.minute); + Expect.equals(0, dt1.second); + Expect.equals(0, dt1.millisecond); + Expect.equals(0, dt1.microsecond); + } + Expect.equals(false, dt1.isUtc); + dt1 = DateTime.parse("1999-01-02 23:58:59.99951Z"); + if (supportsMicroseconds) { + Expect.equals(1999, dt1.year); + Expect.equals(1, dt1.month); + Expect.equals(2, dt1.day); + Expect.equals(23, dt1.hour); + Expect.equals(58, dt1.minute); + Expect.equals(59, dt1.second); + Expect.equals(999, dt1.millisecond); + Expect.equals(510, dt1.microsecond); + } else { + Expect.equals(1999, dt1.year); + Expect.equals(1, dt1.month); + Expect.equals(2, dt1.day); + Expect.equals(23, dt1.hour); + Expect.equals(59, dt1.minute); + Expect.equals(0, dt1.second); + Expect.equals(0, dt1.millisecond); + Expect.equals(0, dt1.microsecond); + } + Expect.equals(true, dt1.isUtc); + dt1 = DateTime.parse("0009-09-09 09:09:09.009Z"); + Expect.equals(9, dt1.year); + Expect.equals(9, dt1.month); + Expect.equals(9, dt1.day); + Expect.equals(9, dt1.hour); + Expect.equals(9, dt1.minute); + Expect.equals(9, dt1.second); + Expect.equals(9, dt1.millisecond); + Expect.equals(true, dt1.isUtc); + dt1 = DateTime.parse("0009-09-09 09:09:09.009-00"); + Expect.equals(9, dt1.year); + Expect.equals(9, dt1.month); + Expect.equals(9, dt1.day); + Expect.equals(9, dt1.hour); + Expect.equals(9, dt1.minute); + Expect.equals(9, dt1.second); + Expect.equals(9, dt1.millisecond); + Expect.equals(true, dt1.isUtc); + dt1 = DateTime.parse("0009-09-09 09:09:09.009-0000"); + Expect.equals(9, dt1.year); + Expect.equals(9, dt1.month); + Expect.equals(9, dt1.day); + Expect.equals(9, dt1.hour); + Expect.equals(9, dt1.minute); + Expect.equals(9, dt1.second); + Expect.equals(9, dt1.millisecond); + Expect.equals(true, dt1.isUtc); + dt1 = DateTime.parse("0009-09-09 09:09:09.009-02"); + Expect.equals(9, dt1.year); + Expect.equals(9, dt1.month); + Expect.equals(9, dt1.day); + Expect.equals(11, dt1.hour); + Expect.equals(9, dt1.minute); + Expect.equals(9, dt1.second); + Expect.equals(9, dt1.millisecond); + Expect.equals(true, dt1.isUtc); + dt1 = DateTime.parse("0009-09-09 09:09:09.009+0200"); + Expect.equals(9, dt1.year); + Expect.equals(9, dt1.month); + Expect.equals(9, dt1.day); + Expect.equals(7, dt1.hour); + Expect.equals(9, dt1.minute); + Expect.equals(9, dt1.second); + Expect.equals(9, dt1.millisecond); + Expect.equals(true, dt1.isUtc); + dt1 = DateTime.parse("0009-09-09 09:09:09.009+1200"); + Expect.equals(9, dt1.year); + Expect.equals(9, dt1.month); + Expect.equals(8, dt1.day); + Expect.equals(21, dt1.hour); + Expect.equals(9, dt1.minute); + Expect.equals(9, dt1.second); + Expect.equals(9, dt1.millisecond); + Expect.equals(true, dt1.isUtc); + dt1 = DateTime.parse("0009-09-09 09:09:09.009-1200"); + Expect.equals(9, dt1.year); + Expect.equals(9, dt1.month); + Expect.equals(9, dt1.day); + Expect.equals(21, dt1.hour); + Expect.equals(9, dt1.minute); + Expect.equals(9, dt1.second); + Expect.equals(9, dt1.millisecond); + Expect.equals(true, dt1.isUtc); + dt1 = DateTime.parse("0009-09-09 09:09:09.009-0230"); + Expect.equals(9, dt1.year); + Expect.equals(9, dt1.month); + Expect.equals(9, dt1.day); + Expect.equals(11, dt1.hour); + Expect.equals(39, dt1.minute); + Expect.equals(9, dt1.second); + Expect.equals(9, dt1.millisecond); + Expect.equals(true, dt1.isUtc); + dt1 = DateTime.parse("0009-09-09 09:09:09.009-2134"); + Expect.equals(9, dt1.year); + Expect.equals(9, dt1.month); + Expect.equals(10, dt1.day); + Expect.equals(6, dt1.hour); + Expect.equals(43, dt1.minute); + Expect.equals(9, dt1.second); + Expect.equals(9, dt1.millisecond); + Expect.equals(true, dt1.isUtc); + + Expect.throws(() => DateTime.parse("bad"), (e) => e is FormatException); + var bad_year = + 1970 + (_MAX_MILLISECONDS ~/ (1000 * 60 * 60 * 24 * 365.2425)) + 1; + Expect.throws(() => DateTime.parse(bad_year.toString() + "-01-01"), + (e) => e is FormatException); + // The last valid time; should not throw. + dt1 = DateTime.parse("275760-09-13T00:00:00.000Z"); + Expect.throws(() => DateTime.parse("275760-09-14T00:00:00.000Z"), + (e) => e is FormatException); + Expect.throws(() => DateTime.parse("275760-09-13T00:00:00.001Z"), + (e) => e is FormatException); + if (supportsMicroseconds) { + Expect.throws(() => DateTime.parse("275760-09-13T00:00:00.000001Z"), + (e) => e is FormatException); + } else { + dt1 = DateTime.parse("275760-09-13T00:00:00.000001Z"); + } + + // first valid time; should not throw. + dt1 = DateTime.parse("-271821-04-20T00:00:00.000Z"); + Expect.throws(() => DateTime.parse("-271821-04-19T23:59:59.999Z"), + (e) => e is FormatException); + + if (supportsMicroseconds) { + Expect.throws(() => DateTime.parse("-271821-04-19T23:59:59.999999Z"), + (e) => e is FormatException); + } +} + +void testWeekday() { + // 2011-10-06 is Summertime. + var d = new DateTime(2011, 10, 6, 0, 45, 37, 0); + Expect.equals(DateTime.THURSDAY, d.weekday); + d = new DateTime.utc(2011, 10, 6, 0, 45, 37, 0); + Expect.equals(DateTime.THURSDAY, d.weekday); + d = new DateTime(2011, 10, 5, 23, 45, 37, 0); + Expect.equals(DateTime.WEDNESDAY, d.weekday); + d = new DateTime.utc(2011, 10, 5, 23, 45, 37, 0); + Expect.equals(DateTime.WEDNESDAY, d.weekday); + // 1970-01-01 is Wintertime. + d = new DateTime(1970, 1, 1, 0, 0, 0, 1); + Expect.equals(DateTime.THURSDAY, d.weekday); + d = new DateTime.utc(1970, 1, 1, 0, 0, 0, 1); + Expect.equals(DateTime.THURSDAY, d.weekday); + d = new DateTime.utc(1969, 12, 31, 23, 59, 59, 999); + Expect.equals(DateTime.WEDNESDAY, d.weekday); + d = new DateTime(1969, 12, 31, 23, 59, 59, 999); + Expect.equals(DateTime.WEDNESDAY, d.weekday); + d = new DateTime(2011, 10, 4, 23, 45, 37, 0); + Expect.equals(DateTime.TUESDAY, d.weekday); + d = new DateTime(2011, 10, 3, 23, 45, 37, 0); + Expect.equals(DateTime.MONDAY, d.weekday); + d = new DateTime(2011, 10, 2, 23, 45, 37, 0); + Expect.equals(DateTime.SUNDAY, d.weekday); + d = new DateTime(2011, 10, 1, 23, 45, 37, 0); + Expect.equals(DateTime.SATURDAY, d.weekday); + d = new DateTime(2011, 9, 30, 23, 45, 37, 0); + Expect.equals(DateTime.FRIDAY, d.weekday); +} + +void testToStrings() { + void test(date, time) { + { + // UTC time. + String source1 = "$date ${time}Z"; + String source2 = "${date}T${time}Z"; + var utcTime1 = DateTime.parse(source1); + var utcTime2 = DateTime.parse(source2); + Expect.isTrue(utcTime1.isUtc); + Expect.equals(utcTime1, utcTime2); + Expect.equals(source1, utcTime1.toString()); + Expect.equals(source2, utcTime1.toIso8601String()); + } + { + // Local time + String source1 = "$date $time"; + String source2 = "${date}T$time"; + var utcTime1 = DateTime.parse(source1); + var utcTime2 = DateTime.parse(source2); + Expect.isFalse(utcTime1.isUtc); + Expect.equals(utcTime1, utcTime2); + Expect.equals(source1, utcTime1.toString()); + Expect.equals(source2, utcTime1.toIso8601String()); + } + } + + test("2000-01-01", "12:00:00.000"); + test("-2000-01-01", "12:00:00.000"); + test("1970-01-01", "00:00:00.000"); + test("1969-12-31", "23:59:59.999"); + test("1969-09-09", "00:09:09.009"); + + if (supportsMicroseconds) { + test("2000-01-01", "12:00:00.000001"); + test("-2000-01-01", "12:00:00.000001"); + test("1970-01-01", "00:00:00.000001"); + test("1969-12-31", "23:59:59.999999"); + test("1969-09-09", "00:09:09.009999"); + } +} + +void testIsoString() { + var d = new DateTime(9999, 1, 1, 23, 59, 59, 999); + Expect.equals("9999-01-01T23:59:59.999", d.toIso8601String()); + d = new DateTime(-9999, 1, 1, 23, 59, 59, 999); + Expect.equals("-9999-01-01T23:59:59.999", d.toIso8601String()); + d = new DateTime.utc(9999, 1, 1, 23, 59, 59, 999); + Expect.equals("9999-01-01T23:59:59.999Z", d.toIso8601String()); + d = new DateTime.utc(-9999, 1, 1, 23, 59, 59, 999); + Expect.equals("-9999-01-01T23:59:59.999Z", d.toIso8601String()); + + d = new DateTime(10000, 1, 1, 23, 59, 59, 999); + Expect.equals("+010000-01-01T23:59:59.999", d.toIso8601String()); + d = new DateTime(-10000, 1, 1, 23, 59, 59, 999); + Expect.equals("-010000-01-01T23:59:59.999", d.toIso8601String()); + d = new DateTime.utc(10000, 1, 1, 23, 59, 59, 999); + Expect.equals("+010000-01-01T23:59:59.999Z", d.toIso8601String()); + d = new DateTime.utc(-10000, 1, 1, 23, 59, 59, 999); + Expect.equals("-010000-01-01T23:59:59.999Z", d.toIso8601String()); + + if (!supportsMicroseconds) return; + + d = new DateTime(9999, 1, 1, 23, 59, 59, 999, 999); + Expect.equals("9999-01-01T23:59:59.999999", d.toIso8601String()); + d = new DateTime(-9999, 1, 1, 23, 59, 59, 999, 999); + Expect.equals("-9999-01-01T23:59:59.999999", d.toIso8601String()); + d = new DateTime.utc(9999, 1, 1, 23, 59, 59, 999, 999); + Expect.equals("9999-01-01T23:59:59.999999Z", d.toIso8601String()); + d = new DateTime.utc(-9999, 1, 1, 23, 59, 59, 999, 999); + Expect.equals("-9999-01-01T23:59:59.999999Z", d.toIso8601String()); + + d = new DateTime(10000, 1, 1, 23, 59, 59, 999, 999); + Expect.equals("+010000-01-01T23:59:59.999999", d.toIso8601String()); + d = new DateTime(-10000, 1, 1, 23, 59, 59, 999, 999); + Expect.equals("-010000-01-01T23:59:59.999999", d.toIso8601String()); + d = new DateTime.utc(10000, 1, 1, 23, 59, 59, 999, 999); + Expect.equals("+010000-01-01T23:59:59.999999Z", d.toIso8601String()); + d = new DateTime.utc(-10000, 1, 1, 23, 59, 59, 999, 999); + Expect.equals("-010000-01-01T23:59:59.999999Z", d.toIso8601String()); + + d = new DateTime(9999, 1, 1, 23, 49, 59, 989, 979); + Expect.equals("9999-01-01T23:49:59.989979", d.toIso8601String()); + d = new DateTime(-9999, 1, 1, 23, 49, 59, 989, 979); + Expect.equals("-9999-01-01T23:49:59.989979", d.toIso8601String()); + d = new DateTime.utc(9999, 1, 1, 23, 49, 59, 989, 979); + Expect.equals("9999-01-01T23:49:59.989979Z", d.toIso8601String()); + d = new DateTime.utc(-9999, 1, 1, 23, 49, 59, 989, 979); + Expect.equals("-9999-01-01T23:49:59.989979Z", d.toIso8601String()); + + d = new DateTime(10000, 1, 1, 23, 49, 59, 989, 979); + Expect.equals("+010000-01-01T23:49:59.989979", d.toIso8601String()); + d = new DateTime(-10000, 1, 1, 23, 49, 59, 989, 979); + Expect.equals("-010000-01-01T23:49:59.989979", d.toIso8601String()); + d = new DateTime.utc(10000, 1, 1, 23, 49, 59, 989, 979); + Expect.equals("+010000-01-01T23:49:59.989979Z", d.toIso8601String()); + d = new DateTime.utc(-10000, 1, 1, 23, 49, 59, 989, 979); + Expect.equals("-010000-01-01T23:49:59.989979Z", d.toIso8601String()); +} + +void main() { + testNow(); + testMillisecondsSinceEpoch(); + testMicrosecondsSinceEpoch(); + testConstructors(); + testUTCGetters(); + testLocalGetters(); + testChangeTimeZone(); + testSubAdd(); + testUnderflowAndOverflow(); + testDateStrings(); + testEquivalentYears(); + testExtremes(); + testFarAwayDates(); + testWeekday(); + testToStrings(); + testIsoString(); +} diff --git a/tests/corelib/double_ceil2_test.dart b/tests/corelib/double_ceil2_test.dart new file mode 100644 index 00000000000..b82daec3482 --- /dev/null +++ b/tests/corelib/double_ceil2_test.dart @@ -0,0 +1,12 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:expect/expect.dart'; + +main() { + Expect.throws(() => double.INFINITY.ceil(), (e) => e is UnsupportedError); + Expect.throws( + () => double.NEGATIVE_INFINITY.ceil(), (e) => e is UnsupportedError); + Expect.throws(() => double.NAN.ceil(), (e) => e is UnsupportedError); +} diff --git a/tests/corelib/double_ceil_test.dart b/tests/corelib/double_ceil_test.dart new file mode 100644 index 00000000000..9901d09f690 --- /dev/null +++ b/tests/corelib/double_ceil_test.dart @@ -0,0 +1,84 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:expect/expect.dart'; + +main() { + Expect.equals(0, 0.0.ceil()); + Expect.equals(1, double.MIN_POSITIVE.ceil()); + Expect.equals(1, (2.0 * double.MIN_POSITIVE).ceil()); + Expect.equals(1, (1.18e-38).ceil()); + Expect.equals(1, (1.18e-38 * 2).ceil()); + Expect.equals(1, 0.49999999999999994.ceil()); + Expect.equals(1, 0.5.ceil()); + Expect.equals(1, 0.9999999999999999.ceil()); + Expect.equals(1, 1.0.ceil()); + Expect.equals(2, 1.000000000000001.ceil()); + // The following numbers are on the border of 52 bits. + // For example: 4503599627370499 + 0.5 => 4503599627370500. + Expect.equals(4503599627370496, 4503599627370496.0.ceil()); + Expect.equals(4503599627370497, 4503599627370497.0.ceil()); + Expect.equals(4503599627370498, 4503599627370498.0.ceil()); + Expect.equals(4503599627370499, 4503599627370499.0.ceil()); + + Expect.equals(9007199254740991, 9007199254740991.0.ceil()); + Expect.equals(9007199254740992, 9007199254740992.0.ceil()); + Expect.equals( + 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368, + double.MAX_FINITE.ceil()); + + Expect.equals(0, (-double.MIN_POSITIVE).ceil()); + Expect.equals(0, (2.0 * -double.MIN_POSITIVE).ceil()); + Expect.equals(0, (-1.18e-38).ceil()); + Expect.equals(0, (-1.18e-38 * 2).ceil()); + Expect.equals(0, (-0.49999999999999994).ceil()); + Expect.equals(0, (-0.5).ceil()); + Expect.equals(0, (-0.9999999999999999).ceil()); + Expect.equals(-1, (-1.0).ceil()); + Expect.equals(-1, (-1.000000000000001).ceil()); + Expect.equals(-4503599627370496, (-4503599627370496.0).ceil()); + Expect.equals(-4503599627370497, (-4503599627370497.0).ceil()); + Expect.equals(-4503599627370498, (-4503599627370498.0).ceil()); + Expect.equals(-4503599627370499, (-4503599627370499.0).ceil()); + Expect.equals(-9007199254740991, (-9007199254740991.0).ceil()); + Expect.equals(-9007199254740992, (-9007199254740992.0).ceil()); + Expect.equals( + -179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368, + (-double.MAX_FINITE).ceil()); + + Expect.isTrue(0.0.ceil() is int); + Expect.isTrue(double.MIN_POSITIVE.ceil() is int); + Expect.isTrue((2.0 * double.MIN_POSITIVE).ceil() is int); + Expect.isTrue((1.18e-38).ceil() is int); + Expect.isTrue((1.18e-38 * 2).ceil() is int); + Expect.isTrue(0.49999999999999994.ceil() is int); + Expect.isTrue(0.5.ceil() is int); + Expect.isTrue(0.9999999999999999.ceil() is int); + Expect.isTrue(1.0.ceil() is int); + Expect.isTrue(1.000000000000001.ceil() is int); + Expect.isTrue(4503599627370496.0.ceil() is int); + Expect.isTrue(4503599627370497.0.ceil() is int); + Expect.isTrue(4503599627370498.0.ceil() is int); + Expect.isTrue(4503599627370499.0.ceil() is int); + Expect.isTrue(9007199254740991.0.ceil() is int); + Expect.isTrue(9007199254740992.0.ceil() is int); + Expect.isTrue(double.MAX_FINITE.ceil() is int); + + Expect.isTrue((-double.MIN_POSITIVE).ceil() is int); + Expect.isTrue((2.0 * -double.MIN_POSITIVE).ceil() is int); + Expect.isTrue((-1.18e-38).ceil() is int); + Expect.isTrue((-1.18e-38 * 2).ceil() is int); + Expect.isTrue((-0.49999999999999994).ceil() is int); + Expect.isTrue((-0.5).ceil() is int); + Expect.isTrue((-0.9999999999999999).ceil() is int); + Expect.isTrue((-1.0).ceil() is int); + Expect.isTrue((-1.000000000000001).ceil() is int); + Expect.isTrue((-4503599627370496.0).ceil() is int); + Expect.isTrue((-4503599627370497.0).ceil() is int); + Expect.isTrue((-4503599627370498.0).ceil() is int); + Expect.isTrue((-4503599627370499.0).ceil() is int); + Expect.isTrue((-9007199254740991.0).ceil() is int); + Expect.isTrue((-9007199254740992.0).ceil() is int); + Expect.isTrue((-double.MAX_FINITE).ceil() is int); +} diff --git a/tests/corelib/double_ceil_to_double_test.dart b/tests/corelib/double_ceil_to_double_test.dart new file mode 100644 index 00000000000..46774e7c9f9 --- /dev/null +++ b/tests/corelib/double_ceil_to_double_test.dart @@ -0,0 +1,93 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:expect/expect.dart'; + +main() { + Expect.equals(0.0, 0.0.ceilToDouble()); + Expect.equals(1.0, double.MIN_POSITIVE.ceilToDouble()); + Expect.equals(1.0, (2.0 * double.MIN_POSITIVE).ceilToDouble()); + Expect.equals(1.0, (1.18e-38).ceilToDouble()); + Expect.equals(1.0, (1.18e-38 * 2).ceilToDouble()); + Expect.equals(1.0, 0.49999999999999994.ceilToDouble()); + Expect.equals(1.0, 0.5.ceilToDouble()); + Expect.equals(1.0, 0.9999999999999999.ceilToDouble()); + Expect.equals(1.0, 1.0.ceilToDouble()); + Expect.equals(2.0, 1.000000000000001.ceilToDouble()); + // The following numbers are on the border of 52 bits. + // For example: 4503599627370499 + 0.5 => 4503599627370500. + Expect.equals(4503599627370496.0, 4503599627370496.0.ceilToDouble()); + Expect.equals(4503599627370497.0, 4503599627370497.0.ceilToDouble()); + Expect.equals(4503599627370498.0, 4503599627370498.0.ceilToDouble()); + Expect.equals(4503599627370499.0, 4503599627370499.0.ceilToDouble()); + + Expect.equals(9007199254740991.0, 9007199254740991.0.ceilToDouble()); + Expect.equals(9007199254740992.0, 9007199254740992.0.ceilToDouble()); + Expect.equals(double.MAX_FINITE, double.MAX_FINITE.ceilToDouble()); + + Expect.equals(0.0, (-double.MIN_POSITIVE).ceilToDouble()); + Expect.equals(0.0, (2.0 * -double.MIN_POSITIVE).ceilToDouble()); + Expect.equals(0.0, (-1.18e-38).ceilToDouble()); + Expect.equals(0.0, (-1.18e-38 * 2).ceilToDouble()); + Expect.equals(0.0, (-0.49999999999999994).ceilToDouble()); + Expect.equals(0.0, (-0.5).ceilToDouble()); + Expect.equals(0.0, (-0.9999999999999999).ceilToDouble()); + Expect.equals(-1.0, (-1.0).ceilToDouble()); + Expect.equals(-1.0, (-1.000000000000001).ceilToDouble()); + Expect.equals(-4503599627370496.0, (-4503599627370496.0).ceilToDouble()); + Expect.equals(-4503599627370497.0, (-4503599627370497.0).ceilToDouble()); + Expect.equals(-4503599627370498.0, (-4503599627370498.0).ceilToDouble()); + Expect.equals(-4503599627370499.0, (-4503599627370499.0).ceilToDouble()); + Expect.equals(-9007199254740991.0, (-9007199254740991.0).ceilToDouble()); + Expect.equals(-9007199254740992.0, (-9007199254740992.0).ceilToDouble()); + Expect.equals(-double.MAX_FINITE, (-double.MAX_FINITE).ceilToDouble()); + + Expect.equals(double.INFINITY, double.INFINITY.ceilToDouble()); + Expect.equals( + double.NEGATIVE_INFINITY, double.NEGATIVE_INFINITY.ceilToDouble()); + Expect.isTrue(double.NAN.ceilToDouble().isNaN); + + Expect.isTrue(0.0.ceilToDouble() is double); + Expect.isTrue(double.MIN_POSITIVE.ceilToDouble() is double); + Expect.isTrue((2.0 * double.MIN_POSITIVE).ceilToDouble() is double); + Expect.isTrue((1.18e-38).ceilToDouble() is double); + Expect.isTrue((1.18e-38 * 2).ceilToDouble() is double); + Expect.isTrue(0.49999999999999994.ceilToDouble() is double); + Expect.isTrue(0.5.ceilToDouble() is double); + Expect.isTrue(0.9999999999999999.ceilToDouble() is double); + Expect.isTrue(1.0.ceilToDouble() is double); + Expect.isTrue(1.000000000000001.ceilToDouble() is double); + Expect.isTrue(4503599627370496.0.ceilToDouble() is double); + Expect.isTrue(4503599627370497.0.ceilToDouble() is double); + Expect.isTrue(4503599627370498.0.ceilToDouble() is double); + Expect.isTrue(4503599627370499.0.ceilToDouble() is double); + Expect.isTrue(9007199254740991.0.ceilToDouble() is double); + Expect.isTrue(9007199254740992.0.ceilToDouble() is double); + Expect.isTrue(double.MAX_FINITE.ceilToDouble() is double); + + Expect.isTrue((-double.MIN_POSITIVE).ceilToDouble().isNegative); + Expect.isTrue((2.0 * -double.MIN_POSITIVE).ceilToDouble().isNegative); + Expect.isTrue((-1.18e-38).ceilToDouble().isNegative); + Expect.isTrue((-1.18e-38 * 2).ceilToDouble().isNegative); + Expect.isTrue((-0.49999999999999994).ceilToDouble().isNegative); + Expect.isTrue((-0.5).ceilToDouble().isNegative); + Expect.isTrue((-0.9999999999999999).ceilToDouble().isNegative); + + Expect.isTrue((-double.MIN_POSITIVE).ceilToDouble() is double); + Expect.isTrue((2.0 * -double.MIN_POSITIVE).ceilToDouble() is double); + Expect.isTrue((-1.18e-38).ceilToDouble() is double); + Expect.isTrue((-1.18e-38 * 2).ceilToDouble() is double); + Expect.isTrue((-0.49999999999999994).ceilToDouble() is double); + Expect.isTrue((-0.5).ceilToDouble() is double); + Expect.isTrue((-0.9999999999999999).ceilToDouble() is double); + Expect.isTrue((-1.0).ceilToDouble() is double); + Expect.isTrue((-1.000000000000001).ceilToDouble() is double); + Expect.isTrue((-4503599627370496.0).ceilToDouble() is double); + Expect.isTrue((-4503599627370497.0).ceilToDouble() is double); + Expect.isTrue((-4503599627370498.0).ceilToDouble() is double); + Expect.isTrue((-4503599627370499.0).ceilToDouble() is double); + Expect.isTrue((-9007199254740991.0).ceilToDouble() is double); + Expect.isTrue((-9007199254740992.0).ceilToDouble() is double); + Expect.isTrue((-double.MAX_FINITE).ceilToDouble() is double); +} diff --git a/tests/corelib/double_compare_test.dart b/tests/corelib/double_compare_test.dart new file mode 100644 index 00000000000..c5a426ecc8f --- /dev/null +++ b/tests/corelib/double_compare_test.dart @@ -0,0 +1,49 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +// Dart test program for testing 'compare' on doubles. + +void main() { + Expect.equals(0, (0.0).compareTo(0.0)); + Expect.equals(0, (1.0).compareTo(1.0)); + Expect.equals(0, (-2.0).compareTo(-2.0)); + Expect.equals(0, (1e-50).compareTo(1e-50)); + Expect.equals(0, (-2e50).compareTo(-2e50)); + Expect.equals(0, double.NAN.compareTo(double.NAN)); + Expect.equals(0, double.INFINITY.compareTo(double.INFINITY)); + Expect.equals( + 0, double.NEGATIVE_INFINITY.compareTo(double.NEGATIVE_INFINITY)); + Expect.equals(0, (-0.0).compareTo(-0.0)); + Expect.isTrue((0.0).compareTo(1.0) < 0); + Expect.isTrue((1.0).compareTo(0.0) > 0); + Expect.isTrue((0.0).compareTo(-1.0) > 0); + Expect.isTrue((-1.0).compareTo(0.0) < 0); + Expect.isTrue((0.0).compareTo(1234e11) < 0); + Expect.isTrue((123e-112).compareTo(0.0) > 0); + Expect.isTrue((0.0).compareTo(-123.0e12) > 0); + Expect.isTrue((-1.0e8).compareTo(0.0) < 0); + + double maxDouble = 1.7976931348623157e308; + Expect.equals(0, maxDouble.compareTo(maxDouble)); + Expect.isTrue(maxDouble.compareTo(double.INFINITY) < 0); + Expect.isTrue(double.INFINITY.compareTo(maxDouble) > 0); + + double negMaxDouble = -maxDouble; + Expect.equals(0, negMaxDouble.compareTo(negMaxDouble)); + Expect.isTrue(double.NEGATIVE_INFINITY.compareTo(negMaxDouble) < 0); + Expect.isTrue(negMaxDouble.compareTo(double.NEGATIVE_INFINITY) > 0); + + Expect.isTrue((-0.0).compareTo(0.0) < 0); + Expect.isTrue((0.0).compareTo(-0.0) > 0); + Expect.isTrue(double.NAN.compareTo(double.INFINITY) > 0); + Expect.isTrue(double.NAN.compareTo(double.NEGATIVE_INFINITY) > 0); + Expect.isTrue(double.INFINITY.compareTo(double.NAN) < 0); + Expect.isTrue(double.NEGATIVE_INFINITY.compareTo(double.NAN) < 0); + Expect.isTrue(maxDouble.compareTo(double.NAN) < 0); + Expect.isTrue(negMaxDouble.compareTo(double.NAN) < 0); + Expect.isTrue(double.NAN.compareTo(maxDouble) > 0); + Expect.isTrue(double.NAN.compareTo(negMaxDouble) > 0); +} diff --git a/tests/corelib/double_floor2_test.dart b/tests/corelib/double_floor2_test.dart new file mode 100644 index 00000000000..a83808838b4 --- /dev/null +++ b/tests/corelib/double_floor2_test.dart @@ -0,0 +1,12 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:expect/expect.dart'; + +main() { + Expect.throws(() => double.INFINITY.floor(), (e) => e is UnsupportedError); + Expect.throws( + () => double.NEGATIVE_INFINITY.floor(), (e) => e is UnsupportedError); + Expect.throws(() => double.NAN.floor(), (e) => e is UnsupportedError); +} diff --git a/tests/corelib/double_floor_test.dart b/tests/corelib/double_floor_test.dart new file mode 100644 index 00000000000..e7732757ac7 --- /dev/null +++ b/tests/corelib/double_floor_test.dart @@ -0,0 +1,84 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:expect/expect.dart'; + +main() { + Expect.equals(0, 0.0.floor()); + Expect.equals(0, double.MIN_POSITIVE.floor()); + Expect.equals(0, (2.0 * double.MIN_POSITIVE).floor()); + Expect.equals(0, (1.18e-38).floor()); + Expect.equals(0, (1.18e-38 * 2).floor()); + Expect.equals(0, 0.49999999999999994.floor()); + Expect.equals(0, 0.5.floor()); + Expect.equals(0, 0.9999999999999999.floor()); + Expect.equals(1, 1.0.floor()); + Expect.equals(1, 1.000000000000001.floor()); + // The following numbers are on the border of 52 bits. + // For example: 4503599627370499 + 0.5 => 4503599627370500. + Expect.equals(4503599627370496, 4503599627370496.0.floor()); + Expect.equals(4503599627370497, 4503599627370497.0.floor()); + Expect.equals(4503599627370498, 4503599627370498.0.floor()); + Expect.equals(4503599627370499, 4503599627370499.0.floor()); + + Expect.equals(9007199254740991, 9007199254740991.0.floor()); + Expect.equals(9007199254740992, 9007199254740992.0.floor()); + Expect.equals( + 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368, + double.MAX_FINITE.floor()); + + Expect.equals(-1, (-double.MIN_POSITIVE).floor()); + Expect.equals(-1, (2.0 * -double.MIN_POSITIVE).floor()); + Expect.equals(-1, (-1.18e-38).floor()); + Expect.equals(-1, (-1.18e-38 * 2).floor()); + Expect.equals(-1, (-0.49999999999999994).floor()); + Expect.equals(-1, (-0.5).floor()); + Expect.equals(-1, (-0.9999999999999999).floor()); + Expect.equals(-1, (-1.0).floor()); + Expect.equals(-2, (-1.000000000000001).floor()); + Expect.equals(-4503599627370496, (-4503599627370496.0).floor()); + Expect.equals(-4503599627370497, (-4503599627370497.0).floor()); + Expect.equals(-4503599627370498, (-4503599627370498.0).floor()); + Expect.equals(-4503599627370499, (-4503599627370499.0).floor()); + Expect.equals(-9007199254740991, (-9007199254740991.0).floor()); + Expect.equals(-9007199254740992, (-9007199254740992.0).floor()); + Expect.equals( + -179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368, + (-double.MAX_FINITE).floor()); + + Expect.isTrue(0.0.floor() is int); + Expect.isTrue(double.MIN_POSITIVE.floor() is int); + Expect.isTrue((2.0 * double.MIN_POSITIVE).floor() is int); + Expect.isTrue((1.18e-38).floor() is int); + Expect.isTrue((1.18e-38 * 2).floor() is int); + Expect.isTrue(0.49999999999999994.floor() is int); + Expect.isTrue(0.5.floor() is int); + Expect.isTrue(0.9999999999999999.floor() is int); + Expect.isTrue(1.0.floor() is int); + Expect.isTrue(1.000000000000001.floor() is int); + Expect.isTrue(4503599627370496.0.floor() is int); + Expect.isTrue(4503599627370497.0.floor() is int); + Expect.isTrue(4503599627370498.0.floor() is int); + Expect.isTrue(4503599627370499.0.floor() is int); + Expect.isTrue(9007199254740991.0.floor() is int); + Expect.isTrue(9007199254740992.0.floor() is int); + Expect.isTrue(double.MAX_FINITE.floor() is int); + + Expect.isTrue((-double.MIN_POSITIVE).floor() is int); + Expect.isTrue((2.0 * -double.MIN_POSITIVE).floor() is int); + Expect.isTrue((-1.18e-38).floor() is int); + Expect.isTrue((-1.18e-38 * 2).floor() is int); + Expect.isTrue((-0.49999999999999994).floor() is int); + Expect.isTrue((-0.5).floor() is int); + Expect.isTrue((-0.9999999999999999).floor() is int); + Expect.isTrue((-1.0).floor() is int); + Expect.isTrue((-1.000000000000001).floor() is int); + Expect.isTrue((-4503599627370496.0).floor() is int); + Expect.isTrue((-4503599627370497.0).floor() is int); + Expect.isTrue((-4503599627370498.0).floor() is int); + Expect.isTrue((-4503599627370499.0).floor() is int); + Expect.isTrue((-9007199254740991.0).floor() is int); + Expect.isTrue((-9007199254740992.0).floor() is int); + Expect.isTrue((-double.MAX_FINITE).floor() is int); +} diff --git a/tests/corelib/double_floor_to_double_test.dart b/tests/corelib/double_floor_to_double_test.dart new file mode 100644 index 00000000000..e174d4c0769 --- /dev/null +++ b/tests/corelib/double_floor_to_double_test.dart @@ -0,0 +1,85 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:expect/expect.dart'; + +main() { + Expect.equals(0.0, 0.0.floorToDouble()); + Expect.equals(0.0, double.MIN_POSITIVE.floorToDouble()); + Expect.equals(0.0, (2.0 * double.MIN_POSITIVE).floorToDouble()); + Expect.equals(0.0, (1.18e-38).floorToDouble()); + Expect.equals(0.0, (1.18e-38 * 2).floorToDouble()); + Expect.equals(0.0, 0.49999999999999994.floorToDouble()); + Expect.equals(0.0, 0.5.floorToDouble()); + Expect.equals(0.0, 0.9999999999999999.floorToDouble()); + Expect.equals(1.0, 1.0.floorToDouble()); + Expect.equals(1.0, 1.000000000000001.floorToDouble()); + // The following numbers are on the border of 52 bits. + // For example: 4503599627370499 + 0.5 => 4503599627370500. + Expect.equals(4503599627370496.0, 4503599627370496.0.floorToDouble()); + Expect.equals(4503599627370497.0, 4503599627370497.0.floorToDouble()); + Expect.equals(4503599627370498.0, 4503599627370498.0.floorToDouble()); + Expect.equals(4503599627370499.0, 4503599627370499.0.floorToDouble()); + + Expect.equals(9007199254740991.0, 9007199254740991.0.floorToDouble()); + Expect.equals(9007199254740992.0, 9007199254740992.0.floorToDouble()); + Expect.equals(double.MAX_FINITE, double.MAX_FINITE.floorToDouble()); + + Expect.equals(-1.0, (-double.MIN_POSITIVE).floorToDouble()); + Expect.equals(-1.0, (2.0 * -double.MIN_POSITIVE).floorToDouble()); + Expect.equals(-1.0, (-1.18e-38).floorToDouble()); + Expect.equals(-1.0, (-1.18e-38 * 2).floorToDouble()); + Expect.equals(-1.0, (-0.49999999999999994).floorToDouble()); + Expect.equals(-1.0, (-0.5).floorToDouble()); + Expect.equals(-1.0, (-0.9999999999999999).floorToDouble()); + Expect.equals(-1.0, (-1.0).floorToDouble()); + Expect.equals(-2.0, (-1.000000000000001).floorToDouble()); + Expect.equals(-4503599627370496.0, (-4503599627370496.0).floorToDouble()); + Expect.equals(-4503599627370497.0, (-4503599627370497.0).floorToDouble()); + Expect.equals(-4503599627370498.0, (-4503599627370498.0).floorToDouble()); + Expect.equals(-4503599627370499.0, (-4503599627370499.0).floorToDouble()); + Expect.equals(-9007199254740991.0, (-9007199254740991.0).floorToDouble()); + Expect.equals(-9007199254740992.0, (-9007199254740992.0).floorToDouble()); + Expect.equals(-double.MAX_FINITE, (-double.MAX_FINITE).floorToDouble()); + + Expect.equals(double.INFINITY, double.INFINITY.floorToDouble()); + Expect.equals( + double.NEGATIVE_INFINITY, double.NEGATIVE_INFINITY.floorToDouble()); + Expect.isTrue(double.NAN.floorToDouble().isNaN); + + Expect.isTrue(0.0.floorToDouble() is double); + Expect.isTrue(double.MIN_POSITIVE.floorToDouble() is double); + Expect.isTrue((2.0 * double.MIN_POSITIVE).floorToDouble() is double); + Expect.isTrue((1.18e-38).floorToDouble() is double); + Expect.isTrue((1.18e-38 * 2).floorToDouble() is double); + Expect.isTrue(0.49999999999999994.floorToDouble() is double); + Expect.isTrue(0.5.floorToDouble() is double); + Expect.isTrue(0.9999999999999999.floorToDouble() is double); + Expect.isTrue(1.0.floorToDouble() is double); + Expect.isTrue(1.000000000000001.floorToDouble() is double); + Expect.isTrue(4503599627370496.0.floorToDouble() is double); + Expect.isTrue(4503599627370497.0.floorToDouble() is double); + Expect.isTrue(4503599627370498.0.floorToDouble() is double); + Expect.isTrue(4503599627370499.0.floorToDouble() is double); + Expect.isTrue(9007199254740991.0.floorToDouble() is double); + Expect.isTrue(9007199254740992.0.floorToDouble() is double); + Expect.isTrue(double.MAX_FINITE.floorToDouble() is double); + + Expect.isTrue((-double.MIN_POSITIVE).floorToDouble() is double); + Expect.isTrue((2.0 * -double.MIN_POSITIVE).floorToDouble() is double); + Expect.isTrue((-1.18e-38).floorToDouble() is double); + Expect.isTrue((-1.18e-38 * 2).floorToDouble() is double); + Expect.isTrue((-0.49999999999999994).floorToDouble() is double); + Expect.isTrue((-0.5).floorToDouble() is double); + Expect.isTrue((-0.9999999999999999).floorToDouble() is double); + Expect.isTrue((-1.0).floorToDouble() is double); + Expect.isTrue((-1.000000000000001).floorToDouble() is double); + Expect.isTrue((-4503599627370496.0).floorToDouble() is double); + Expect.isTrue((-4503599627370497.0).floorToDouble() is double); + Expect.isTrue((-4503599627370498.0).floorToDouble() is double); + Expect.isTrue((-4503599627370499.0).floorToDouble() is double); + Expect.isTrue((-9007199254740991.0).floorToDouble() is double); + Expect.isTrue((-9007199254740992.0).floorToDouble() is double); + Expect.isTrue((-double.MAX_FINITE).floorToDouble() is double); +} diff --git a/tests/corelib/double_parse_test.dart b/tests/corelib/double_parse_test.dart new file mode 100644 index 00000000000..9cfdea1ecca --- /dev/null +++ b/tests/corelib/double_parse_test.dart @@ -0,0 +1,1196 @@ +// Copyright (c) 2014 the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. +// VMOptions=--no-use-field-guards +// VMOptions= + +import "dart:math" show pow; +import "package:expect/expect.dart"; + +const whiteSpace = const [ + "", + "\x09", + "\x0a", + "\x0b", + "\x0c", + "\x0d", + "\x85", // //# 01: ok + "\xa0", + "\u1680", + "\u2000", + "\u2001", + "\u2002", + "\u2003", + "\u2004", + "\u2005", + "\u2006", + "\u2007", + "\u2008", + "\u2009", + "\u200a", + "\u2028", + "\u2029", + "\u202f", + "\u205f", + "\u3000", + "\uFEFF" +]; + +void expectNumEquals(double expected, var actual, String message) { + if (expected.isNaN) { + Expect.isTrue(actual is double && actual.isNaN, "isNaN: $message"); + } else { + Expect.identical(expected, actual, message); + } +} + +// Test source surrounded by any combination of whitespace. +void testParseAllWhitespace(String source, double result) { + for (String ws1 in whiteSpace) { + for (String ws2 in whiteSpace) { + String padded = "$ws1$source$ws2"; + // Use Expect.identical because it also handles NaN and 0.0/-0.0. + // Except on dart2js: http://dartbug.com/11551 + expectNumEquals(result, double.parse(padded), "parse '$padded'"); + padded = "$ws1$ws2$source"; + expectNumEquals(result, double.parse(padded), "parse '$padded'"); + padded = "$source$ws1$ws2"; + expectNumEquals(result, double.parse(padded), "parse '$padded'"); + } + } +} + +// Test source and -source surrounded by any combination of whitespace. +void testParseWhitespace(String source, double result) { + assert(result >= 0); + testParseAllWhitespace(source, result); + testParseAllWhitespace("-$source", -result); +} + +// Test parsing source, optionally preceeded and/or followed by whitespace. +void testParse(String source, double result, [name = ""]) { + expectNumEquals(result, double.parse(source), "parse '$source:$name"); + expectNumEquals(result, double.parse(" $source"), "parse ' $source':$name"); + expectNumEquals(result, double.parse("$source "), "parse '$source ':$name"); + expectNumEquals(result, double.parse(" $source "), "parse ' $source ':$name"); + + expectNumEquals(result, double.parse("+$source"), "parse '+$source:$name"); + expectNumEquals(result, double.parse(" +$source"), "parse ' +$source':$name"); + expectNumEquals(result, double.parse("+$source "), "parse '+$source ':$name"); + expectNumEquals( + result, double.parse(" +$source "), "parse ' +$source ':$name"); + + expectNumEquals(-result, double.parse("-$source"), "parse '-$source:$name"); + expectNumEquals( + -result, double.parse(" -$source"), "parse ' -$source':$name"); + expectNumEquals( + -result, double.parse("-$source "), "parse '-$source ':$name"); + expectNumEquals( + -result, double.parse(" -$source "), "parse ' -$source ':$name"); +} + +void testDouble(double value) { + testParse("$value", value); + if (value.isFinite) { + String exp = value.toStringAsExponential(); + String lcexp = exp.toLowerCase(); + testParse(lcexp, value); + String ucexp = exp.toUpperCase(); + testParse(ucexp, value); + } +} + +void testFail(String source) { + var object = new Object(); + Expect.throws(() { + double.parse(source, (s) { + Expect.equals(source, s); + throw object; + }); + }, (e) => identical(object, e), "Fail: '$source'"); + Expect.equals(1.5, double.parse(source, (s) => 1.5)); +} + +void main() { + testDouble(0.0); + testDouble(5e-324); + testDouble(2.225073858507201e-308); + testDouble(2.2250738585072014e-308); + testDouble(0.49999999999999994); + testDouble(0.5); + testDouble(0.50000000000000006); + testDouble(0.9999999999999999); + testDouble(1.0); + testDouble(1.0000000000000002); + testDouble(4294967295.0); + testDouble(4294967296.0); + testDouble(4503599627370495.5); + testDouble(4503599627370497.0); + testDouble(9007199254740991.0); + testDouble(9007199254740992.0); + testDouble(1.7976931348623157e+308); + testDouble(double.INFINITY); + testDouble(double.NAN); + + // Strings that cannot occur from toString of a number. + testParse("000000000000", 0.0); + testParse("000000000001", 1.0); + testParse("000000000000.0000000000000", 0.0); + testParse("000000000001.0000000000000", 1.0); + testParse("0e0", 0.0); + testParse("0e+0", 0.0); + testParse("0e-0", 0.0); + testParse("1e0", 1.0); + testParse("1e+0", 1.0); + testParse("1e-0", 1.0); + testParse("1.", 1.0); + testParse(".1", 0.1); + testParse("1.e1", 10.0); + testParse(".1e1", 1.0); + testParse("Infinity", double.INFINITY); + testParse("NaN", double.NAN); + + // Cases where mantissa and 10^exponent are representable as a double. + for (int i = -22; i <= 22; i++) { + for (double j in [1.0, 9007199254740991.0, 9007199254740992.0]) { + var value = (i >= 0) ? j * pow(10.0, i) : j / pow(10.0, -i); + testParse("${j}e$i", value, "$i/$j"); + testParse("${j}E$i", value, "$i/$j"); + if (i >= 0) { + testParse("${j}e+$i", value, "$i/$j"); + testParse("${j}E+$i", value, "$i/$j"); + } + } + } + for (int i = 0; i <= 22; i++) { + var digits = "9007199254740991"; + for (int i = 0; i < digits.length; i++) { + int dotIndex = digits.length - i; + var string = "${digits.substring(0, dotIndex)}." + "${digits.substring(dotIndex)}e$i"; + testParse(string, 9007199254740991.0); + } + } + + testParse( + "0.00000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000012351641146031163604414219821705534309126495065358119110639" + "6420625168876817552187966324959090408998094949141173861429432731" + "6641775889849490996936990026954695315751782975778511319614542919" + "6224552592217965901424968268076250159685228839124609682811834931" + "8292403785007928846349518531559641397792756664639171692046759890" + "0776562329863178978731138323263641361002818700324274998854829973" + "5227010414083113118928696725368169503983880965288753370088162336" + "8004844756702677687292583305671118833393020810798402309572336459" + "2015026502876542452438269585569329582311976245631182694093981811" + "9686640211945509336174248834117544931694293962814151377997828762" + "2277536275946568454181273895934743339974841620248529105142565927" + "256981069188614130727188467062660492956638336181640625", + 0.0); + testParse( + "0.00000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000024703282292062327208828439643411068618252990130716238221279" + "2841250337753635104375932649918180817996189898282347722858865463" + "3283551779698981993873980053909390631503565951557022639229085839" + "2449105184435931802849936536152500319370457678249219365623669863" + "6584807570015857692699037063119282795585513329278343384093519780" + "1553124659726357957462276646527282722005637400648549997709659947" + "0454020828166226237857393450736339007967761930577506740176324673" + "6009689513405355374585166611342237666786041621596804619144672918" + "4030053005753084904876539171138659164623952491262365388187963623" + "9373280423891018672348497668235089863388587925628302755995657524" + "4555072551893136908362547791869486679949683240497058210285131854" + "51396213837722826145437693412532098591327667236328125", + 0.0); + testParse( + "0.00000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000024703282292062327208828439643411068618252990130716238221279" + "2841250337753635104375932649918180817996189898282347722858865463" + "3283551779698981993873980053909390631503565951557022639229085839" + "2449105184435931802849936536152500319370457678249219365623669863" + "6584807570015857692699037063119282795585513329278343384093519780" + "1553124659726357957462276646527282722005637400648549997709659947" + "0454020828166226237857393450736339007967761930577506740176324673" + "6009689513405355374585166611342237666786041621596804619144672918" + "4030053005753084904876539171138659164623952491262365388187963623" + "9373280423891018672348497668235089863388587925628302755995657524" + "4555072551893136908362547791869486679949683240497058210285131854" + "51396213837722826145437693412532098591327667236328125", + 0.0); + testParse("0.00000000000000000000000000000000000000000000000000000000000000" //# 03: ok + "0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok + "0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok + "0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok + "0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok + "0000024703282292062327208828439643411068627545332140664243314532" //# 03: ok + "8041234170109088178685677591650492652607243027730579814636067699" //# 03: ok + "1112238669661707327453443265068702897439863329200619332642599205" //# 03: ok + "1806252781222000513169502627641523911022607448403553068808609405" //# 03: ok + "1727798181294290864842608522062097649849550765341204993205100587" //# 03: ok + "2127469658709242016690593998242808606978027857019419997429604579" //# 03: ok + "7572623273334010723772922131119806567715298322567005234345331218" //# 03: ok + "5169920860031716486480793611343761679481328431956040281530986197" //# 03: ok + "8304604971452253283193290744072288902141724247846767401941767720" //# 03: ok + "8561650585989659548591956327689896895290365125294085321852619688" //# 03: ok + "9863888974446146846024033780172178553364579041996676675092137151" //# 03: ok + "9705456298034409473812692774776868254618683783877327369245051207" //# 03: ok + "5931578479504396230612962142122846982018227555473696607567828620" //# 03: ok + "5497859173707553281928994692862033843994140625", // //# 03: ok + 5e-324); // //# 03: ok + testParse( + "0.00000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000037054923438093490813242659465116602918087143186126352238665" + "4061891674274999582254154033144959392383231717975289492511095959" + "2096640779585747657231506869704773681319051549691937265430115392" + "9316510179867828993955338712739726887403536747219495345250565253" + "9734220743745353366904984135736109339114232557854653467028698863" + "1755341990606652876965097618075398198036065644601954996844545287" + "8562428797081554870870561495721040952204106503876761616095480465" + "4854302923481671949982122917011832487483775622035971266330696098" + "1770527542930458978998057183774359009418156980309146068528141338" + "9871550473737887132279287842897827763181104688776671568136524122" + "1523792405286695424882335699501538146509629059245968850620692484" + "3143597161396297062546730578356156393213233025204703880754948792" + "4068421520495603769387037857877153017981772444526303392432171379" + "4502140826292446718071005307137966156005859375", + 5e-324); + testParse( + "0.00000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000037054923438093490813242659465116602927379485196074357331918" + "9261875506630452656563898974877271226994284847423521584288298194" + "9925327669548472990810970080864085947255348927335533958843628758" + "8673657776653897704274904804228750479055686517373829048435504795" + "4877211355023786539048555594678924193378269993917515076140279670" + "2329686989589536936193414969790924083008456100972824996564489920" + "5681031242249339356786090176104508511951642895866260110264487010" + "4014534270108033061877749917013356500179062432395206928717009377" + "6045079508629627357314808756707988746935928736893548082281945435" + "9059920635836528008522746502352634795082881888442454133993486286" + "6832608827839705362543821687804230019924524860745587315427697781" + "770943207565842392181565401187981478869915008544921875", + 5e-324); + testParse( + "0.00000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000037054923438093490813242659465116602936671827206022362425172" + "4461859338985905730873643916609583061605337976871753676065500430" + "7754014559511198324390433292023398213191646304979130652257142124" + "8030805373439966414594470895717774070707836287528162751620444337" + "0020201966302219711192127053621739047642307429980376685251860477" + "2904031988572420995421732321506449967980846557343694996284434553" + "2799633687417123842701618856487976071699179287855758604433493555" + "3174765616734394173773376917014880512874349242754442591103322657" + "0319631474328795735631560329641618484453700493477950096035749532" + "8248290797935168884766205161807441826984659088108236699850448451" + "2141425250392715300205307676106921893339420662245205780234703079" + "2275266989920550781084577445403473184185067145693733619245051207" + "5931578479504396230612962142122846982018227555473696607567828620" + "5497859173707553281928994692862033843994140625", + 5e-324); + testParse( + "0.00000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000049406564584124654417656879286822137236505980261432476442558" + "5682500675507270208751865299836361635992379796564695445717730926" + "6567103559397963987747960107818781263007131903114045278458171678" + "4898210368871863605699873072305000638740915356498438731247339727" + "3169615140031715385398074126238565591171026658556686768187039560" + "3106249319452715914924553293054565444011274801297099995419319894" + "0908041656332452475714786901472678015935523861155013480352649347" + "2019379026810710749170333222684475333572083243193609238289345836" + "8060106011506169809753078342277318329247904982524730776375927247" + "8746560847782037344696995336470179726777175851256605511991315048" + "9110145103786273816725095583738973359899366480994116420570263709" + "0279242767544565229087538682506419718265533447265625", + 5e-324); + testParse( + "0.00000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000049406564584124654417656879286822137255090664281328486629065" + "6082468340218176357371355183300985305214486055461159629272135398" + "2224477339323414654906886530137405794879726658401238665285198410" + "3612505562444001026339005255283047822045214896807106137617218810" + "3455596362588581729685217044124195299699101530682409986410201174" + "4254939317418484033381187996485617213956055714038839994859209159" + "5145246546668021447545844262239613135430596645134010468690662437" + "0339841720063432972961587222687523358962656863912080563061972395" + "6609209942904506566386581488144577804283448495693534803883535441" + "7123301171979319097183912655379793790580730250588170643705239377" + "9727777948892293692048067560344357106729158083993353350184274303" + "9410912596068818947625385549553736509237367567754654738490102415" + "1863156959008792461225924284245693964036455110947393215135657241" + "099571834741510656385798938572406768798828125", + 5e-324); + testParse( + "0.00000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000074109846876186981626485318930233205836174286372252704477330" + "8123783348549999164508308066289918784766463435950578985022191918" + "4193281559171495314463013739409547362638103099383874530860230785" + "8633020359735657987910677425479453774807073494438990690501130507" + "9468441487490706733809968271472218678228465115709306934057397726" + "3510683981213305753930195236150796396072131289203909993689090575" + "7124857594163109741741122991442081904408213007753523232190960930" + "9708605846963343899964245834023664974967551244071942532661392196" + "3541055085860917957996114367548718018836313960618292137056282677" + "9743100947475774264558575685795655526362209377553343136273048244" + "3047584810573390849764671399003076293019258118491937701241384968" + "6287194322792594125093461156712312786426466050409407761509897584" + "8136843040991207538774075715754306035963544889052606784864342758" + "900428165258489343614201061427593231201171875", + 5e-324); + testParse("0.00000000000000000000000000000000000000000000000000000000000000" //# 02: ok + "0000000000000000000000000000000000000000000000000000000000000000" //# 02: ok + "0000000000000000000000000000000000000000000000000000000000000000" //# 02: ok + "0000000000000000000000000000000000000000000000000000000000000000" //# 02: ok + "0000000000000000000000000000000000000000000000000000000000000000" //# 02: ok + "0000074109846876186981626485318930233205854758970392148714663837" //# 02: ok + "8523751013260905313127797949754542453988569694847043168576596389" //# 02: ok + "9850655339096945981621940161728171894510697854671067917687257517" //# 02: ok + "7347315553307795408549809608457500958111373034747658096871009590" //# 02: ok + "9754422710047573078097111189357848386756539987835030152280559340" //# 02: ok + "4659373979179073872386829939581848166016912201945649993128979841" //# 02: ok + "1362062484498678713572180352209017023903285791732520220528974020" //# 02: ok + "8029068540216066123755499834026713000358124864790413857434018755" //# 02: ok + "2090159017259254714629617513415977493871857473787096164563890871" //# 02: ok + "8119841271673056017045493004705269590165763776884908267986972573" //# 02: ok + "3665217655679410725087643375608460039849049721491174630855395563" //# 02: ok + "54188641513168478436313080237596295773983001708984375", // //# 02: ok + 1e-323); // //# 02: ok + testParse("0.00000000000000000000000000000000000000000000000000000000000000" //# 03: ok + "0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok + "0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok + "0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok + "0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok + "0000074109846876186981626485318930233205873343654412044724850344" //# 03: ok + "8923718677971811461747287833219166123210675953743507352131000861" //# 03: ok + "5508029119022396648780866584046796426383292609958261304514284249" //# 03: ok + "6061610746879932829188941791435548141415672575056325503240888674" //# 03: ok + "0040403932604439422384254107243478095284614859960753370503720954" //# 03: ok + "5808063977144841990843464643012899935961693114687389992568869106" //# 03: ok + "5599267374834247685403237712975952143398358575711517208866987110" //# 03: ok + "6349531233468788347546753834029761025748698485508885182206645314" //# 03: ok + "0639262948657591471263120659283236968907400986955900192071499065" //# 03: ok + "6496581595870337769532410323614883653969318176216473399700896902" //# 03: ok + "4282850500785430600410615352213843786678841324490411560469406158" //# 03: ok + "4550533979841101562169154890806946368370134291387467238490102415" //# 03: ok + "1863156959008792461225924284245693964036455110947393215135657241" //# 03: ok + "099571834741510656385798938572406768798828125", // //# 03: ok + 1e-323); // //# 03: ok + testParse( + "0.00000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000011125369292" + "5360069154511635866620203210960799023116591527666370844360221740" + "6959097927141579506255510282033669865517905502576217080776730054" + "4280061926888594105653889967660011652398050737212918180359607825" + "2347125186710418762540332530832907947436024558998429581982425031" + "7954385059152437399890443876874974725790225802525457699928291235" + "4093225567689679024960579905428830259962166760571761950743978498" + "0479564444580149632075553173315669683173879325651468588102366281" + "5890742832175436061414318821022423405703806955738531400844926622" + "0550120807237108092835830752700771425423583764509515806613894483" + "6485368656166704349449158753391942346304638698898642932982747054" + "5684547703068233784351199339157645340492308605462312698364257812" + "5", + 1.1125369292536007e-308); + testParse( + "0.00000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000011125369292" + "5360069154511635866620203210960799023116610112350390740370408247" + "7359065591852485654875000165498293534740011761472681264331134525" + "9937435706814044772812816389978636184270645492500111567186634557" + "1061420380282556183179464713810955130740324099307096988352304114" + "8240366281709303744177586794760604434318300674651180918151452849" + "5241915565655447143417214608859882029906947673313501950183867763" + "4716769334915718603906610534082604802668952109630465576440379371" + "4211205525428158285205572821025471431094380576457002725617553180" + "9099224738635444849469333898568030900459127277678319834121502677" + "4862108980363986101936076072301556410108193098230208064696671383" + "6302180548174253659674171315763029087322100208461549627978268407" + "4131669828524253718537846867047316790971834120489029738490102415" + "1863156959008792461225924284245693964036455110947393215135657241" + "099571834741510656385798938572406768798828125", + 1.1125369292536007e-308); + testParse( + "0.00000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000011125369292" + "5360093857793927928947412039400442434185191195972481664588256512" + "9400380600184308462011953048487227014291989141962100620081191046" + "1906239926662125432368943599250777752029021933482747432761666932" + "6081935177574213144751136884007361083502182696938981541236215812" + "4253211406611428748302338022108627812847664259678077865798649401" + "4497660229450268863966221848525061212023023248478571949013749179" + "6696380382410806898101889263285073571646568472249978339940677865" + "3579969652328069212208231432361613047099274956616864695216972981" + "6031069881591856241078866777972171115011992742603077167294249913" + "7481908755860441269310739102717418145889672225195380557264480249" + "9621987409855350817390775154421748273612200242960133979035379072" + "1007951555248028896005922474205893068160932603143782761509897584" + "8136843040991207538774075715754306035963544889052606784864342758" + "900428165258489343614201061427593231201171875", + 1.1125369292536007e-308); + testParse( + "0.00000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000011125369292" + "5360093857793927928947412039400442434185209780656501560598443019" + "9800348264895214610631442931951850683514095400858564803635595517" + "7563613706587576099527870021569402283901616688769940819588693664" + "4796230371146350565390269066985408266806482237247648947606094895" + "4539192629168295092589480939994257521375739131803801084021811015" + "5646350227416036982422856551956112981967804161220311948453638445" + "0933585272746375869932946624052008691141641256228975328278690955" + "1900432345580791435999485432364661072489848577335336019989599540" + "4580173812990192997712369923839430590047536255771881194801858107" + "5858649080057723021797656421627032209693226624526945688978404579" + "0239620254961370692713747131027132020441991845959370908649389667" + "01396213837722826145437693412532098591327667236328125", + 1.1125369292536007e-308); + testParse("0.00000000000000000000000000000000000000000000000000000000000000" //# 03: ok + "0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok + "0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok + "0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok + "0000000000000000000000000000000000000000000000000000011125369292" //# 03: ok + "5360093857793927928947412039400442434185228365340521456608629527" //# 03: ok + "0200315929606120759250932815416474352736201659755028987189999989" //# 03: ok + "3220987486513026766686796443888026815774211444057134206415720396" //# 03: ok + "3510525564718487986029401249963455450110781777556316353975973978" //# 03: ok + "4825173851725161436876623857879887229903814003929524302244972629" //# 03: ok + "6795040225381805100879491255387164751912585073962051947893527710" //# 03: ok + "5170790163081944841764003984818943810636714040207972316616704045" //# 03: ok + "0220895038833513659790739432367709097880422198053807344762226099" //# 03: ok + "3129277744388529754345873069706690065083079768940685222309466301" //# 03: ok + "4235389404255004774284573740536646273496781023858510820692328908" //# 03: ok + "0857253100067390568036719107632515767271783448958607838263400261" //# 03: ok + "9271291212296536333081616208300526650104600844121842238490102415" //# 03: ok + "1863156959008792461225924284245693964036455110947393215135657241" //# 03: ok + "099571834741510656385798938572406768798828125", // //# 03: ok + 1.112536929253601e-308); // //# 03: ok + testParse( + "0.00000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000011125369292" + "5360118561076219991274620867840085845253828033646632276836664299" + "2641598602648849715007375581870031501510285299140912526494460981" + "0847165486286558093401850075478792915405182640326963458817779503" + "7245335555582282368240205603137908586176939915496868313229764759" + "1124000199184152785288518003113540316961252461082144468115330795" + "7199474887142394939885133198483395703973441561868861946163298392" + "1387606100912602107790340074788347699109403186806482068455015628" + "7910121858986146810584652043706898739275890198932140639134272458" + "8610226818743277902588909094978089754671488747034246582989821731" + "5231929503948741694146154089862122073081814550155248444974062103" + "4794692806854507601076294922896618700391675086456429118934521521" + "5279242767544565229087538682506419718265533447265625", + 1.112536929253601e-308); + testParse( + "0.00000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000011125369292" + "5360118561076219991274620867840085845253846618330652172846850806" + "3041566267359755863626865465334655170732391558037376710048865452" + "6504539266212008760560776497797417447277777395614156845644806235" + "5959630749154419788879337786115955769481239455805535719599643842" + "1409981421741019129575660920999170025489327333207867686338492409" + "8348164885108163058341767901914447473918222474610601945603187657" + "5624810991248171079621397435555282818604475970785479056793028718" + "6230584552238869034375906043709946764666463819650611963906899017" + "7159330750141614659222412240845349229707032260203050610497429925" + "3608669828146023446633071408771736136885368949486813576687986432" + "5412325651960527476399266899502002447221466689455666048548532116" + "4410912596068818947625385549553736509237367567754654738490102415" + "1863156959008792461225924284245693964036455110947393215135657241" + "099571834741510656385798938572406768798828125", + 1.112536929253601e-308); + testParse( + "0.00000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000011125369292" + "5360143264358512053601829696279729256322427701952743097064699071" + "5082881275691578670763818348323588650284368938526796065798921972" + "8473343486060089420116903707069559015036153836596792711219838611" + "0980145546446076750451009956312361722243098053437420272483555539" + "7422826546643144133700412148347193404018690918234764633985688961" + "7603909548902984778890775141579626656034298049775671944433069073" + "7604422038743259373816676164757751587582092333404991820293327212" + "5599348679138779961378564655046088380671358199810473933506318818" + "4091175893098026050831945120249489444259897725127807943670177161" + "6228469603642478614007734439187597872666848076451986069255795298" + "8732132513641624634115870738160721633511566723954250399605642781" + "1287194322792594125093461156712312786426466050409407761509897584" + "8136843040991207538774075715754306035963544889052606784864342758" + "900428165258489343614201061427593231201171875", + 1.112536929253601e-308); + testParse("0.00000000000000000000000000000000000000000000000000000000000000" //# 02: ok + "0000000000000000000000000000000000000000000000000000000000000000" //# 02: ok + "0000000000000000000000000000000000000000000000000000000000000000" //# 02: ok + "0000000000000000000000000000000000000000000000000000000000000000" //# 02: ok + "0000000000000000000000000000000000000000000000000000011125369292" //# 02: ok + "5360143264358512053601829696279729256322446286636762993074885578" //# 02: ok + "5482848940402484819383308231788212319506475197423260249353326444" //# 02: ok + "4130717265985540087275830129388183546908748591883986098046865342" //# 02: ok + "9694440740018214171090142139290408905547397593746087678853434622" //# 02: ok + "7708807769200010477987555066232823112546765790360487852208850575" //# 02: ok + "8752599546868752897347409845010678425979078962517411943872958339" //# 02: ok + "1841626929078828345647733525524686707077165117383988808631340302" //# 02: ok + "3919811372391502185169818655049136406061931820528945258278945377" //# 02: ok + "2640279824496362807465448266116748919295441238296611971177785355" //# 02: ok + "4605209927839760366494651758097211936470402475783551200969719627" //# 02: ok + "9349765358747644509438842714766105380341358326953487329219653376" //# 02: ok + "04188641513168478436313080237596295773983001708984375", // //# 02: ok + 1.1125369292536017e-308); // //# 02: ok + testParse("0.00000000000000000000000000000000000000000000000000000000000000" //# 03: ok + "0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok + "0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok + "0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok + "0000000000000000000000000000000000000000000000000000011125369292" //# 03: ok + "5360143264358512053601829696279729256322464871320782889085072085" //# 03: ok + "5882816605113390968002798115252835988728581456319724432907730915" //# 03: ok + "9788091045910990754434756551706808078781343347171179484873892074" //# 03: ok + "8408735933590351591729274322268456088851697134054755085223313705" //# 03: ok + "7994788991756876822274697984118452821074840662486211070432012189" //# 03: ok + "9901289544834521015804044548441730195923859875259151943312847604" //# 03: ok + "6078831819414397317478790886291621826572237901362985796969353392" //# 03: ok + "2240274065644224408961072655052184431452505441247416583051571936" //# 03: ok + "1189383755894699564098951411984008394330984751465415998685393549" //# 03: ok + "2981950252037042118981569077006826000273956875115116332683643956" //# 03: ok + "9967398203853664384761814691371489127171149929952724258833663970" //# 03: ok + "9550533979841101562169154890806946368370134291387467238490102415" //# 03: ok + "1863156959008792461225924284245693964036455110947393215135657241" //# 03: ok + "099571834741510656385798938572406768798828125", // //# 03: ok + 1.1125369292536017e-308); // //# 03: ok + testParse( + "0.00000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000022250738585" + "0720138309023271733240406421921598046233183055332741688720443481" + "3918195854283159012511020564067339731035811005152434161553460108" + "8560123853777188211307779935320023304796101474425836360719215650" + "4694250373420837525080665061665815894872049117996859163964850063" + "5908770118304874799780887753749949451580451605050915399856582470" + "8186451135379358049921159810857660519924333521143523901487956996" + "0959128889160299264151106346631339366347758651302937176204732563" + "1781485664350872122828637642044846811407613911477062801689853244" + "1100241614474216185671661505401542850847167529019031613227788967" + "2970737312333408698898317506783884692609277397797285865965494109" + "1369095406136467568702398678315290680984617210924625396728515625", + 2.2250738585072014e-308); + testParse( + "0.00000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000022250738585" + "0720138309023271733240406421921598046233201640016761584730629988" + "4318163518994065161130510447531963400257917264048898345107864580" + "4217497633702638878466706357638647836668696229713029747546242382" + "3408545566992974945719797244643863078176348658305526570334729146" + "6194751340861741144068030671635579160108526477176638618079744084" + "9335141133345126168377794514288712289869114433885263900927846261" + "5196333779495868235982163707398274485842831435281934164542745653" + "0101948357603594346619891642047894836798187532195534126462479802" + "9649345545872552942305164651268802325882711042187835640735397161" + "1347477636530690451385234825693498756412831797128850997679418438" + "1986728251242487444025370654920674427814408813923862326342526219" + "9131669828524253718537846867047316790971834120489029738490102415" + "1863156959008792461225924284245693964036455110947393215135657241" + "099571834741510656385798938572406768798828125", + 2.2250738585072014e-308); + testParse( + "0.00000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000022250738585" + "0720163012305563795567615250361241457301782723638852508948478253" + "6359478527325887968267463330520896879809894644538317700857921100" + "6186301853550719538022833566910789404427072670695665613121274757" + "8429060364284631907291469414840269030938207255937411123218640844" + "2207596465763866148192781898983602538637890062203535565726940636" + "8590885797139947888926801753953891471985190009050333899757727677" + "7175944826990956530177442436600743254820447797901446928043044146" + "9470712484503505273622550253384036452803081912355396096061899603" + "6581190688828964333914697530672942540435576507112592973908144397" + "3967277412027145618759897856109360492194310924094023490247227304" + "5306535112923584601741974493579393614104508848422446677399636884" + "6007951555248028896005922474205893068160932603143782761509897584" + "8136843040991207538774075715754306035963544889052606784864342758" + "900428165258489343614201061427593231201171875", + 2.2250738585072014e-308); + testParse( + "0.00000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000022250738585" + "0720163012305563795567615250361241457301801308322872404958664760" + "6759446192036794116886953213985520549032000903434781884412325572" + "1843675633476170205181759989229413936299667425982858999948301489" + "7143355557856769327930601597818316214242506796246078529588519927" + "2493577688320732492479924816869232247165964934329258783950102250" + "9739575795105716007383436457384943241929970921792073899197616943" + "1413149717326525502008499797367678374315520581880443916381057236" + "7791175177756227497413804253387084478193655533073867420834526162" + "5130294620227301090548200676540202015471120020281397001415752591" + "2344017736224427371246815175018974555997865323425588621961151633" + "5924167958029604477064946470184777360934300451421683607013647479" + "51396213837722826145437693412532098591327667236328125", + 2.2250738585072014e-308); + testParse("0.00000000000000000000000000000000000000000000000000000000000000" //# 03: ok + "0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok + "0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok + "0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok + "0000000000000000000000000000000000000000000000000000022250738585" //# 03: ok + "0720163012305563795567615250361241457301819893006892300968851267" //# 03: ok + "7159413856747700265506443097450144218254107162331246067966730043" //# 03: ok + "7501049413401620872340686411548038468172262181270052386775328221" //# 03: ok + "5857650751428906748569733780796363397546806336554745935958399010" //# 03: ok + "2779558910877598836767067734754861955694039806454982002173263865" //# 03: ok + "0888265793071484125840071160815995011874751834533813898637506208" //# 03: ok + "5650354607662094473839557158134613493810593365859440904719070326" //# 03: ok + "6111637871008949721205058253390132503584229153792338745607152721" //# 03: ok + "3679398551625637847181703822407461490506663533450201028923360785" //# 03: ok + "0720758060421709123733732493928588619801419722757153753675075962" //# 03: ok + "6541800803135624352387918446790161107764092054420920536627658074" //# 03: ok + "4271291212296536333081616208300526650104600844121842238490102415" //# 03: ok + "1863156959008792461225924284245693964036455110947393215135657241" //# 03: ok + "099571834741510656385798938572406768798828125", // //# 03: ok + 2.225073858507202e-308); // //# 03: ok + testParse( + "0.00000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000022250738585" + "0720187715587855857894824078800884868370419561313003121196886039" + "9600696529790429221262885863903701367028190801717129607271191035" + "5127227413175152199055740043138804567803233377539881639177387328" + "9592460742292701130780538133970816533612964474495297895212189790" + "9078385258336590185178961879988515042751478263607602168043622031" + "1292700454832073964845713103912225963935608322440623896907276890" + "1867170545492751739865893248104017382283282512457950656557381910" + "3800864691161582871998970864729322144979697154670672039979199080" + "9160347625980385995424739847678861180095072511543762389603716215" + "1717298160115446043595312843254064419386453249053891377956809158" + "0479240509922741385427494262054264040883983691918741817298779334" + "0279242767544565229087538682506419718265533447265625", + 2.225073858507202e-308); + testParse( + "0.00000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000022250738585" + "0720187715587855857894824078800884868370438145997023017207072547" + "0000664194501335369882375747368325036250297060613593790825595507" + "0784601193100602866214666465457429099675828132827075026004414060" + "8306755935864838551419670316948863716917264014803965301582068873" + "9364366480893456529466104797874144751279553135733325386266783645" + "2441390452797842083302347807343277733880389235182363896347166155" + "6104375435828320711696950608870952501778355296436947644895395000" + "2121327384414305095790224864732370170370270775389143364751825639" + "7709451557378722752058242993546120655130616024712566417111324409" + "0094038484312727796082230162163678483190007648385456509670733487" + "1096873355028761260750466238659647787713775294917978746912789928" + "9410912596068818947625385549553736509237367567754654738490102415" + "1863156959008792461225924284245693964036455110947393215135657241" + "099571834741510656385798938572406768798828125", + 2.225073858507202e-308); + testParse( + "0.00000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000022250738585" + "0720212418870147920222032907240528279439019229619113941424920812" + "2041979202833158177019328630357258515802274441103013146575652027" + "2753405412948683525770793674729570667434204573809710891579446436" + "3327270733156495512991342487145269669679122612435849854465980571" + "5377211605795581533590856025222168129808916720760222333913980197" + "1697135116592663803851355047008456915996464810347433895177047571" + "8083986483323409005892229338073421270755971659056460408395693494" + "1490091511314216022792883476068511786375165155549005334351245440" + "4641296700335134143667775872950260869683481489637323750284071645" + "2713838259809182963456893192579540218971486775350629002238542353" + "4416680216709858418467070077318366974003875329416563097969900593" + "6287194322792594125093461156712312786426466050409407761509897584" + "8136843040991207538774075715754306035963544889052606784864342758" + "900428165258489343614201061427593231201171875", + 2.225073858507202e-308); + testParse("0.00000000000000000000000000000000000000000000000000000000000000" //# 03: ok + "0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok + "0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok + "0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok + "0000000000000000000000000000000000000000000000000000022250738585" //# 03: ok + "0720212418870147920222032907240528279439037814303133837435107319" //# 03: ok + "2441946867544064325638818513821882185024380699999477330130056498" //# 03: ok + "8410779192874134192929720097048195199306799329096904278406473168" //# 03: ok + "2041565926728632933630474670123316852983422152744517260835859654" //# 03: ok + "5663192828352447877877998943107797838336991592885945552137141811" //# 03: ok + "2845825114558431922307989750439508685941245723089173894616936837" //# 03: ok + "2321191373658977977723286698840356390251044443035457396733706583" //# 03: ok + "9810554204566938246584137476071559811765738776267476659123871999" //# 03: ok + "3190400631733470900301279018817520344719025002806127777791679839" //# 03: ok + "1090578584006464715943810511489154282775041174682194133952466682" //# 03: ok + "5034313061815878293790042053923750720833666932415800027583911188" //# 03: ok + "54188641513168478436313080237596295773983001708984375", // //# 03: ok + 2.2250738585072024e-308); // //# 03: ok + testParse("0.00000000000000000000000000000000000000000000000000000000000000" //# 03: ok + "0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok + "0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok + "0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok + "0000000000000000000000000000000000000000000000000000022250738585" //# 03: ok + "0720212418870147920222032907240528279439056398987153733445293826" //# 03: ok + "2841914532254970474258308397286505854246486958895941513684460970" //# 03: ok + "4068152972799584860088646519366819731179394084384097665233499900" //# 03: ok + "0755861120300770354269606853101364036287721693053184667205738737" //# 03: ok + "5949174050909314222165141860993427546865066465011668770360303425" //# 03: ok + "3994515112524200040764624453870560455886026635830913894056826102" //# 03: ok + "6558396263994546949554344059607291509746117227014454385071719673" //# 03: ok + "8131016897819660470375391476074607837156312396985947983896498558" //# 03: ok + "1739504563131807656934782164684779819754568515974931805299288032" //# 03: ok + "9467318908203746468430727830398768346578595574013759265666391011" //# 03: ok + "5651945906921898169113014030529134467663458535415036957197921783" //# 03: ok + "4550533979841101562169154890806946368370134291387467238490102415" //# 03: ok + "1863156959008792461225924284245693964036455110947393215135657241" //# 03: ok + "099571834741510656385798938572406768798828125", // //# 03: ok + 2.2250738585072024e-308); // //# 03: ok + testParse( + "0.00000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000100208418000448638899805402" + "5675081023947173151201955956352756465219477298834774949553868001" + "7172354813827222283890479851867436841402279176933922227531985191" + "9016883548022442028316027357265612083085166971723487691494714589" + "5578331812936322386545483369746322848628024994920311121080242823" + "5714326388663336759990619917681011604908667604621058852897083245" + "0816977893343649540492907374306035456728456338904015275857972276" + "1526157631250497160973795706924168310120033199859199012414074894" + "8202195091387650850548954516920927386376492603899633528627985383" + "2932104496700123254769405070337764094630065313795728259355401668" + "8207267296623786504114239553488532354086348874488976434804499149" + "322509765625", + 1.0020841800044864e-292); + testParse( + "0.00000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000100208418000448638899805402" + "5675081023947173151201956040050732492021560444211472901925540702" + "1586014286915762763038748010206109436411449756840422987132589595" + "3085274649978096343836685185731606312366412920027708756586099963" + "7975552653362983131506665648352778744386705639822064232334712197" + "7867779247842315182877112028658635902319185766818606103345104073" + "9923514010434512590195330770391813338086311968111531328662618487" + "3315578521649250253839821623536466419018719481428679013982985346" + "1571995354000952600076951720089726239270930511481845755671197870" + "4747866889418540057514218596081876158765839665014133210631738825" + "4165335079883777074977685931654819161553596657523084699300803458" + "3609637179288099118793858900152420545987239088654699259390735847" + "0152049332041520812604025151794328168042160636342216519487980314" + "421878240614097350935640662328296457417309284210205078125", + 1.0020841800044864e-292); + testParse( + "0.00000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000100208418000448650025174695" + "1035150178458809017822159083615579461533985681124447841542417041" + "9717793267880261310997721975562434111911014099603638548708110842" + "9228554372955381818449259496459629506201971760632184806762937040" + "5528236159220080404124633621972774900305368909016987591808198481" + "1515258588636795736994571683578362033288375244948969302377353651" + "5803667343942465515751063883649087835332767470268261173797304563" + "0216301185431893700183322963627539884395226243941187598947530725" + "0723137660949785162435276134774551939185861652055952702429699518" + "1666462911218814544860422297294423455917874727086839114692958995" + "8734568169530500282699951928714187892923739790353511103290941894" + "8525105836280134665557340439005224794505069516807613438973521965" + "4847950667958479187395974848205671831957839363657783480512019685" + "578121759385902649064359337671703542582690715789794921875", + 1.0020841800044864e-292); + testParse( + "0.00000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000100208418000448650025174695" + "1035150178458809017822159167313555488336068826501145793914089742" + "4131452740968801790145990133901106706920184679510139308308715246" + "3296945474911036133969917324925623735483217708936405871854322414" + "7925456999646741149085815900579230796064049553918740703062667855" + "3668711447815774159881063794555986330698893407146516552825374480" + "4910203461033328565453487279734865716690623099475777226601950774" + "2005722075830646793049348880239837993293912525510667600516441176" + "4092937923563086911963273337943350792080299559638164929472912005" + "3482225303937231347605235823038535520053649078305244065969296152" + "4692635952790490853563398306880474700390987573387619367787246203" + "8909645359318233784351199339157645340492308605462312698364257812" + "5", + 1.0020841800044864e-292); + testParse("0.00000000000000000000000000000000000000000000000000000000000000" //# 03: ok + "0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok + "0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok + "0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok + "0000000000000000000000000000000000000100208418000448650025174695" //# 03: ok + "1035150178458809017822159251011531515138151971877843746285762442" //# 03: ok + "8545112214057342269294258292239779301929355259416640067909319649" //# 03: ok + "7365336576866690449490575153391617964764463657240626936945707789" //# 03: ok + "0322677840073401894046998179185686691822730198820493814317137229" //# 03: ok + "5822164306994752582767555905533610628109411569344063803273395309" //# 03: ok + "4016739578124191615155910675820643598048478728683293279406596985" //# 03: ok + "3795142966229399885915374796852136102192598807080147602085351627" //# 03: ok + "7462738186176388661491270541112149644974737467220377156516124492" //# 03: ok + "5297987696655648150350049348782647584189423429523649017245633309" //# 03: ok + "0650703736050481424426844685046761507858235356421727632283550512" //# 03: ok + "9294184882356332903145058239310065886479547694117011957754993659" //# 03: ok + "5152049332041520812604025151794328168042160636342216519487980314" //# 03: ok + "421878240614097350935640662328296457417309284210205078125", // //# 03: ok + 1.0020841800044866e-292); // //# 03: ok + testParse( + "0.00000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000200416836000897255548872220" + "0630023738871074569163505490783914884205771542336808210387292522" + "0426513773371285555269939139667533951768747348715410293510510274" + "9473643242267695845324274779211200861374232469021139022270213528" + "6462413252451807248010301677826829802384000871843763078195635583" + "5519882659021798720200352081612073758236883604191202305937584019" + "3447504651307941031064654937754410393532579156664506650227987556" + "2093186373340695057796485067216997253892307748415460848623417226" + "4622904518424429578269271391797007961345371296322204255566117522" + "4763967378926030323867148635273985338412963098572424905483014370" + "3443797280914164309330161600193180015563420351180667003643504189" + "5081099906363532431297601321684709319015382789075374603271484375", + 2.0041683600089726e-292); + testParse( + "0.00000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000200416836000897255548872220" + "0630023738871074569163505574481890911007854687713506162758965222" + "4840173246459826034418207298006206546777917928621911053111114678" + "3542034344223350160844932607677195090655478417325360087361598902" + "8859634092878467992971483956433285698142681516745516189450104957" + "7673335518200777143086844192589698055647401766388749556385604848" + "2554040768398804080767078333840188274890434785872022703032633767" + "3882607263739448150662510983829295362790994029984940850192327677" + "7992704781037731327797268594965806814239809203904416482609330009" + "6579729771644447126611962161018097402548737449790829856759351526" + "9401865064174154880193607978359466823030668134214775268139808498" + "5465639429401631550091460221837129865002621877730073862662220222" + "0152049332041520812604025151794328168042160636342216519487980314" + "421878240614097350935640662328296457417309284210205078125", + 2.0041683600089726e-292); + testParse( + "0.00000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000000000000000000000000000000" + "0000000000000000000000000000000000000200416836000897266674241512" + "5990092893382710435783708618046737880520279924626481102375841562" + "2971952227424324582377181263362531222277482271385126614686635925" + "9685314067200635635457506918405218284491037257929836137538435979" + "6412317598735565265589451930053281854061344785940439548923591241" + "1320814858995257697204303847509424186616591244519112755417854425" + "8434194101906757006322811447097462772136890288028752548167319843" + "0783329927522091597006012323920368828167500792497449435156873056" + "7143847087986563890155593009650632514154740344478523429367831657" + "3498325793444721613958165862230644699700772511863535760820571697" + "3971098153820878087915873975418835554400811267045201672129946935" + "0381108086393667096854941760689934113520452305882988042245006340" + "4847950667958479187395974848205671831957839363657783480512019685" + "578121759385902649064359337671703542582690715789794921875", + 2.0041683600089726e-292); + testParse("0.00000000000000000000000000000000000000000000000000000000000000" //# 03: ok + "0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok + "0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok + "0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok + "0000000000000000000000000000000000000200416836000897266674241512" //# 03: ok + "5990092893382710435783708701744713907322363070003179054747514262" //# 03: ok + "7385611700512865061525449421701203817286652851291627374287240329" //# 03: ok + "3753705169156289950978164746871212513772283206234057202629821353" //# 03: ok + "8809538439162226010550634208659737749820025430842192660178060615" //# 03: ok + "3474267718174236120090795958487048484027109406716660005865875254" //# 03: ok + "7540730218997620056025234843183240653494745917236268600971966054" //# 03: ok + "2572750817920844689872038240532666937066187074066929436725783508" //# 03: ok + "0513647350599865639683590212819431367049178252060735656411044144" //# 03: ok + "5314088186163138416702979387974756763836546863081940712096908853" //# 03: ok + "9929165937080868658779320353585122361868059050079309936626251244" //# 03: ok + "0765647609431766215648800660842354659507691394537687301635742187" //# 03: ok + "5", // //# 03: ok + 2.004168360008973e-292); // //# 03: ok + testParse("0.00000000000000000000000000000000000000000000000000000000000000" //# 03: ok + "0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok + "0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok + "0000000000000000000000000000000000000000000000000000000000000000" //# 03: ok + "0000000000000000000000000000000000000200416836000897266674241512" //# 03: ok + "5990092893382710435783708785442689934124446215379877007119186963" //# 03: ok + "1799271173601405540673717580039876412295823431198128133887844732" //# 03: ok + "7822096271111944266498822575337206743053529154538278267721206728" //# 03: ok + "1206759279588886755511816487266193645578706075743945771432529989" //# 03: ok + "5627720577353214542977288069464672781437627568914207256313896083" //# 03: ok + "6647266336088483105727658239269018534852601546443784653776612265" //# 03: ok + "4362171708319597782738064157144965045964873355636409438294693959" //# 03: ok + "3883447613213167389211587415988230219943616159642947883454256631" //# 03: ok + "7129850578881555219447792913718868827972321214300345663373246010" //# 03: ok + "5887233720340859229642766731751409169335306833113418201122555553" //# 03: ok + "1150187132469865334442659560994775205494930483192386561026478034" //# 03: ok + "5152049332041520812604025151794328168042160636342216519487980314" //# 03: ok + "421878240614097350935640662328296457417309284210205078125", // //# 03: ok + 2.004168360008973e-292); // //# 03: ok + testParse("0.99999999999999988897769753748434595763683319091796875", + 0.9999999999999999); + testParse( + "0.99999999999999988897769753748434595763683319091796879176194859" + "5190556970945882299241904356487451251641385905655273315006228765" + "423911854226535211864757002331316471099853515625", + 0.9999999999999999); + testParse( + "0.99999999999999994448884876874217297881841659545898433323805140" + "4809443029054117700758095643512548748358614094344726684993771234" + "576088145773464788135242997668683528900146484375", + 0.9999999999999999); + testParse("0.999999999999999944488848768742172978818416595458984375", //# 03: ok + 1.0); // //# 03: ok + testParse("0.99999999999999994448884876874217297881841659545898441676194859" //# 03: ok + "5190556970945882299241904356487451251641385905655273315006228765" //# 03: ok + "423911854226535211864757002331316471099853515625", // //# 03: ok + 1.0); // //# 03: ok + testParse("0.499999999999999944488848768742172978818416595458984375", + 0.49999999999999994); + testParse( + "0.49999999999999994448884876874217297881841659545898439588097429" + "7595278485472941149620952178243725625820692952827636657503114382" + "7119559271132676059323785011656582355499267578125", + 0.49999999999999994); + testParse( + "0.49999999999999997224442438437108648940920829772949216661902570" + "2404721514527058850379047821756274374179307047172363342496885617" + "2880440728867323940676214988343417644500732421875", + 0.49999999999999994); + testParse("0.4999999999999999722444243843710864894092082977294921875", //# 03: ok + 0.5); // //# 03: ok + testParse("0.49999999999999997224442438437108648940920829772949220838097429" //# 03: ok + "7595278485472941149620952178243725625820692952827636657503114382" //# 03: ok + "7119559271132676059323785011656582355499267578125", // //# 03: ok + 0.5); // //# 03: ok + testParse("1.9999999999999997779553950749686919152736663818359375", + 1.9999999999999998); + testParse( + "1.99999999999999977795539507496869191527366638183593758352389719" + "0381113941891764598483808712974902503282771811310546630012457530" + "84782370845307042372951400466263294219970703125", + 1.9999999999999998); + testParse( + "1.99999999999999988897769753748434595763683319091796866647610280" + "9618886058108235401516191287025097496717228188689453369987542469" + "15217629154692957627048599533736705780029296875", + 1.9999999999999998); + testParse("1.99999999999999988897769753748434595763683319091796875", //# 03: ok + 2.0); // //# 03: ok + testParse("1.99999999999999988897769753748434595763683319091796883352389719" //# 03: ok + "0381113941891764598483808712974902503282771811310546630012457530" //# 03: ok + "84782370845307042372951400466263294219970703125", // //# 03: ok + 2.0); // //# 03: ok + testParse("4503599627370495.5", 4503599627370495.5); + testParse( + "4503599627370495.50000000000000000000000000000000000018807909613" + "1566001274997845955559308450986489083534003441400273004546761512" + "75634765625", + 4503599627370495.5); + testParse( + "4503599627370495.74999999999999999999999999999999999981192090386" + "8433998725002154044440691549013510916465996558599726995453238487" + "24365234375", + 4503599627370495.5); + testParse("4503599627370495.75", 4503599627370496.0); + testParse( + "4503599627370495.75000000000000000000000000000000000018807909613" + "1566001274997845955559308450986489083534003441400273004546761512" + "75634765625", + 4503599627370496.0); + testParse("4503599627370496", 4503599627370496.0); + testParse( + "4503599627370496.00000000000000000000000000000000000037615819226" + "3132002549995691911118616901972978167068006882800546009093523025" + "5126953125", + 4503599627370496.0); + testParse( + "4503599627370496.49999999999999999999999999999999999962384180773" + "6867997450004308088881383098027021832931993117199453990906476974" + "4873046875", + 4503599627370496.0); + testParse("4503599627370496.5", 4503599627370496.0); + testParse( + "4503599627370496.50000000000000000000000000000000000037615819226" + "3132002549995691911118616901972978167068006882800546009093523025" + "5126953125", + 4503599627370497.0); + testParse("9007199254740991", 9007199254740991.0); + testParse( + "9007199254740991.00000000000000000000000000000000000037615819226" + "3132002549995691911118616901972978167068006882800546009093523025" + "5126953125", + 9007199254740991.0); + testParse( + "9007199254740991.49999999999999999999999999999999999962384180773" + "6867997450004308088881383098027021832931993117199453990906476974" + "4873046875", + 9007199254740991.0); + testParse("9007199254740991.5", 9007199254740992.0); + testParse( + "9007199254740991.50000000000000000000000000000000000037615819226" + "3132002549995691911118616901972978167068006882800546009093523025" + "5126953125", + 9007199254740992.0); + testParse( + "1797693134862315708145274237317043567980705675258449965989174768" + "0315726078002853876058955863276687817154045895351438246423432132" + "6889464182768467546703537516986049910576551282076245490090389328" + "9440758685084551339423045832369032229481658085593321233482747978" + "26204144723168738177180919299881250404026184124858368", + 1.7976931348623157e+308); + testParse( + "1797693134862315708145274237317043567980705675258450041064343056" + "0785749075118623426984641994452647172104399563141377322686588394" + "6121172130178666127034918365540069095282013901258936156392632590" + "7055367751483602939820315058278058002847941584484775356682545657" + "44106770877499077221865536419145864291265781790932992", + 1.7976931348623157e+308); + testParse( + "1797693134862315807937289714053034150799341327100378194286569501" + "7574473832160705543739215666582761354682674973879349714831499292" + "8620232455220458908340124972127889717295245764493583188543574449" + "7703035690903649098158444443687202655781915109457910629727393062" + "50541739356374003666875082388828428992938306508423168", + 1.7976931348623157e+308); + testParse( + "1797693134862315807937289714053034150799341327100378269361737789" + "8044496829276475094664901797758720709633028641669288791094655554" + "7851940402630657488671505820681908902000708383676273854845817711" + "5317644757302700698555713669596228429148198608349364752927190741" + "68444365510704342711559699508093042880177904174497792", + double.INFINITY); + testParse( + "1797693134862315807937289714053034150799341327100378344436906077" + "8514519826392244645590587928934680064583382309459227867357811816" + "7083648350040856069002886669235928086706171002858964521148060973" + "2932253823701752298952982895505254202514482107240818876126988420" + "86346991665034681756244316627357656767417501840572416", + double.INFINITY); + + // Edge cases of algorithm (e+-22/23). + testParse("1e22", 1e22); + testParse("1e23", 1e23); + testParse("1e-22", 1e-22); + testParse("1e-23", 1e-23); + + testParseWhitespace("1", 1.0); + testParseWhitespace("1.0", 1.0); + testParseWhitespace("1e1", 10.0); + testParseWhitespace(".1e1", 1.0); + testParseWhitespace("1.e1", 10.0); + testParseWhitespace("1e+1", 10.0); + testParseWhitespace("1e-1", 0.1); + + // Negative tests - things not to allow. + + // Spaces inside the numeral. + testFail("- 1"); + testFail("+ 1"); + testFail("2 2"); + testFail("1 ."); + testFail(". 1"); + testFail("1e 2"); + testFail("1 e2"); + // Invalid characters. + testFail("0x0"); + testFail("0x1H"); + testFail("12H"); + testFail("1x2"); + testFail("00x2"); + testFail("0x2.2"); + // Double exponent without value. + testFail(".e1"); + testFail("e1"); + testFail("e+1"); + testFail("e-1"); + testFail("-e1"); + testFail("-e+1"); + testFail("-e-1"); + // Too many signs. + testFail("--1"); + testFail("-+1"); + testFail("+-1"); + testFail("++1"); + // Incorrect ways to write NaN/Infinity. + testFail("infinity"); + testFail("INFINITY"); + testFail("1.#INF"); + testFail("inf"); + testFail("nan"); + testFail("NAN"); + testFail("1.#IND"); + testFail("indef"); + testFail("qnan"); + testFail("snan"); +} diff --git a/tests/corelib/double_round2_test.dart b/tests/corelib/double_round2_test.dart new file mode 100644 index 00000000000..702a81f2f00 --- /dev/null +++ b/tests/corelib/double_round2_test.dart @@ -0,0 +1,12 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:expect/expect.dart'; + +main() { + Expect.throws(() => double.INFINITY.round(), (e) => e is UnsupportedError); + Expect.throws( + () => double.NEGATIVE_INFINITY.round(), (e) => e is UnsupportedError); + Expect.throws(() => double.NAN.round(), (e) => e is UnsupportedError); +} diff --git a/tests/corelib/double_round3_test.dart b/tests/corelib/double_round3_test.dart new file mode 100644 index 00000000000..a1edeeb77f3 --- /dev/null +++ b/tests/corelib/double_round3_test.dart @@ -0,0 +1,12 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:expect/expect.dart'; + +main() { + Expect.equals(0, 0.49999999999999994.round()); + Expect.equals(0, (-0.49999999999999994).round()); + Expect.isTrue(0.49999999999999994.round() is int); + Expect.isTrue((-0.49999999999999994).round() is int); +} diff --git a/tests/corelib/double_round4_test.dart b/tests/corelib/double_round4_test.dart new file mode 100644 index 00000000000..2b89dcc0fe2 --- /dev/null +++ b/tests/corelib/double_round4_test.dart @@ -0,0 +1,38 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:expect/expect.dart'; + +main() { + // The following numbers are on the border of 52 bits. + // For example: 4503599627370499 + 0.5 => 4503599627370500. + Expect.equals(4503599627370496, 4503599627370496.0.round()); + Expect.equals(4503599627370497, 4503599627370497.0.round()); + Expect.equals(4503599627370498, 4503599627370498.0.round()); + Expect.equals(4503599627370499, 4503599627370499.0.round()); + + Expect.equals(9007199254740991, 9007199254740991.0.round()); + Expect.equals(9007199254740992, 9007199254740992.0.round()); + + Expect.equals(-4503599627370496, (-4503599627370496.0).round()); + Expect.equals(-4503599627370497, (-4503599627370497.0).round()); + Expect.equals(-4503599627370498, (-4503599627370498.0).round()); + Expect.equals(-4503599627370499, (-4503599627370499.0).round()); + + Expect.equals(-9007199254740991, (-9007199254740991.0).round()); + Expect.equals(-9007199254740992, (-9007199254740992.0).round()); + + Expect.isTrue(4503599627370496.0.round() is int); + Expect.isTrue(4503599627370497.0.round() is int); + Expect.isTrue(4503599627370498.0.round() is int); + Expect.isTrue(4503599627370499.0.round() is int); + Expect.isTrue(9007199254740991.0.round() is int); + Expect.isTrue(9007199254740992.0.round() is int); + Expect.isTrue((-4503599627370496.0).round() is int); + Expect.isTrue((-4503599627370497.0).round() is int); + Expect.isTrue((-4503599627370498.0).round() is int); + Expect.isTrue((-4503599627370499.0).round() is int); + Expect.isTrue((-9007199254740991.0).round() is int); + Expect.isTrue((-9007199254740992.0).round() is int); +} diff --git a/tests/corelib/double_round_test.dart b/tests/corelib/double_round_test.dart new file mode 100644 index 00000000000..77f21fc254b --- /dev/null +++ b/tests/corelib/double_round_test.dart @@ -0,0 +1,54 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:expect/expect.dart'; + +main() { + Expect.equals(0, 0.0.round()); + Expect.equals(0, double.MIN_POSITIVE.round()); + Expect.equals(0, (2.0 * double.MIN_POSITIVE).round()); + Expect.equals(0, (1.18e-38).round()); + Expect.equals(0, (1.18e-38 * 2).round()); + Expect.equals(1, 0.5.round()); + Expect.equals(1, 0.9999999999999999.round()); + Expect.equals(1, 1.0.round()); + Expect.equals(1, 1.000000000000001.round()); + + Expect.equals( + 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368, + double.MAX_FINITE.round()); + + Expect.equals(0, (-double.MIN_POSITIVE).round()); + Expect.equals(0, (2.0 * -double.MIN_POSITIVE).round()); + Expect.equals(0, (-1.18e-38).round()); + Expect.equals(0, (-1.18e-38 * 2).round()); + Expect.equals(-1, (-0.5).round()); + Expect.equals(-1, (-0.9999999999999999).round()); + Expect.equals(-1, (-1.0).round()); + Expect.equals(-1, (-1.000000000000001).round()); + Expect.equals( + -179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368, + (-double.MAX_FINITE).round()); + + Expect.isTrue(0.0.round() is int); + Expect.isTrue(double.MIN_POSITIVE.round() is int); + Expect.isTrue((2.0 * double.MIN_POSITIVE).round() is int); + Expect.isTrue((1.18e-38).round() is int); + Expect.isTrue((1.18e-38 * 2).round() is int); + Expect.isTrue(0.5.round() is int); + Expect.isTrue(0.9999999999999999.round() is int); + Expect.isTrue(1.0.round() is int); + Expect.isTrue(1.000000000000001.round() is int); + Expect.isTrue(double.MAX_FINITE.round() is int); + + Expect.isTrue((-double.MIN_POSITIVE).round() is int); + Expect.isTrue((2.0 * -double.MIN_POSITIVE).round() is int); + Expect.isTrue((-1.18e-38).round() is int); + Expect.isTrue((-1.18e-38 * 2).round() is int); + Expect.isTrue((-0.5).round() is int); + Expect.isTrue((-0.9999999999999999).round() is int); + Expect.isTrue((-1.0).round() is int); + Expect.isTrue((-1.000000000000001).round() is int); + Expect.isTrue((-double.MAX_FINITE).round() is int); +} diff --git a/tests/corelib/double_round_to_double2_test.dart b/tests/corelib/double_round_to_double2_test.dart new file mode 100644 index 00000000000..ef8024db033 --- /dev/null +++ b/tests/corelib/double_round_to_double2_test.dart @@ -0,0 +1,13 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:expect/expect.dart'; + +main() { + Expect.equals(0.0, 0.49999999999999994.roundToDouble()); + Expect.equals(0.0, (-0.49999999999999994).roundToDouble()); + Expect.isTrue(0.49999999999999994.roundToDouble() is double); + Expect.isTrue((-0.49999999999999994).roundToDouble().isNegative); + Expect.isTrue((-0.49999999999999994).roundToDouble() is double); +} diff --git a/tests/corelib/double_round_to_double3_test.dart b/tests/corelib/double_round_to_double3_test.dart new file mode 100644 index 00000000000..c53ac8168b4 --- /dev/null +++ b/tests/corelib/double_round_to_double3_test.dart @@ -0,0 +1,34 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:expect/expect.dart'; + +main() { + // The following numbers are on the border of 52 bits. + // For example: 4503599627370499 + 0.5 => 4503599627370500. + Expect.equals(4503599627370496.0, 4503599627370496.0.roundToDouble()); + Expect.equals(4503599627370497.0, 4503599627370497.0.roundToDouble()); + Expect.equals(4503599627370498.0, 4503599627370498.0.roundToDouble()); + Expect.equals(4503599627370499.0, 4503599627370499.0.roundToDouble()); + Expect.equals(9007199254740991.0, 9007199254740991.0.roundToDouble()); + Expect.equals(9007199254740992.0, 9007199254740992.0.roundToDouble()); + Expect.equals(-4503599627370496.0, (-4503599627370496.0).roundToDouble()); + Expect.equals(-4503599627370497.0, (-4503599627370497.0).roundToDouble()); + Expect.equals(-4503599627370498.0, (-4503599627370498.0).roundToDouble()); + Expect.equals(-4503599627370499.0, (-4503599627370499.0).roundToDouble()); + Expect.equals(-9007199254740991.0, (-9007199254740991.0).roundToDouble()); + Expect.equals(-9007199254740992.0, (-9007199254740992.0).roundToDouble()); + Expect.isTrue(4503599627370496.0.roundToDouble() is double); + Expect.isTrue(4503599627370497.0.roundToDouble() is double); + Expect.isTrue(4503599627370498.0.roundToDouble() is double); + Expect.isTrue(4503599627370499.0.roundToDouble() is double); + Expect.isTrue(9007199254740991.0.roundToDouble() is double); + Expect.isTrue(9007199254740992.0.roundToDouble() is double); + Expect.isTrue((-4503599627370496.0).roundToDouble() is double); + Expect.isTrue((-4503599627370497.0).roundToDouble() is double); + Expect.isTrue((-4503599627370498.0).roundToDouble() is double); + Expect.isTrue((-4503599627370499.0).roundToDouble() is double); + Expect.isTrue((-9007199254740991.0).roundToDouble() is double); + Expect.isTrue((-9007199254740992.0).roundToDouble() is double); +} diff --git a/tests/corelib/double_round_to_double_test.dart b/tests/corelib/double_round_to_double_test.dart new file mode 100644 index 00000000000..ae2d196a6e8 --- /dev/null +++ b/tests/corelib/double_round_to_double_test.dart @@ -0,0 +1,62 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:expect/expect.dart'; + +main() { + Expect.equals(0.0, 0.0.roundToDouble()); + Expect.equals(0.0, double.MIN_POSITIVE.roundToDouble()); + Expect.equals(0.0, (2.0 * double.MIN_POSITIVE).roundToDouble()); + Expect.equals(0.0, (1.18e-38).roundToDouble()); + Expect.equals(0.0, (1.18e-38 * 2).roundToDouble()); + Expect.equals(1.0, 0.5.roundToDouble()); + Expect.equals(1.0, 0.9999999999999999.roundToDouble()); + Expect.equals(1.0, 1.0.roundToDouble()); + Expect.equals(1.0, 1.000000000000001.roundToDouble()); + Expect.equals(2.0, 1.5.roundToDouble()); + + Expect.equals(double.MAX_FINITE, double.MAX_FINITE.roundToDouble()); + + Expect.equals(0.0, (-double.MIN_POSITIVE).roundToDouble()); + Expect.equals(0.0, (2.0 * -double.MIN_POSITIVE).roundToDouble()); + Expect.equals(0.0, (-1.18e-38).roundToDouble()); + Expect.equals(0.0, (-1.18e-38 * 2).roundToDouble()); + Expect.equals(-1.0, (-0.5).roundToDouble()); + Expect.equals(-1.0, (-0.9999999999999999).roundToDouble()); + Expect.equals(-1.0, (-1.0).roundToDouble()); + Expect.equals(-1.0, (-1.000000000000001).roundToDouble()); + Expect.equals(-2.0, (-1.5).roundToDouble()); + Expect.equals(-double.MAX_FINITE, (-double.MAX_FINITE).roundToDouble()); + + Expect.equals(double.INFINITY, double.INFINITY.roundToDouble()); + Expect.equals( + double.NEGATIVE_INFINITY, double.NEGATIVE_INFINITY.roundToDouble()); + Expect.isTrue(double.NAN.roundToDouble().isNaN); + + Expect.isTrue(0.0.roundToDouble() is double); + Expect.isTrue(double.MIN_POSITIVE.roundToDouble() is double); + Expect.isTrue((2.0 * double.MIN_POSITIVE).roundToDouble() is double); + Expect.isTrue((1.18e-38).roundToDouble() is double); + Expect.isTrue((1.18e-38 * 2).roundToDouble() is double); + Expect.isTrue(0.5.roundToDouble() is double); + Expect.isTrue(0.9999999999999999.roundToDouble() is double); + Expect.isTrue(1.0.roundToDouble() is double); + Expect.isTrue(1.000000000000001.roundToDouble() is double); + Expect.isTrue(double.MAX_FINITE.roundToDouble() is double); + + Expect.isTrue((-double.MIN_POSITIVE).roundToDouble().isNegative); + Expect.isTrue((2.0 * -double.MIN_POSITIVE).roundToDouble().isNegative); + Expect.isTrue((-1.18e-38).roundToDouble().isNegative); + Expect.isTrue((-1.18e-38 * 2).roundToDouble().isNegative); + + Expect.isTrue((-double.MIN_POSITIVE).roundToDouble() is double); + Expect.isTrue((2.0 * -double.MIN_POSITIVE).roundToDouble() is double); + Expect.isTrue((-1.18e-38).roundToDouble() is double); + Expect.isTrue((-1.18e-38 * 2).roundToDouble() is double); + Expect.isTrue((-0.5).roundToDouble() is double); + Expect.isTrue((-0.9999999999999999).roundToDouble() is double); + Expect.isTrue((-1.0).roundToDouble() is double); + Expect.isTrue((-1.000000000000001).roundToDouble() is double); + Expect.isTrue((-double.MAX_FINITE).roundToDouble() is double); +} diff --git a/tests/corelib/double_truncate2_test.dart b/tests/corelib/double_truncate2_test.dart new file mode 100644 index 00000000000..633debd61a4 --- /dev/null +++ b/tests/corelib/double_truncate2_test.dart @@ -0,0 +1,12 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:expect/expect.dart'; + +main() { + Expect.throws(() => double.INFINITY.truncate(), (e) => e is UnsupportedError); + Expect.throws( + () => double.NEGATIVE_INFINITY.truncate(), (e) => e is UnsupportedError); + Expect.throws(() => double.NAN.truncate(), (e) => e is UnsupportedError); +} diff --git a/tests/corelib/double_truncate_test.dart b/tests/corelib/double_truncate_test.dart new file mode 100644 index 00000000000..8c6a322916f --- /dev/null +++ b/tests/corelib/double_truncate_test.dart @@ -0,0 +1,92 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:expect/expect.dart'; + +main() { + Expect.equals(0, 0.0.truncate()); + Expect.equals(0, double.MIN_POSITIVE.truncate()); + Expect.equals(0, (2.0 * double.MIN_POSITIVE).truncate()); + Expect.equals(0, (1.18e-38).truncate()); + Expect.equals(0, (1.18e-38 * 2).truncate()); + Expect.equals(0, 0.49999999999999994.truncate()); + Expect.equals(0, 0.5.truncate()); + Expect.equals(0, 0.9999999999999999.truncate()); + Expect.equals(1, 1.0.truncate()); + Expect.equals(1, 1.000000000000001.truncate()); + // The following numbers are on the border of 52 bits. + // For example: 4503599627370499 + 0.5 => 4503599627370500. + Expect.equals(4503599627370496, 4503599627370496.0.truncate()); + Expect.equals(4503599627370497, 4503599627370497.0.truncate()); + Expect.equals(4503599627370498, 4503599627370498.0.truncate()); + Expect.equals(4503599627370499, 4503599627370499.0.truncate()); + + Expect.equals(9007199254740991, 9007199254740991.0.truncate()); + Expect.equals(9007199254740992, 9007199254740992.0.truncate()); + Expect.equals( + 179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368, + double.MAX_FINITE.truncate()); + + Expect.equals(0, (-double.MIN_POSITIVE).truncate()); + Expect.equals(0, (2.0 * -double.MIN_POSITIVE).truncate()); + Expect.equals(0, (-1.18e-38).truncate()); + Expect.equals(0, (-1.18e-38 * 2).truncate()); + Expect.equals(0, (-0.49999999999999994).truncate()); + Expect.equals(0, (-0.5).truncate()); + Expect.equals(0, (-0.9999999999999999).truncate()); + Expect.equals(-1, (-1.0).truncate()); + Expect.equals(-1, (-1.000000000000001).truncate()); + Expect.equals(-4503599627370496, (-4503599627370496.0).truncate()); + Expect.equals(-4503599627370497, (-4503599627370497.0).truncate()); + Expect.equals(-4503599627370498, (-4503599627370498.0).truncate()); + Expect.equals(-4503599627370499, (-4503599627370499.0).truncate()); + Expect.equals(-9007199254740991, (-9007199254740991.0).truncate()); + Expect.equals(-9007199254740992, (-9007199254740992.0).truncate()); + Expect.equals( + -179769313486231570814527423731704356798070567525844996598917476803157260780028538760589558632766878171540458953514382464234321326889464182768467546703537516986049910576551282076245490090389328944075868508455133942304583236903222948165808559332123348274797826204144723168738177180919299881250404026184124858368, + (-double.MAX_FINITE).truncate()); + + Expect.isTrue(0.0.truncate() is int); + Expect.isTrue(double.MIN_POSITIVE.truncate() is int); + Expect.isTrue((2.0 * double.MIN_POSITIVE).truncate() is int); + Expect.isTrue((1.18e-38).truncate() is int); + Expect.isTrue((1.18e-38 * 2).truncate() is int); + Expect.isTrue(0.49999999999999994.truncate() is int); + Expect.isTrue(0.5.truncate() is int); + Expect.isTrue(0.9999999999999999.truncate() is int); + Expect.isTrue(1.0.truncate() is int); + Expect.isTrue(1.000000000000001.truncate() is int); + Expect.isTrue(4503599627370496.0.truncate() is int); + Expect.isTrue(4503599627370497.0.truncate() is int); + Expect.isTrue(4503599627370498.0.truncate() is int); + Expect.isTrue(4503599627370499.0.truncate() is int); + Expect.isTrue(9007199254740991.0.truncate() is int); + Expect.isTrue(9007199254740992.0.truncate() is int); + Expect.isTrue(double.MAX_FINITE.truncate() is int); + + Expect.isTrue((-double.MIN_POSITIVE).truncateToDouble().isNegative); + Expect.isTrue((2.0 * -double.MIN_POSITIVE).truncateToDouble().isNegative); + Expect.isTrue((-1.18e-38).truncateToDouble().isNegative); + Expect.isTrue((-1.18e-38 * 2).truncateToDouble().isNegative); + Expect.isTrue((-0.49999999999999994).truncateToDouble().isNegative); + Expect.isTrue((-0.5).truncateToDouble().isNegative); + Expect.isTrue((-0.9999999999999999).truncateToDouble().isNegative); + + Expect.isTrue((-double.MIN_POSITIVE).truncate() is int); + Expect.isTrue((2.0 * -double.MIN_POSITIVE).truncate() is int); + Expect.isTrue((-1.18e-38).truncate() is int); + Expect.isTrue((-1.18e-38 * 2).truncate() is int); + Expect.isTrue((-0.49999999999999994).truncate() is int); + Expect.isTrue((-0.5).truncate() is int); + Expect.isTrue((-0.9999999999999999).truncate() is int); + Expect.isTrue((-1.0).truncate() is int); + Expect.isTrue((-1.000000000000001).truncate() is int); + Expect.isTrue((-4503599627370496.0).truncate() is int); + Expect.isTrue((-4503599627370497.0).truncate() is int); + Expect.isTrue((-4503599627370498.0).truncate() is int); + Expect.isTrue((-4503599627370499.0).truncate() is int); + Expect.isTrue((-9007199254740991.0).truncate() is int); + Expect.isTrue((-9007199254740992.0).truncate() is int); + Expect.isTrue((-double.MAX_FINITE).truncate() is int); +} diff --git a/tests/corelib/double_truncate_to_double_test.dart b/tests/corelib/double_truncate_to_double_test.dart new file mode 100644 index 00000000000..ebfc8bbef0d --- /dev/null +++ b/tests/corelib/double_truncate_to_double_test.dart @@ -0,0 +1,85 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:expect/expect.dart'; + +main() { + Expect.equals(0.0, 0.0.truncateToDouble()); + Expect.equals(0.0, double.MIN_POSITIVE.truncateToDouble()); + Expect.equals(0.0, (2.0 * double.MIN_POSITIVE).truncateToDouble()); + Expect.equals(0.0, (1.18e-38).truncateToDouble()); + Expect.equals(0.0, (1.18e-38 * 2).truncateToDouble()); + Expect.equals(0.0, 0.49999999999999994.truncateToDouble()); + Expect.equals(0.0, 0.5.truncateToDouble()); + Expect.equals(0.0, 0.9999999999999999.truncateToDouble()); + Expect.equals(1.0, 1.0.truncateToDouble()); + Expect.equals(1.0, 1.000000000000001.truncateToDouble()); + // The following numbers are on the border of 52 bits. + // For example: 4503599627370499 + 0.5 => 4503599627370500. + Expect.equals(4503599627370496.0, 4503599627370496.0.truncateToDouble()); + Expect.equals(4503599627370497.0, 4503599627370497.0.truncateToDouble()); + Expect.equals(4503599627370498.0, 4503599627370498.0.truncateToDouble()); + Expect.equals(4503599627370499.0, 4503599627370499.0.truncateToDouble()); + + Expect.equals(9007199254740991.0, 9007199254740991.0.truncateToDouble()); + Expect.equals(9007199254740992.0, 9007199254740992.0.truncateToDouble()); + Expect.equals(double.MAX_FINITE, double.MAX_FINITE.truncateToDouble()); + + Expect.equals(0.0, (-double.MIN_POSITIVE).truncateToDouble()); + Expect.equals(0.0, (2.0 * -double.MIN_POSITIVE).truncateToDouble()); + Expect.equals(0.0, (-1.18e-38).truncateToDouble()); + Expect.equals(0.0, (-1.18e-38 * 2).truncateToDouble()); + Expect.equals(0.0, (-0.49999999999999994).truncateToDouble()); + Expect.equals(0.0, (-0.5).truncateToDouble()); + Expect.equals(0.0, (-0.9999999999999999).truncateToDouble()); + Expect.equals(-1.0, (-1.0).truncateToDouble()); + Expect.equals(-1.0, (-1.000000000000001).truncateToDouble()); + Expect.equals(-4503599627370496.0, (-4503599627370496.0).truncateToDouble()); + Expect.equals(-4503599627370497.0, (-4503599627370497.0).truncateToDouble()); + Expect.equals(-4503599627370498.0, (-4503599627370498.0).truncateToDouble()); + Expect.equals(-4503599627370499.0, (-4503599627370499.0).truncateToDouble()); + Expect.equals(-9007199254740991.0, (-9007199254740991.0).truncateToDouble()); + Expect.equals(-9007199254740992.0, (-9007199254740992.0).truncateToDouble()); + Expect.equals(-double.MAX_FINITE, (-double.MAX_FINITE).truncateToDouble()); + + Expect.equals(double.INFINITY, double.INFINITY.truncateToDouble()); + Expect.equals( + double.NEGATIVE_INFINITY, double.NEGATIVE_INFINITY.truncateToDouble()); + Expect.isTrue(double.NAN.truncateToDouble().isNaN); + + Expect.isTrue(0.0.truncateToDouble() is double); + Expect.isTrue(double.MIN_POSITIVE.truncateToDouble() is double); + Expect.isTrue((2.0 * double.MIN_POSITIVE).truncateToDouble() is double); + Expect.isTrue((1.18e-38).truncateToDouble() is double); + Expect.isTrue((1.18e-38 * 2).truncateToDouble() is double); + Expect.isTrue(0.49999999999999994.truncateToDouble() is double); + Expect.isTrue(0.5.truncateToDouble() is double); + Expect.isTrue(0.9999999999999999.truncateToDouble() is double); + Expect.isTrue(1.0.truncateToDouble() is double); + Expect.isTrue(1.000000000000001.truncateToDouble() is double); + Expect.isTrue(4503599627370496.0.truncateToDouble() is double); + Expect.isTrue(4503599627370497.0.truncateToDouble() is double); + Expect.isTrue(4503599627370498.0.truncateToDouble() is double); + Expect.isTrue(4503599627370499.0.truncateToDouble() is double); + Expect.isTrue(9007199254740991.0.truncateToDouble() is double); + Expect.isTrue(9007199254740992.0.truncateToDouble() is double); + Expect.isTrue(double.MAX_FINITE.truncateToDouble() is double); + + Expect.isTrue((-double.MIN_POSITIVE).truncateToDouble() is double); + Expect.isTrue((2.0 * -double.MIN_POSITIVE).truncateToDouble() is double); + Expect.isTrue((-1.18e-38).truncateToDouble() is double); + Expect.isTrue((-1.18e-38 * 2).truncateToDouble() is double); + Expect.isTrue((-0.49999999999999994).truncateToDouble() is double); + Expect.isTrue((-0.5).truncateToDouble() is double); + Expect.isTrue((-0.9999999999999999).truncateToDouble() is double); + Expect.isTrue((-1.0).truncateToDouble() is double); + Expect.isTrue((-1.000000000000001).truncateToDouble() is double); + Expect.isTrue((-4503599627370496.0).truncateToDouble() is double); + Expect.isTrue((-4503599627370497.0).truncateToDouble() is double); + Expect.isTrue((-4503599627370498.0).truncateToDouble() is double); + Expect.isTrue((-4503599627370499.0).truncateToDouble() is double); + Expect.isTrue((-9007199254740991.0).truncateToDouble() is double); + Expect.isTrue((-9007199254740992.0).truncateToDouble() is double); + Expect.isTrue((-double.MAX_FINITE).truncateToDouble() is double); +} diff --git a/tests/corelib/duration2_test.dart b/tests/corelib/duration2_test.dart new file mode 100644 index 00000000000..7bfebb09b7a --- /dev/null +++ b/tests/corelib/duration2_test.dart @@ -0,0 +1,27 @@ +// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + // If the duration class multiplies "str" * microseconds-per-day (instead of + // (microseconds-per-day * "str") it will try to build up a huge string and + // terminate with an out-of-memory exception instead of an ArgumentError or + // TypeError. + // See dartbug.com/22309 + + String longString = "str" * 1000; + Expect.throws(() => new Duration(days: longString), + (e) => e is ArgumentError || e is TypeError || e is NoSuchMethodError); + Expect.throws(() => new Duration(hours: longString), + (e) => e is ArgumentError || e is TypeError || e is NoSuchMethodError); + Expect.throws(() => new Duration(minutes: longString), + (e) => e is ArgumentError || e is TypeError || e is NoSuchMethodError); + Expect.throws(() => new Duration(seconds: longString), + (e) => e is ArgumentError || e is TypeError || e is NoSuchMethodError); + Expect.throws(() => new Duration(milliseconds: longString), + (e) => e is ArgumentError || e is TypeError || e is NoSuchMethodError); + Expect.throws(() => new Duration(microseconds: longString), + (e) => e is ArgumentError || e is TypeError || e is NoSuchMethodError); +} diff --git a/tests/corelib/duration_big_num_test.dart b/tests/corelib/duration_big_num_test.dart new file mode 100644 index 00000000000..154afb90734 --- /dev/null +++ b/tests/corelib/duration_big_num_test.dart @@ -0,0 +1,21 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; +import 'dart:math'; + +main() { + Duration d, d1; + + d1 = new Duration(microseconds: pow(2, 53)); + d = d1 * 2; + Expect.equals(pow(2, 54), d.inMicroseconds); + d = d1 * 1.5; + Expect.equals(pow(2, 53).toDouble() * 1.5, d.inMicroseconds); + Expect.isTrue(d.inMicroseconds is int); + + // Test that we lose precision when multiplying with a double. + d = new Duration(microseconds: pow(2, 53) + 1) * 1.0; + Expect.equals(0, d.inMicroseconds % 2); +} diff --git a/tests/corelib/duration_double_multiplication_test.dart b/tests/corelib/duration_double_multiplication_test.dart new file mode 100644 index 00000000000..415067cbfb2 --- /dev/null +++ b/tests/corelib/duration_double_multiplication_test.dart @@ -0,0 +1,19 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + Duration d, d1; + + d1 = new Duration(milliseconds: 1); + d = d1 * 0.005; + Expect.equals(1000 * 0.005, d.inMicroseconds); + d = d1 * 0.0; + Expect.equals(0, d.inMicroseconds); + d = d1 * -0.005; + Expect.equals(1000 * -0.005, d.inMicroseconds); + d = d1 * 0.0015; + Expect.equals((1000 * 0.0015).round(), d.inMicroseconds); +} diff --git a/tests/corelib/duration_test.dart b/tests/corelib/duration_test.dart new file mode 100644 index 00000000000..842f4b05d70 --- /dev/null +++ b/tests/corelib/duration_test.dart @@ -0,0 +1,293 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + Duration d; + d = new Duration(days: 1); + Expect.equals(86400000000, d.inMicroseconds); + Expect.equals(86400000, d.inMilliseconds); + Expect.equals(86400, d.inSeconds); + Expect.equals(1440, d.inMinutes); + Expect.equals(24, d.inHours); + Expect.equals(1, d.inDays); + d = const Duration(hours: 1); + Expect.equals(3600000000, d.inMicroseconds); + Expect.equals(3600000, d.inMilliseconds); + Expect.equals(3600, d.inSeconds); + Expect.equals(60, d.inMinutes); + Expect.equals(1, d.inHours); + Expect.equals(0, d.inDays); + d = new Duration(minutes: 1); + Expect.equals(60000000, d.inMicroseconds); + Expect.equals(60000, d.inMilliseconds); + Expect.equals(60, d.inSeconds); + Expect.equals(1, d.inMinutes); + Expect.equals(0, d.inHours); + Expect.equals(0, d.inDays); + d = const Duration(seconds: 1); + Expect.equals(1000000, d.inMicroseconds); + Expect.equals(1000, d.inMilliseconds); + Expect.equals(1, d.inSeconds); + Expect.equals(0, d.inMinutes); + Expect.equals(0, d.inHours); + Expect.equals(0, d.inDays); + d = new Duration(milliseconds: 1); + Expect.equals(1000, d.inMicroseconds); + Expect.equals(1, d.inMilliseconds); + Expect.equals(0, d.inSeconds); + Expect.equals(0, d.inMinutes); + Expect.equals(0, d.inHours); + Expect.equals(0, d.inDays); + d = new Duration(microseconds: 1); + Expect.equals(1, d.inMicroseconds); + Expect.equals(0, d.inMilliseconds); + Expect.equals(0, d.inSeconds); + Expect.equals(0, d.inMinutes); + Expect.equals(0, d.inHours); + Expect.equals(0, d.inDays); + + d = const Duration(milliseconds: 1, microseconds: 999); + Expect.equals(1999, d.inMicroseconds); + Expect.equals(1, d.inMilliseconds); + d = const Duration(seconds: 1, milliseconds: 999); + Expect.equals(1999, d.inMilliseconds); + Expect.equals(1, d.inSeconds); + d = new Duration(minutes: 1, seconds: 59); + Expect.equals(119, d.inSeconds); + Expect.equals(1, d.inMinutes); + d = const Duration(hours: 1, minutes: 59); + Expect.equals(119, d.inMinutes); + Expect.equals(1, d.inHours); + d = new Duration(days: 1, hours: 23); + Expect.equals(47, d.inHours); + Expect.equals(1, d.inDays); + d = const Duration( + days: 0, + hours: 23, + minutes: 59, + seconds: 59, + milliseconds: 999, + microseconds: 999); + Expect.equals(0, d.inDays); + + d = new Duration(days: -1); + Expect.equals(-86400000000, d.inMicroseconds); + Expect.equals(-86400000, d.inMilliseconds); + Expect.equals(-86400, d.inSeconds); + Expect.equals(-1440, d.inMinutes); + Expect.equals(-24, d.inHours); + Expect.equals(-1, d.inDays); + d = const Duration(hours: -1); + Expect.equals(-3600000000, d.inMicroseconds); + Expect.equals(-3600000, d.inMilliseconds); + Expect.equals(-3600, d.inSeconds); + Expect.equals(-60, d.inMinutes); + Expect.equals(-1, d.inHours); + Expect.equals(0, d.inDays); + d = new Duration(minutes: -1); + Expect.equals(-60000000, d.inMicroseconds); + Expect.equals(-60000, d.inMilliseconds); + Expect.equals(-60, d.inSeconds); + Expect.equals(-1, d.inMinutes); + Expect.equals(0, d.inHours); + Expect.equals(0, d.inDays); + d = const Duration(seconds: -1); + Expect.equals(-1000000, d.inMicroseconds); + Expect.equals(-1000, d.inMilliseconds); + Expect.equals(-1, d.inSeconds); + Expect.equals(0, d.inMinutes); + Expect.equals(0, d.inHours); + Expect.equals(0, d.inDays); + d = new Duration(milliseconds: -1); + Expect.equals(-1000, d.inMicroseconds); + Expect.equals(-1, d.inMilliseconds); + Expect.equals(0, d.inSeconds); + Expect.equals(0, d.inMinutes); + Expect.equals(0, d.inHours); + Expect.equals(0, d.inDays); + d = new Duration(microseconds: -1); + Expect.equals(-1, d.inMicroseconds); + Expect.equals(0, d.inMilliseconds); + Expect.equals(0, d.inSeconds); + Expect.equals(0, d.inMinutes); + Expect.equals(0, d.inHours); + Expect.equals(0, d.inDays); + + d = const Duration(days: 1, hours: -24); + Expect.equals(0, d.inMicroseconds); + d = new Duration(hours: 1, minutes: -60); + Expect.equals(0, d.inMicroseconds); + d = const Duration(minutes: 1, seconds: -60); + Expect.equals(0, d.inMicroseconds); + d = new Duration(seconds: 1, milliseconds: -1000); + Expect.equals(0, d.inMicroseconds); + d = new Duration(milliseconds: 1, microseconds: -1000); + Expect.equals(0, d.inMicroseconds); + + d = const Duration(hours: 25); + Expect.equals(1, d.inDays); + Expect.equals(25, d.inHours); + Expect.equals(1500, d.inMinutes); + Expect.equals(90000, d.inSeconds); + Expect.equals(90000000, d.inMilliseconds); + Expect.equals(90000000000, d.inMicroseconds); + d = new Duration(minutes: 61); + Expect.equals(0, d.inDays); + Expect.equals(1, d.inHours); + Expect.equals(61, d.inMinutes); + Expect.equals(3660, d.inSeconds); + Expect.equals(3660000, d.inMilliseconds); + Expect.equals(3660000000, d.inMicroseconds); + d = const Duration(seconds: 61); + Expect.equals(0, d.inDays); + Expect.equals(0, d.inHours); + Expect.equals(1, d.inMinutes); + Expect.equals(61, d.inSeconds); + Expect.equals(61000, d.inMilliseconds); + Expect.equals(61000000, d.inMicroseconds); + d = new Duration(milliseconds: 1001); + Expect.equals(0, d.inDays); + Expect.equals(0, d.inHours); + Expect.equals(0, d.inMinutes); + Expect.equals(1, d.inSeconds); + Expect.equals(1001, d.inMilliseconds); + Expect.equals(1001000, d.inMicroseconds); + d = new Duration(microseconds: 1001); + Expect.equals(0, d.inDays); + Expect.equals(0, d.inHours); + Expect.equals(0, d.inMinutes); + Expect.equals(0, d.inSeconds); + Expect.equals(1, d.inMilliseconds); + Expect.equals(1001, d.inMicroseconds); + + var d1 = const Duration(milliseconds: 1000); + var d2 = const Duration(seconds: 1); + Expect.identical(d1, d2); + + d1 = const Duration(microseconds: 1000); + d2 = const Duration(milliseconds: 1); + Expect.identical(d1, d2); + + d1 = new Duration(hours: 1); + d2 = new Duration(hours: -1); + d = d1 + d2; + Expect.equals(0, d.inMicroseconds); + d = d1 - d2; + Expect.equals(3600000000 * 2, d.inMicroseconds); + + d2 = new Duration(hours: 1); + d = d1 + d2; + Expect.equals(3600000000 * 2, d.inMicroseconds); + d = d1 - d2; + Expect.equals(0, d.inMicroseconds); + + d = d1 * 2; + Expect.equals(3600000000 * 2, d.inMicroseconds); + d = d1 * -1; + Expect.equals(-3600000000, d.inMicroseconds); + d = d1 * 0; + Expect.equals(0, d.inMicroseconds); + + d = d1 ~/ 2; + Expect.equals(1800000000, d.inMicroseconds); + d = d1 ~/ 3600000001; + Expect.equals(0, d.inMicroseconds); + d = d1 ~/ -3600000001; + Expect.equals(0, d.inMicroseconds); + d = d1 ~/ 3599999999; + Expect.equals(1, d.inMicroseconds); + d = d1 ~/ -3599999999; + Expect.equals(-1, d.inMicroseconds); + d = d1 ~/ -1; + Expect.equals(-3600000000, d.inMicroseconds); + d = d1 * 0; + Expect.equals(0, d.inMicroseconds); + Expect.throws(() => d1 ~/ 0, (e) => e is IntegerDivisionByZeroException); + + d = new Duration(microseconds: 0); + Expect.isTrue(d < new Duration(microseconds: 1)); + Expect.isTrue(d <= new Duration(microseconds: 1)); + Expect.isTrue(d <= d); + Expect.isTrue(d > new Duration(microseconds: -1)); + Expect.isTrue(d >= new Duration(microseconds: -1)); + Expect.isTrue(d >= d); + + d = const Duration( + days: 1, + hours: 3, + minutes: 17, + seconds: 42, + milliseconds: 823, + microseconds: 127); + Expect.equals("27:17:42.823127", d.toString()); + + d = const Duration(hours: 1999, minutes: 17, seconds: 42); + Expect.equals("1999:17:42.000000", d.toString()); + + d = const Duration( + days: -1, + hours: -3, + minutes: -17, + seconds: -42, + milliseconds: -823, + microseconds: -127); + Expect.equals("-27:17:42.823127", d.toString()); + + d = const Duration(hours: -1999, minutes: -17, seconds: -42); + Expect.equals("-1999:17:42.000000", d.toString()); + + // Edge conditions for toString of microseconds. + // Regression test for http://dartbug.com/15678 + + d = const Duration(microseconds: 1); + Expect.equals("0:00:00.000001", d.toString()); + + d = const Duration(microseconds: 9); + Expect.equals("0:00:00.000009", d.toString()); + + d = const Duration(microseconds: 10); + Expect.equals("0:00:00.000010", d.toString()); + + d = const Duration(microseconds: 99); + Expect.equals("0:00:00.000099", d.toString()); + + d = const Duration(microseconds: 100); + Expect.equals("0:00:00.000100", d.toString()); + + d = const Duration(microseconds: 999); + Expect.equals("0:00:00.000999", d.toString()); + + d = const Duration(microseconds: 1000); + Expect.equals("0:00:00.001000", d.toString()); + + d = const Duration(microseconds: 9999); + Expect.equals("0:00:00.009999", d.toString()); + + d = const Duration(microseconds: 10000); + Expect.equals("0:00:00.010000", d.toString()); + + d = const Duration(microseconds: 99999); + Expect.equals("0:00:00.099999", d.toString()); + + d = const Duration(microseconds: 100000); + Expect.equals("0:00:00.100000", d.toString()); + + d = const Duration(microseconds: 999999); + Expect.equals("0:00:00.999999", d.toString()); + + d = const Duration(microseconds: 1000000); + Expect.equals("0:00:01.000000", d.toString()); + + d1 = const Duration(hours: 1); + d2 = const Duration(hours: -1); + Expect.isFalse(d1.isNegative); + Expect.isTrue(d2.isNegative); + Expect.equals(d1, d1.abs()); + Expect.equals(d1, d2.abs()); + + Expect.equals(d2, -d1); + Expect.equals(d1, -d2); +} diff --git a/tests/corelib/error_stack_trace1_test.dart b/tests/corelib/error_stack_trace1_test.dart new file mode 100644 index 00000000000..53df6717348 --- /dev/null +++ b/tests/corelib/error_stack_trace1_test.dart @@ -0,0 +1,40 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +class A { + static Aa() => Ab(); + static Ab() => Ac(); + static Ac() => throw "abc"; +} + +class B { + static Ba() => Bb(); + static Bb() => Bc(); + static Bc() { + try { + A.Aa(); + } catch (e) { + // This should produce a NoSuchMethodError. + var trace = e.stackTrace; + } + } +} + +main() { + bool hasThrown = false; + try { + B.Ba(); + } catch (e) { + hasThrown = true; + var trace = e.stackTrace.toString(); + print(trace); + Expect.isTrue(trace.contains("Bc")); + Expect.isTrue(trace.contains("Bb")); + Expect.isTrue(trace.contains("Ba")); + Expect.isTrue(trace.contains("main")); + } + Expect.isTrue(hasThrown); +} diff --git a/tests/corelib/error_stack_trace2_test.dart b/tests/corelib/error_stack_trace2_test.dart new file mode 100644 index 00000000000..24c03050ddb --- /dev/null +++ b/tests/corelib/error_stack_trace2_test.dart @@ -0,0 +1,29 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +class A { + get foo => cyclicStatic; +} + +var a = new A(); +var cyclicStatic = (() => a.foo + 1)(); + +cyclicInitialization() { + return cyclicStatic; +} + +main() { + bool hasThrown = false; + try { + cyclicStatic + 1; + } catch (e2) { + var e = e2; + hasThrown = true; + Expect.isTrue( + e.stackTrace is StackTrace, "$e doesn't have a non-null stack trace"); + } + Expect.isTrue(hasThrown); +} diff --git a/tests/corelib/error_stack_trace_test.dart b/tests/corelib/error_stack_trace_test.dart new file mode 100644 index 00000000000..6851f7b904c --- /dev/null +++ b/tests/corelib/error_stack_trace_test.dart @@ -0,0 +1,83 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +void argument() { + throw new ArgumentError(499); +} + +void noSuchMethod() { + (499).doesNotExist(); +} + +void nullThrown() { + throw null; +} + +void range() { + throw new RangeError.range(0, 1, 2); +} + +void fallThrough() { + nested() {} + + switch (5) { + case 5: + nested(); + default: + Expect.fail("Should not reach"); + } +} + +abstract class A { + foo(); +} + +void abstractClassInstantiation() { + new A(); +} + +void unsupported() { + throw new UnsupportedError("unsupported"); +} + +void unimplemented() { + throw new UnimplementedError("unimplemented"); +} + +void state() { + return [1, 2].single; +} + +void type() { + return 1 + "string"; +} + +main() { + List errorFunctions = [ + argument, + noSuchMethod, + nullThrown, + range, + fallThrough, + abstractClassInstantiation, + unsupported, + unimplemented, + state, + type + ]; + + for (var f in errorFunctions) { + bool hasThrown = false; + try { + f(); + } catch (e) { + hasThrown = true; + Expect.isTrue( + e.stackTrace is StackTrace, "$e doesn't have a non-null stack trace"); + } + Expect.isTrue(hasThrown); + } +} diff --git a/tests/corelib/errors_test.dart b/tests/corelib/errors_test.dart new file mode 100644 index 00000000000..763b4863e70 --- /dev/null +++ b/tests/corelib/errors_test.dart @@ -0,0 +1,77 @@ +// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +// Test that error constructors do what they are documented as doing. + +main() { + Expect.equals("Invalid argument(s)", new ArgumentError().toString()); + Expect.equals( + "Invalid argument(s): message", new ArgumentError("message").toString()); + Expect.equals( + "Invalid argument: null", new ArgumentError.value(null).toString()); + Expect.equals("Invalid argument: 42", new ArgumentError.value(42).toString()); + Expect.equals( + "Invalid argument: \"bad\"", new ArgumentError.value("bad").toString()); + Expect.equals("Invalid argument (foo): null", + new ArgumentError.value(null, "foo").toString()); + Expect.equals("Invalid argument (foo): 42", + new ArgumentError.value(42, "foo").toString()); + Expect.equals("Invalid argument (foo): message: 42", + new ArgumentError.value(42, "foo", "message").toString()); + Expect.equals("Invalid argument: message: 42", + new ArgumentError.value(42, null, "message").toString()); + Expect.equals("Invalid argument(s): Must not be null", + new ArgumentError.notNull().toString()); + Expect.equals("Invalid argument(s) (foo): Must not be null", + new ArgumentError.notNull("foo").toString()); + + Expect.equals("RangeError", new RangeError(null).toString()); + Expect.equals("RangeError: message", new RangeError("message").toString()); + Expect.equals("RangeError: Value not in range: 42", + new RangeError.value(42).toString()); + Expect.equals("RangeError (foo): Value not in range: 42", + new RangeError.value(42, "foo").toString()); + Expect.equals("RangeError (foo): message: 42", + new RangeError.value(42, "foo", "message").toString()); + Expect.equals("RangeError: message: 42", + new RangeError.value(42, null, "message").toString()); + + Expect.equals("RangeError: Invalid value: Not in range 2..9, inclusive: 42", + new RangeError.range(42, 2, 9).toString()); + Expect.equals( + "RangeError (foo): Invalid value: Not in range 2..9, " + "inclusive: 42", + new RangeError.range(42, 2, 9, "foo").toString()); + Expect.equals("RangeError (foo): message: Not in range 2..9, inclusive: 42", + new RangeError.range(42, 2, 9, "foo", "message").toString()); + Expect.equals("RangeError: message: Not in range 2..9, inclusive: 42", + new RangeError.range(42, 2, 9, null, "message").toString()); + + Expect.equals( + "RangeError: Index out of range: " + "index should be less than 3: 42", + new RangeError.index(42, [1, 2, 3]).toString()); + Expect.equals( + "RangeError (foo): Index out of range: " + "index should be less than 3: 42", + new RangeError.index(42, [1, 2, 3], "foo").toString()); + Expect.equals( + "RangeError (foo): message: " + "index should be less than 3: 42", + new RangeError.index(42, [1, 2, 3], "foo", "message").toString()); + Expect.equals( + "RangeError: message: " + "index should be less than 3: 42", + new RangeError.index(42, [1, 2, 3], null, "message").toString()); + Expect.equals( + "RangeError (foo): message: " + "index should be less than 2: 42", + new RangeError.index(42, [1, 2, 3], "foo", "message", 2).toString()); + Expect.equals( + "RangeError: Index out of range: " + "index must not be negative: -5", + new RangeError.index(-5, [1, 2, 3]).toString()); +} diff --git a/tests/corelib/exception_implementation_test.dart b/tests/corelib/exception_implementation_test.dart new file mode 100644 index 00000000000..0744f50ef68 --- /dev/null +++ b/tests/corelib/exception_implementation_test.dart @@ -0,0 +1,18 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +library exception_implementation_test; + +import "package:expect/expect.dart"; + +main() { + final msg = 1; + try { + throw new Exception(msg); + Expect.fail("Unreachable"); + } on Exception catch (e) { + Expect.isTrue(e is Exception); + Expect.equals("Exception: $msg", e.toString()); + } +} diff --git a/tests/corelib/expando_test.dart b/tests/corelib/expando_test.dart new file mode 100644 index 00000000000..3b604e43792 --- /dev/null +++ b/tests/corelib/expando_test.dart @@ -0,0 +1,116 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +class ExpandoTest { + static Expando visits; + + static testMain() { + visits = new Expando('visits'); + var legal = [ + new Object(), + new List(), + [1, 2, 3], + const [1, 2, 3], + new Map(), + {'x': 1, 'y': 2}, + const {'x': 1, 'y': 2}, + new Expando(), + new Expando('horse') + ]; + for (var object in legal) { + testNamedExpando(object); + testUnnamedExpando(object); + } + for (var object in legal) { + Expect.equals(2, visits[object], "$object"); + } + testIllegal(); + testIdentity(); + } + + static visit(object) { + int count = visits[object]; + count = (count == null) ? 1 : count + 1; + visits[object] = count; + } + + static testNamedExpando(object) { + Expando expando = new Expando('myexpando'); + Expect.equals('myexpando', expando.name); + Expect.isTrue(expando.toString().startsWith('Expando:myexpando')); + testExpando(expando, object); + } + + static testUnnamedExpando(object) { + Expando expando = new Expando(); + Expect.isNull(expando.name); + Expect.isTrue(expando.toString().startsWith('Expando:')); + testExpando(expando, object); + } + + static testExpando(Expando expando, object) { + visit(object); + + Expect.isNull(expando[object]); + expando[object] = 42; + Expect.equals(42, expando[object]); + expando[object] = null; + Expect.isNull(expando[object]); + + Expando alternative = new Expando('myexpando'); + Expect.isNull(alternative[object]); + alternative[object] = 87; + Expect.isNull(expando[object]); + expando[object] = 99; + Expect.equals(99, expando[object]); + Expect.equals(87, alternative[object]); + } + + static testIllegal() { + Expando expando = new Expando(); + Expect.throws( + () => expando[null], (exception) => exception is ArgumentError, "null"); + Expect.throws(() => expando['string'], + (exception) => exception is ArgumentError, "'string'"); + Expect.throws(() => expando['string'], + (exception) => exception is ArgumentError, "'string'"); + Expect.throws( + () => expando[42], (exception) => exception is ArgumentError, "42"); + Expect.throws(() => expando[42.87], + (exception) => exception is ArgumentError, "42.87"); + Expect.throws( + () => expando[true], (exception) => exception is ArgumentError, "true"); + Expect.throws(() => expando[false], + (exception) => exception is ArgumentError, "false"); + } + + static testIdentity() { + // Expando only depends on identity of object. + Expando expando = new Expando(); + var m1 = new Mutable(1); + var m2 = new Mutable(7); + var m3 = new Mutable(13); + expando[m1] = 42; + Expect.equals(42, expando[m1]); + m1.id = 37; + Expect.equals(42, expando[m1]); + expando[m2] = 37; + expando[m3] = 10; + m3.id = 1; + Expect.equals(42, expando[m1]); + Expect.equals(37, expando[m2]); + Expect.equals(10, expando[m3]); + } +} + +main() => ExpandoTest.testMain(); + +class Mutable { + int id; + Mutable(this.id); + int get hashCode => id; + bool operator ==(other) => other is Mutable && other.id == id; +} diff --git a/tests/corelib/expression_test.dart b/tests/corelib/expression_test.dart new file mode 100644 index 00000000000..d0ba4c917bd --- /dev/null +++ b/tests/corelib/expression_test.dart @@ -0,0 +1,117 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +// Tests basic expressions. Does not attempt to validate the details of arithmetic, coercion, and +// so forth. +class ExpressionTest { + ExpressionTest() {} + + int foo; + + static testMain() { + var test = new ExpressionTest(); + test.testBinary(); + test.testUnary(); + test.testShifts(); + test.testBitwise(); + test.testIncrement(); + test.testMangling(); + } + + testBinary() { + int x = 4, y = 2; + Expect.equals(6, x + y); + Expect.equals(2, x - y); + Expect.equals(8, x * y); + Expect.equals(2, x / y); + Expect.equals(0, x % y); + } + + testUnary() { + int x = 4, y = 2, z = -5; + bool t = true, f = false; + Expect.equals(-4, -x); + Expect.equals(4, ~z); + Expect.equals(f, !t); + } + + testShifts() { + int x = 4, y = 2; + Expect.equals(y, x >> 1); + Expect.equals(x, y << 1); + } + + testBitwise() { + int x = 4, y = 2; + Expect.equals(6, (x | y)); + Expect.equals(0, (x & y)); + Expect.equals(6, (x ^ y)); + } + + operator [](int index) { + return foo; + } + + operator []=(int index, int value) { + foo = value; + } + + testIncrement() { + int x = 4, a = x++; + Expect.equals(4, a); + Expect.equals(5, x); + Expect.equals(6, ++x); + Expect.equals(6, x++); + Expect.equals(7, x); + Expect.equals(6, --x); + Expect.equals(6, x--); + Expect.equals(5, x); + + this.foo = 0; + Expect.equals(0, this.foo++); + Expect.equals(1, this.foo); + Expect.equals(2, ++this.foo); + Expect.equals(2, this.foo); + Expect.equals(2, this.foo--); + Expect.equals(1, this.foo); + Expect.equals(0, --this.foo); + Expect.equals(0, this.foo); + + Expect.equals(0, this[0]++); + Expect.equals(1, this[0]); + Expect.equals(2, ++this[0]); + Expect.equals(2, this[0]); + Expect.equals(2, this[0]--); + Expect.equals(1, this[0]); + Expect.equals(0, --this[0]); + Expect.equals(0, this[0]); + + int $0 = 42, $1 = 87, $2 = 117; + Expect.equals(42, $0++); + Expect.equals(43, $0); + Expect.equals(44, ++$0); + Expect.equals(88, $0 += $0); + Expect.equals(87, $1++); + Expect.equals(88, $1); + Expect.equals(89, ++$1); + Expect.equals(178, ($1 += $1)); + Expect.equals(117, $2++); + Expect.equals(118, $2); + Expect.equals(119, ++$2); + } + + void testMangling() { + int $0 = 42, $1 = 87, $2 = 117; + this[0] = 0; + Expect.equals(42, (this[0] += $0)); + Expect.equals(129, (this[0] += $1)); + Expect.equals(246, (this[0] += $2)); + } +} + +main() { + ExpressionTest.testMain(); +} diff --git a/tests/corelib/for_in_test.dart b/tests/corelib/for_in_test.dart new file mode 100644 index 00000000000..35d1a86439c --- /dev/null +++ b/tests/corelib/for_in_test.dart @@ -0,0 +1,96 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +class ForInTest { + static testMain() { + testSimple(); + testBreak(); + testContinue(); + testClosure(); + } + + static Set getSmallSet() { + Set set = new Set(); + set.add(1); + set.add(2); + set.add(4); + return set; + } + + static void testSimple() { + Set set = getSmallSet(); + int count = 0; + for (final i in set) { + count += i; + } + Expect.equals(7, count); + + count = 0; + for (var i in set) { + count += i; + } + Expect.equals(7, count); + + count = 0; + for (int i in set) { + count += i; + } + Expect.equals(7, count); + + count = 0; + for (final int i in set) { + count += i; + } + Expect.equals(7, count); + + count = 0; + int i = 0; + Expect.equals(false, set.contains(i)); // Used to test [i] after loop. + for (i in set) { + count += i; + } + Expect.equals(7, count); + Expect.equals(true, set.contains(i)); + // The default implementation of [Set] preserves order. + Expect.equals(4, i); + } + + static void testBreak() { + Set set = getSmallSet(); + int count = 0; + for (final i in set) { + if (i == 4) break; + count += i; + } + Expect.equals(true, count < 4); + } + + static void testContinue() { + Set set = getSmallSet(); + int count = 0; + for (final i in set) { + if (i < 4) continue; + count += i; + } + Expect.equals(4, count); + } + + static void testClosure() { + Set set = getSmallSet(); + List closures = new List(set.length); + int index = 0; + for (var i in set) { + closures[index++] = () => i; + } + + Expect.equals(index, set.length); + Expect.equals(7, closures[0]() + closures[1]() + closures[2]()); + } +} + +main() { + ForInTest.testMain(); +} diff --git a/tests/corelib/format_exception_test.dart b/tests/corelib/format_exception_test.dart new file mode 100644 index 00000000000..a2e89e6194c --- /dev/null +++ b/tests/corelib/format_exception_test.dart @@ -0,0 +1,108 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +library format_exception_test; + +import "package:expect/expect.dart"; + +test(exn, message, source, offset, toString) { + Expect.equals(message, exn.message); + Expect.equals(source, exn.source); + Expect.equals(offset, exn.offset); + Expect.equals(toString, exn.toString()); +} + +main() { + var e; + e = new FormatException(); + test(e, "", null, null, "FormatException"); + e = new FormatException(""); + test(e, "", null, null, "FormatException"); + e = new FormatException(null); + test(e, null, null, null, "FormatException"); + + e = new FormatException("message"); + test(e, "message", null, null, "FormatException: message"); + + e = new FormatException("message", "source"); + test(e, "message", "source", null, "FormatException: message\nsource"); + + e = new FormatException("message", "source" * 25); + test(e, "message", "source" * 25, null, + "FormatException: message\n" + "source" * 12 + "sou..."); + e = new FormatException("message", "source" * 25); + test(e, "message", "source" * 25, null, + "FormatException: message\n" + "source" * 12 + "sou..."); + e = new FormatException("message", "s1\nsource\ns2"); + test(e, "message", "s1\nsource\ns2", null, + "FormatException: message\n" + "s1\nsource\ns2"); + + var o = new Object(); + e = new FormatException("message", o, 10); + test(e, "message", o, 10, "FormatException: message (at offset 10)"); + + e = new FormatException("message", "source", 3); + test(e, "message", "source", 3, + "FormatException: message (at character 4)\nsource\n ^\n"); + + e = new FormatException("message", "s1\nsource\ns2", 6); + test(e, "message", "s1\nsource\ns2", 6, + "FormatException: message (at line 2, character 4)\nsource\n ^\n"); + + var longline = "watermelon cantaloupe " * 8 + "watermelon"; // Length > 160. + var longsource = (longline + "\n") * 25; + var line10 = (longline.length + 1) * 9; + e = new FormatException("message", longsource, line10); + test( + e, + "message", + longsource, + line10, + "FormatException: message (at line 10, character 1)\n" + "${longline.substring(0, 75)}...\n^\n"); + + e = new FormatException("message", longsource, line10 - 1); + test( + e, + "message", + longsource, + line10 - 1, + "FormatException: message (at line 9, " + "character ${longline.length + 1})\n" + "...${longline.substring(longline.length - 75)}\n" + "${' ' * 78}^\n"); + + var half = longline.length ~/ 2; + e = new FormatException("message", longsource, line10 + half); + test( + e, + "message", + longsource, + line10 + half, + "FormatException: message (at line 10, character ${half + 1})\n" + "...${longline.substring(half - 36, half + 36)}...\n" + "${' ' * 39}^\n"); + + var sourceNL = "\nsource with leading NL"; + e = new FormatException("message", sourceNL, 2); + test( + e, + "message", + sourceNL, + 2, + "FormatException: message (at line 2, character 2)\n" + "source with leading NL\n" + " ^\n"); + + var sourceNL2 = "\n\nsource with leading NL"; + e = new FormatException("message", sourceNL2, 2); + test( + e, + "message", + sourceNL2, + 2, + "FormatException: message (at line 3, character 1)\n" + "source with leading NL\n" + "^\n"); +} diff --git a/tests/corelib/from_environment_const_type_test.dart b/tests/corelib/from_environment_const_type_test.dart new file mode 100644 index 00000000000..fb9de9816a1 --- /dev/null +++ b/tests/corelib/from_environment_const_type_test.dart @@ -0,0 +1,43 @@ +// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. +// SharedOptions=-Da=true -Db=false -Dc=3 -Dd=STRING + +import "package:expect/expect.dart"; + +class Foo {} + +const + bool // //# 01: ok + int // //# 02: static type warning, checked mode compile-time error + String // //# 03: static type warning, checked mode compile-time error + Foo // //# 04: static type warning, checked mode compile-time error + a = const bool.fromEnvironment('a'); + +const + bool // //# 05: ok + int // //# 06: static type warning, checked mode compile-time error + String // //# 07: static type warning, checked mode compile-time error + Foo // //# 08: static type warning, checked mode compile-time error + b = const bool.fromEnvironment('b'); + +const + bool // //# 09: static type warning, checked mode compile-time error + int // //# 10: ok + String // //# 11: static type warning, checked mode compile-time error + Foo // //# 12: static type warning, checked mode compile-time error + c = const int.fromEnvironment('c'); + +const + bool // //# 13: static type warning, checked mode compile-time error + int // //# 14: static type warning, checked mode compile-time error + String // //# 15: ok + Foo // //# 16: static type warning, checked mode compile-time error + d = const String.fromEnvironment('d'); + +main() { + Expect.equals(a, true); + Expect.equals(b, false); + Expect.equals(c, 3); + Expect.equals(d, 'STRING'); +} diff --git a/tests/corelib/from_environment_const_type_undefined_test.dart b/tests/corelib/from_environment_const_type_undefined_test.dart new file mode 100644 index 00000000000..076fa7e144c --- /dev/null +++ b/tests/corelib/from_environment_const_type_undefined_test.dart @@ -0,0 +1,42 @@ +// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +class Foo {} + +const + bool // //# 01: ok + int // //# 02: static type warning, checked mode compile-time error + String //# 03: static type warning, checked mode compile-time error + Foo // //# 04: static type warning, checked mode compile-time error + a = const bool.fromEnvironment('a'); + +const + bool // //# 05: ok + int // //# 06: static type warning, checked mode compile-time error + String //# 07: static type warning, checked mode compile-time error + Foo // //# 08: static type warning, checked mode compile-time error + b = const bool.fromEnvironment('b'); + +const + bool // //# 09: static type warning + int // //# 10: ok + String //# 11: static type warning + Foo // //# 12: static type warning + c = const int.fromEnvironment('c'); + +const + bool // //# 13: static type warning + int // //# 14: static type warning + String //# 15: ok + Foo // //# 16: static type warning + d = const String.fromEnvironment('d'); + +main() { + Expect.equals(a, false); + Expect.equals(b, false); + Expect.equals(c, null); + Expect.equals(d, null); +} diff --git a/tests/corelib/growable_list_test.dart b/tests/corelib/growable_list_test.dart new file mode 100644 index 00000000000..722a5b34d92 --- /dev/null +++ b/tests/corelib/growable_list_test.dart @@ -0,0 +1,187 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// Sanity check on the growing behavior of a growable list. + +import "package:expect/expect.dart"; + +void main() { + testConstructor(); + + bool checked = false; + assert((checked = true)); + // Concurrent modification checks are only guaranteed in checked mode. + if (checked) testConcurrentModification(); +} + +// Iterable generating numbers in range [0..count). +// May perform callback at some point underways. +class TestIterableBase extends Iterable { + final int length; + final int count; + // call [callback] if generating callbackIndex. + final int callbackIndex; + final Function callback; + TestIterableBase(this.length, this.count, this.callbackIndex, this.callback); + Iterator get iterator => new CallbackIterator(this); +} + +class TestIterable extends TestIterableBase { + TestIterable(count, [callbackIndex = -1, callback]) + : super(-1, count, callbackIndex, callback); + int get length => throw "SHOULD NOT BE CALLED"; +} + +// Implement Set for private EfficientLengthIterable interface. +class EfficientTestIterable extends TestIterableBase implements Set { + EfficientTestIterable(length, count, [callbackIndex = -1, callback]) + : super(length, count, callbackIndex, callback); + // Avoid warnings because we don't actually implement Set. + noSuchMethod(i) => super.noSuchMethod(i); +} + +class CallbackIterator implements Iterator { + TestIterableBase _iterable; + int _current = null; + int _nextIndex = 0; + CallbackIterator(this._iterable); + bool moveNext() { + if (_nextIndex >= _iterable.count) { + _current = null; + return false; + } + _current = _nextIndex; + _nextIndex++; + if (_current == _iterable.callbackIndex) { + _iterable.callback(); + } + return true; + } + + int get current => _current; +} + +void testConstructor() { + // Constructor can make both growable and fixed-length lists. + testGrowable(list) { + Expect.isTrue(list is List); + Expect.isFalse(list is List); + int length = list.length; + list.add(42); + Expect.equals(list.length, length + 1); + } + + testFixedLength(list) { + Expect.isTrue(list is List); + int length = list.length; + Expect.throws(() { + list.add(42); + }, null, "adding to fixed-length list"); + Expect.equals(length, list.length); + } + + bool checked = false; + assert((checked = true)); + testThrowsOrTypeError(fn, test, [name]) { + Expect.throws( + fn, checked ? null : test, checked ? name : "$name w/ TypeError"); + } + + testFixedLength(new List(0)); + testFixedLength(new List(5)); + testFixedLength(new List.filled(5, null)); // default growable: false. + testGrowable(new List()); + testGrowable(new List()..length = 5); + testGrowable(new List.filled(5, null, growable: true)); + Expect.throws(() => new List(-1), (e) => e is ArgumentError, "-1"); + // There must be limits. Fix this test if we ever allow 10^30 elements. + Expect.throws(() => new List(0x7fffffffffffffff), + (e) => e is ArgumentError, "bignum"); + Expect.throws(() => new List(null), (e) => e is ArgumentError, "null"); + testThrowsOrTypeError( + () => new List([] as Object), // Cast to avoid warning. + (e) => e is ArgumentError, + 'list'); + testThrowsOrTypeError( + () => new List([42] as Object), (e) => e is ArgumentError, "list2"); +} + +void testConcurrentModification() { + // Without EfficientLengthIterable interface + { + // Change length of list after 200 additions. + var l = []; + var ci = new TestIterable(257, 200, () { + l.add("X"); + }); + Expect.throws(() { + l.addAll(ci); + }, (e) => e is ConcurrentModificationError, "cm1"); + } + + { + // Change length of list after 200 additions. + var l = []; + var ci = new TestIterable(257, 200, () { + l.length = 0; + }); + Expect.throws(() { + l.addAll(ci); + }, (e) => e is ConcurrentModificationError, "cm2"); + } + + // With EfficientLengthIterable interface (uses length). + { + // Change length of list after 20 additions. + var l = []; + var ci = new EfficientTestIterable(257, 257, 20, () { + l.add("X"); + }); + Expect.throws(() { + l.addAll(ci); + }, (e) => e is ConcurrentModificationError, "cm3"); + } + + { + var l = []; + var ci = new EfficientTestIterable(257, 257, 20, () { + l.length = 0; + }); + Expect.throws(() { + l.addAll(ci); + }, (e) => e is ConcurrentModificationError, "cm4"); + } + + { + // Length 500, only 250 elements. + var l = []; + var ci = new EfficientTestIterable(500, 250); + l.addAll(ci); + Expect.listEquals(new List.generate(250, (x) => x), l, "cm5"); + } + + { + // Length 250, but 500 elements. + var l = []; + var ci = new EfficientTestIterable(250, 500); + l.addAll(ci); + Expect.listEquals(new List.generate(500, (x) => x), l, "cm6"); + } + + { + // Adding to yourself. + var l = [1]; + Expect.throws(() { + l.addAll(l); + }, (e) => e is ConcurrentModificationError, "cm7"); + } + + { + // Adding to yourself. + var l = [1, 2, 3]; + Expect.throws(() { + l.addAll(l); + }, (e) => e is ConcurrentModificationError, "cm8"); + } +} diff --git a/tests/corelib/has_next_iterator_test.dart b/tests/corelib/has_next_iterator_test.dart new file mode 100644 index 00000000000..c3801667b54 --- /dev/null +++ b/tests/corelib/has_next_iterator_test.dart @@ -0,0 +1,37 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +library hasNextIterator.test; + +import "package:expect/expect.dart"; +import 'dart:collection'; + +main() { + var it = new HasNextIterator([].iterator); + Expect.isFalse(it.hasNext); + Expect.isFalse(it.hasNext); + Expect.throws(() => it.next(), (e) => e is StateError); + Expect.isFalse(it.hasNext); + + it = new HasNextIterator([1].iterator); + Expect.isTrue(it.hasNext); + Expect.isTrue(it.hasNext); + Expect.equals(1, it.next()); + Expect.isFalse(it.hasNext); + Expect.isFalse(it.hasNext); + Expect.throws(() => it.next(), (e) => e is StateError); + Expect.isFalse(it.hasNext); + + it = new HasNextIterator([1, 2].iterator); + Expect.isTrue(it.hasNext); + Expect.isTrue(it.hasNext); + Expect.equals(1, it.next()); + Expect.isTrue(it.hasNext); + Expect.isTrue(it.hasNext); + Expect.equals(2, it.next()); + Expect.isFalse(it.hasNext); + Expect.isFalse(it.hasNext); + Expect.throws(() => it.next(), (e) => e is StateError); + Expect.isFalse(it.hasNext); +} diff --git a/tests/corelib/hash_map2_test.dart b/tests/corelib/hash_map2_test.dart new file mode 100644 index 00000000000..c744dd0d750 --- /dev/null +++ b/tests/corelib/hash_map2_test.dart @@ -0,0 +1,308 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// Tests of hash map behavior, with focus in iteration and concurrent +// modification errors. + +library hash_map2_test; + +import "package:expect/expect.dart"; +import 'dart:collection'; + +testMap(Map newMap(), Map newMapFrom(Map map)) { + Map gen(int from, int to) { + Map map = new LinkedHashMap(); + for (int i = from; i < to; i++) map[i] = i; + return map; + } + + bool odd(int n) => (n & 1) == 1; + bool even(int n) => (n & 1) == 0; + void addAll(Map toMap, Map fromMap) { + fromMap.forEach((k, v) { + toMap[k] = v; + }); + } + + { + // Test growing to largish capacity. + Map map = newMap(); + + for (int i = 0; i < 256; i++) { + map[i] = i; + } + addAll(map, gen(256, 512)); + addAll(map, newMapFrom(gen(512, 1000))); + Expect.equals(1000, map.length); + + // Remove half. + for (int i = 0; i < 1000; i += 2) map.remove(i); + Expect.equals(500, map.length); + Expect.isFalse(map.keys.any(even)); + Expect.isTrue(map.keys.every(odd)); + + // Re-add all. + addAll(map, gen(0, 1000)); + Expect.equals(1000, map.length); + } + + { + // Test having many deleted elements. + Map map = newMap(); + map[0] = 0; + for (int i = 0; i < 1000; i++) { + map[i + 1] = i + 1; + map.remove(i); + Expect.equals(1, map.length); + } + } + + { + // Test having many elements with same hashCode + Map map = newMap(); + for (int i = 0; i < 1000; i++) { + map[new BadHashCode()] = 0; + } + Expect.equals(1000, map.length); + } + + { + // Check concurrent modification + Map map = newMap() + ..[0] = 0 + ..[1] = 1; + + { + // Test adding before a moveNext. + Iterator iter = map.keys.iterator; + iter.moveNext(); + map[1] = 9; // Updating existing key isn't a modification. + iter.moveNext(); + map[2] = 2; + Expect.throws(iter.moveNext, (e) => e is Error); + } + + { + // Test adding after last element. + Iterator iter = map.keys.iterator; + Expect.equals(3, map.length); + iter.moveNext(); + iter.moveNext(); + iter.moveNext(); + map[3] = 3; + Expect.throws(iter.moveNext, (e) => e is Error); + } + + { + // Test removing during iteration. + Iterator iter = map.keys.iterator; + iter.moveNext(); + map.remove(1000); // Not a modification if it's not there. + iter.moveNext(); + int n = iter.current; + map.remove(n); + // Removing doesn't change current. + Expect.equals(n, iter.current); + Expect.throws(iter.moveNext, (e) => e is Error); + } + + { + // Test removing after last element. + Iterator iter = map.keys.iterator; + Expect.equals(3, map.length); + iter.moveNext(); + iter.moveNext(); + iter.moveNext(); + int n = iter.current; + map.remove(n); + // Removing doesn't change current. + Expect.equals(n, iter.current); + Expect.throws(iter.moveNext, (e) => e is Error); + } + + { + // Test that updating value of existing key doesn't cause concurrent + // modification error. + Iterator iter = map.keys.iterator; + Expect.equals(2, map.length); + iter.moveNext(); + int n = iter.current; + map[n] = n * 2; + iter.moveNext(); + Expect.equals(map[iter.current], iter.current); + } + + { + // Test that modification during putIfAbsent is not an error. + map.putIfAbsent(4, () { + map[5] = 5; + map[4] = -1; + return 4; + }); + Expect.equals(4, map[4]); + Expect.equals(5, map[5]); + } + + { + // Check adding many existing keys isn't considered modification. + Map map2 = newMap(); + for (var key in map.keys) { + map2[key] = map[key] + 1; + } + Iterator iter = map.keys.iterator; + addAll(map, map2); + // Shouldn't throw. + iter.moveNext(); + } + } + + { + // Regression test for bug in putIfAbsent where adding an element + // that make the table grow, can be lost. + Map map = newMap(); + map.putIfAbsent("S", () => 0); + map.putIfAbsent("T", () => 0); + map.putIfAbsent("U", () => 0); + map.putIfAbsent("C", () => 0); + map.putIfAbsent("a", () => 0); + map.putIfAbsent("b", () => 0); + map.putIfAbsent("n", () => 0); + Expect.isTrue(map.containsKey("n")); + } + + { + // Check that putIfAbsent works just as well as put. + Map map = newMap(); + for (int i = 0; i < 128; i++) { + map.putIfAbsent(i, () => i); + Expect.isTrue(map.containsKey(i)); + map.putIfAbsent(i >> 1, () => -1); // Never triggers. + } + for (int i = 0; i < 128; i++) { + Expect.equals(i, map[i]); + } + } + + { + // Check that updating existing elements is not a modification. + // This must be the case even if the underlying data structure is + // nearly full. + for (int i = 1; i < 128; i++) { + // Create maps of different sizes, some of which should be + // at a limit of the underlying data structure. + Map map = newMapFrom(gen(0, i)); + + // ForEach-iteration. + map.forEach((key, v) { + Expect.equals(key, map[key]); + map[key] = key + 1; + map.remove(1000); // Removing something not there. + map.putIfAbsent(key, () => Expect.fail("SHOULD NOT BE ABSENT")); + // Doesn't cause ConcurrentModificationError. + }); + + // for-in iteration. + for (int key in map.keys) { + Expect.equals(key + 1, map[key]); + map[key] = map[key] + 1; + map.remove(1000); // Removing something not there. + map.putIfAbsent(key, () => Expect.fail("SHOULD NOT BE ABSENT")); + // Doesn't cause ConcurrentModificationError. + } + + // Raw iterator. + Iterator iter = map.keys.iterator; + for (int key = 0; key < i; key++) { + Expect.equals(key + 2, map[key]); + map[key] = key + 3; + map.remove(1000); // Removing something not there. + map.putIfAbsent(key, () => Expect.fail("SHOULD NOT BE ABSENT")); + // Doesn't cause ConcurrentModificationError on the moveNext. + } + iter.moveNext(); // Should not throw. + + // Remove a lot of elements, which can cause a re-tabulation. + for (int key = 1; key < i; key++) { + Expect.equals(key + 3, map[key]); + map.remove(key); + } + iter = map.keys.iterator; + map[0] = 2; + iter.moveNext(); // Should not throw. + } + } + + { + // Check that null can be in the map. + Map map = newMap(); + map[null] = 0; + Expect.equals(1, map.length); + Expect.isTrue(map.containsKey(null)); + Expect.isNull(map.keys.first); + Expect.isNull(map.keys.last); + map[null] = 1; + Expect.equals(1, map.length); + Expect.isTrue(map.containsKey(null)); + map.remove(null); + Expect.isTrue(map.isEmpty); + Expect.isFalse(map.containsKey(null)); + + // Created using map.from. + map = newMapFrom(new Map()..[null] = 0); + Expect.equals(1, map.length); + Expect.isTrue(map.containsKey(null)); + Expect.isNull(map.keys.first); + Expect.isNull(map.keys.last); + map[null] = 1; + Expect.equals(1, map.length); + Expect.isTrue(map.containsKey(null)); + map.remove(null); + Expect.isTrue(map.isEmpty); + Expect.isFalse(map.containsKey(null)); + + Map fromMap = new Map(); + fromMap[1] = 0; + fromMap[2] = 0; + fromMap[3] = 0; + fromMap[null] = 0; + fromMap[4] = 0; + fromMap[5] = 0; + fromMap[6] = 0; + Expect.equals(7, fromMap.length); + + // map that grows with null in it. + map = newMapFrom(fromMap); + Expect.equals(7, map.length); + for (int i = 7; i < 128; i++) { + map[i] = 0; + } + Expect.equals(128, map.length); + Expect.isTrue(map.containsKey(null)); + map[null] = 1; + Expect.equals(128, map.length); + Expect.isTrue(map.containsKey(null)); + map.remove(null); + Expect.equals(127, map.length); + Expect.isFalse(map.containsKey(null)); + } +} + +void main() { + Expect.isTrue(new HashMap() is Map); + Expect.isTrue(new LinkedHashMap() is Map); + Expect.isTrue(new HashMap.from({}) is Map); + Expect.isTrue(new LinkedHashMap.from({}) is Map); + Expect.isTrue({} is Map); + Expect.isTrue(const {} is Map); + + testMap(() => new HashMap(), (m) => new HashMap.from(m)); + testMap(() => new LinkedHashMap(), (m) => new LinkedHashMap.from(m)); +} + +class BadHashCode { + static int idCounter = 0; + final int id; + BadHashCode() : id = idCounter++; + int get hashCode => 42; +} diff --git a/tests/corelib/hash_map_test.dart b/tests/corelib/hash_map_test.dart new file mode 100644 index 00000000000..4bd6d62db8f --- /dev/null +++ b/tests/corelib/hash_map_test.dart @@ -0,0 +1,23 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +// Test program for the HashMap class. + +class HashMapTest { + static testMain() { + var m = new Map(); + Expect.equals(0, m.length); + Expect.equals(true, m.isEmpty); + m["one"] = 1; + Expect.equals(1, m.length); + Expect.equals(false, m.isEmpty); + Expect.equals(1, m["one"]); + } +} + +main() { + HashMapTest.testMain(); +} diff --git a/tests/corelib/hash_set_test.dart b/tests/corelib/hash_set_test.dart new file mode 100644 index 00000000000..a274c026d51 --- /dev/null +++ b/tests/corelib/hash_set_test.dart @@ -0,0 +1,363 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. +// +// VMOptions= + +// Tests of hash set behavior, with focus in iteration and concurrent +// modification errors. + +library hash_map2_test; + +import "package:expect/expect.dart"; +import 'dart:collection'; +import 'dart:math' as math; + +testSet(Set newSet(), Set newSetFrom(Iterable from)) { + Set gen(int from, int to) => + new Set.from(new Iterable.generate(to - from, (n) => n + from)); + + bool odd(int n) => (n & 1) == 1; + bool even(int n) => (n & 1) == 0; + + { + // Test growing to largish capacity. + Set set = newSet(); + + for (int i = 0; i < 256; i++) { + set.add(i); + } + + set.addAll(gen(256, 512)); + set.addAll(newSetFrom(gen(512, 1000))); + Expect.equals(1000, set.length); + + // Remove half. + for (int i = 0; i < 1000; i += 2) set.remove(i); + Expect.equals(500, set.length); + Expect.isFalse(set.any(even)); + Expect.isTrue(set.every(odd)); + + // Re-add all. + set.addAll(gen(0, 1000)); + Expect.equals(1000, set.length); + } + + { + // Test having many deleted elements. + Set set = newSet(); + set.add(0); + for (int i = 0; i < 1000; i++) { + set.add(i + 1); + set.remove(i); + Expect.equals(1, set.length); + } + } + + { + // Test having many elements with same hashCode + Set set = newSet(); + for (int i = 0; i < 1000; i++) { + set.add(new BadHashCode()); + } + Expect.equals(1000, set.length); + } + + { + // Check concurrent modification + Set set = newSet()..add(0)..add(1); + + { + // Test adding before a moveNext. + Iterator iter = set.iterator; + iter.moveNext(); + set.add(1); // Updating existing key isn't a modification. + iter.moveNext(); + set.add(2); + Expect.throws(iter.moveNext, (e) => e is Error); + } + + { + // Test adding after last element. + Iterator iter = set.iterator; + Expect.equals(3, set.length); + iter.moveNext(); + iter.moveNext(); + iter.moveNext(); + set.add(3); + Expect.throws(iter.moveNext, (e) => e is Error); + } + + { + // Test removing during iteration. + Iterator iter = set.iterator; + iter.moveNext(); + set.remove(1000); // Not a modification if it's not there. + iter.moveNext(); + int n = iter.current; + set.remove(n); + // Removing doesn't change current. + Expect.equals(n, iter.current); + Expect.throws(iter.moveNext, (e) => e is Error); + } + + { + // Test removing after last element. + Iterator iter = set.iterator; + Expect.equals(3, set.length); + iter.moveNext(); + iter.moveNext(); + iter.moveNext(); + int n = iter.current; + set.remove(n); + // Removing doesn't change current. + Expect.equals(n, iter.current); + Expect.throws(iter.moveNext, (e) => e is Error); + } + + { + // Test that updating value doesn't cause error. + Iterator iter = set.iterator; + Expect.equals(2, set.length); + iter.moveNext(); + int n = iter.current; + set.add(n); + iter.moveNext(); + Expect.isTrue(set.contains(iter.current)); + } + + { + // Check adding many existing values isn't considered modification. + Set set2 = newSet(); + for (var value in set) { + set2.add(value); + } + Iterator iter = set.iterator; + set.addAll(set2); + // Shouldn't throw. + iter.moveNext(); + } + } + + { + // Check that updating existing elements is not a modification. + // This must be the case even if the underlying data structure is + // nearly full. + for (int i = 1; i < 128; i++) { + // Create maps of different sizes, some of which should be + // at a limit of the underlying data structure. + Set set = newSetFrom(gen(0, i)); + Iterator iter = set.iterator; + for (int j = 0; j < i; j++) { + set.add(j); + } + iter.moveNext(); // Should not throw. + + for (int j = 1; j < i; j++) { + set.remove(j); + } + iter = set.iterator; + set.add(0); + iter.moveNext(); // Should not throw. + } + } + + { + // Check that null can be in the set. + Set set = newSet(); + set.add(null); + Expect.equals(1, set.length); + Expect.isTrue(set.contains(null)); + Expect.isNull(set.first); + Expect.isNull(set.last); + set.add(null); + Expect.equals(1, set.length); + Expect.isTrue(set.contains(null)); + set.remove(null); + Expect.isTrue(set.isEmpty); + Expect.isFalse(set.contains(null)); + + // Created using Set.from. + set = newSetFrom([null]); + Expect.equals(1, set.length); + Expect.isTrue(set.contains(null)); + Expect.isNull(set.first); + Expect.isNull(set.last); + set.add(null); + Expect.equals(1, set.length); + Expect.isTrue(set.contains(null)); + set.remove(null); + Expect.isTrue(set.isEmpty); + Expect.isFalse(set.contains(null)); + + // Set that grows with null in it. + set = newSetFrom([1, 2, 3, null, 4, 5, 6]); + Expect.equals(7, set.length); + for (int i = 7; i < 128; i++) { + set.add(i); + } + Expect.equals(128, set.length); + Expect.isTrue(set.contains(null)); + set.add(null); + Expect.equals(128, set.length); + Expect.isTrue(set.contains(null)); + set.remove(null); + Expect.equals(127, set.length); + Expect.isFalse(set.contains(null)); + } + + { + // Check that addAll and clear works. + Set set = newSet(); + set.addAll([]); + Expect.isTrue(set.isEmpty); + set.addAll([1, 3, 2]); + Expect.equals(3, set.length); + Expect.isTrue(set.contains(1)); + Expect.isTrue(set.contains(3)); + Expect.isTrue(set.contains(2)); + Expect.isFalse(set.contains(4)); + set.clear(); + Expect.isTrue(set.isEmpty); + } + + { + // Check that removeWhere and retainWhere work. + Set set = newSetFrom([1, 2, 3]); + set.removeWhere((each) => each == 2); + Expect.equals(2, set.length); + Expect.isTrue(set.contains(1)); + Expect.isFalse(set.contains(2)); + Expect.isTrue(set.contains(3)); + set.retainWhere((each) => each == 3); + Expect.equals(1, set.length); + Expect.isFalse(set.contains(1)); + Expect.isFalse(set.contains(2)); + Expect.isTrue(set.contains(3)); + } + + { + // Test lookup + Set set = newSet(); + var m1a = new Mutable(1); + var m1b = new Mutable(1); + var m2a = new Mutable(2); + var m2b = new Mutable(2); + Expect.isNull(set.lookup(m1a)); + Expect.isNull(set.lookup(m1b)); + set.add(m1a); + Expect.identical(m1a, set.lookup(m1a)); + Expect.identical(m1a, set.lookup(m1b)); + + Expect.isNull(set.lookup(m2a)); + Expect.isNull(set.lookup(m2b)); + set.add(m2a); + Expect.identical(m2a, set.lookup(m2a)); + Expect.identical(m2a, set.lookup(m2b)); + + set.add(m2b); // Adding doesn't change element. + Expect.identical(m2a, set.lookup(m2a)); + Expect.identical(m2a, set.lookup(m2b)); + + set.remove(m1a); + set.add(m1b); + Expect.identical(m1b, set.lookup(m1a)); + Expect.identical(m1b, set.lookup(m1b)); + + set.add(1); + Expect.identical(1, set.lookup(1.0)); + set.add(-0.0); + Expect.identical(-0.0, set.lookup(0.0)); + } + + { + // Test special hash codes + Set set = newSet(); + List keys = []; + // Powers of two + for (int i = 63; i >= 2; --i) { + keys.add(new Mutable(math.pow(2, i))); + } + for (var key in keys) { + Expect.isTrue(set.add(key)); + } + for (var key in keys) { + Expect.isTrue(set.contains(key)); + } + } +} + +void testIdentitySet(Set create()) { + Set set = create(); + set.add(1); + set.add(2); + set.add(1); // Integers are identical if equal. + Expect.equals(2, set.length); + var complex = 4; + complex = set.length == 2 ? complex ~/ 4 : 87; // Avoid compile-time constant. + Expect.isTrue(set.contains(complex)); // 1 is in set, even if computed. + set.clear(); + + // All compile time constants are identical to themselves. + var constants = [ + double.INFINITY, + double.NAN, -0.0, //# 01: ok + 0.0, 42, "", null, false, true, #bif, testIdentitySet + ]; + set.addAll(constants); + Expect.equals(constants.length, set.length); + for (var c in constants) { + Expect.isTrue(set.contains(c), "constant: $c"); + } + Expect.isTrue(set.containsAll(constants), "constants: $set"); + set.clear(); + + var m1 = new Mutable(1); + var m2 = new Mutable(2); + var m3 = new Mutable(3); + var m4 = new Mutable(2); // Equal to m2, but not identical. + set.addAll([m1, m2, m3, m4]); + Expect.equals(4, set.length); + Expect.equals(3, m3.hashCode); + m3.id = 1; + Expect.equals(1, m3.hashCode); + // Changing hashCode doesn't affect lookup. + Expect.isTrue(set.contains(m3)); + Expect.isTrue(set.contains(m1)); + set.remove(m3); + Expect.isFalse(set.contains(m3)); + Expect.isTrue(set.contains(m1)); + + Expect.identical(m1, set.lookup(m1)); + Expect.identical(null, set.lookup(m3)); +} + +void main() { + testSet(() => new Set(), (m) => new Set.from(m)); + testSet(() => new HashSet(), (m) => new HashSet.from(m)); + testSet(() => new LinkedHashSet(), (m) => new LinkedHashSet.from(m)); + testIdentitySet(() => new Set.identity()); + testIdentitySet(() => new HashSet.identity()); + testIdentitySet(() => new LinkedHashSet.identity()); + testIdentitySet(() => new HashSet( + equals: (x, y) => identical(x, y), hashCode: (x) => identityHashCode(x))); + testIdentitySet(() => new LinkedHashSet( + equals: (x, y) => identical(x, y), hashCode: (x) => identityHashCode(x))); +} + +class BadHashCode { + static int idCounter = 0; + final int id; + BadHashCode() : id = idCounter++; + int get hashCode => 42; + // operator == is identity. + // Can't make a bad compareTo that isn't invalid. + int compareTo(BadHashCode other) => id - other.id; +} + +class Mutable { + int id; + Mutable(this.id); + int get hashCode => id; + bool operator ==(other) => other is Mutable && id == other.id; +} diff --git a/tests/corelib/hash_set_type_check_test.dart b/tests/corelib/hash_set_type_check_test.dart new file mode 100644 index 00000000000..27c7908423e --- /dev/null +++ b/tests/corelib/hash_set_type_check_test.dart @@ -0,0 +1,47 @@ +// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// Tests of hash set type checking. + +library hash_set_type_check_test; + +import "package:expect/expect.dart"; +import 'dart:collection'; + +testSet(Set newSet()) { + Set s = newSet(); + Expect.throws(() => s.add(1), (e) => e is Error); + Expect.isNull(s.lookup(1)); +} + +void testIdentitySet(Set create()) { + Set s = create(); + Expect.throws(() => s.add(1), (e) => e is Error); + Expect.isNull(s.lookup(1)); +} + +bool get inCheckedMode { + try { + var i = 1; + String j = i; + } catch (_) { + return true; + } + return false; +} + +void main() { + if (!inCheckedMode) return; + + testSet(() => new Set()); + testSet(() => new HashSet()); + testSet(() => new LinkedHashSet()); + testIdentitySet(() => new Set.identity()); + testIdentitySet(() => new HashSet.identity()); + testIdentitySet(() => new LinkedHashSet.identity()); + testIdentitySet(() => new HashSet( + equals: (x, y) => identical(x, y), hashCode: (x) => identityHashCode(x))); + testIdentitySet(() => new LinkedHashSet( + equals: (x, y) => identical(x, y), hashCode: (x) => identityHashCode(x))); +} diff --git a/tests/corelib/hashcode_boxed_test.dart b/tests/corelib/hashcode_boxed_test.dart new file mode 100644 index 00000000000..e23c75aea1d --- /dev/null +++ b/tests/corelib/hashcode_boxed_test.dart @@ -0,0 +1,21 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +double fib(double n) { + return n <= 1.0 ? 1.0 : fib(n - 1) + fib(n - 2); +} + +main() { + // Compute the same value in a way that won't be optimized away so the results + // are different objects in memory. + var a = fib(5.0) + 1.0; + var b = fib(4.0) + 4.0; + + Expect.isTrue(identical(a, b)); + Expect.equals(identityHashCode(a), identityHashCode(b)); + Expect.equals(a, b); + Expect.equals(a.hashCode, b.hashCode); +} diff --git a/tests/corelib/hashcode_test.dart b/tests/corelib/hashcode_test.dart new file mode 100644 index 00000000000..ba452759175 --- /dev/null +++ b/tests/corelib/hashcode_test.dart @@ -0,0 +1,48 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +class Override { + int hash; + int get superHash => super.hashCode; + int get hashCode => hash; + + int foo() => hash; // Just some function that can be closurized. + + bool operator ==(Object other) => + other is Override && (other as Override).hash == hash; +} + +int bar() => 42; // Some global function. + +main() { + var o = new Object(); + var hash = o.hashCode; + // Doesn't change. + Expect.equals(hash, o.hashCode); + Expect.equals(hash, identityHashCode(o)); + + var c = new Override(); + int identityHash = c.superHash; + hash = (identityHash == 42) ? 37 : 42; + c.hash = hash; + Expect.equals(hash, c.hashCode); + Expect.equals(identityHash, identityHashCode(c)); + + // These classes don't override hashCode. + var samples = [0, 0x10000000, 1.5, -0, null, true, false, const Object()]; + for (var v in samples) { + print(v); + Expect.equals(v.hashCode, identityHashCode(v)); + } + // These do, or might do, but we can still use hashCodeOf and get the same + // result each time. + samples = ["string", "", (x) => 42, c.foo, bar]; + for (var v in samples) { + print(v); + Expect.equals(v.hashCode, v.hashCode); + Expect.equals(identityHashCode(v), identityHashCode(v)); + } +} diff --git a/tests/corelib/hidden_library2_test.dart b/tests/corelib/hidden_library2_test.dart new file mode 100644 index 00000000000..637cd940779 --- /dev/null +++ b/tests/corelib/hidden_library2_test.dart @@ -0,0 +1,15 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// Test that the internal hidden library doesn't make problems with taking +// stack-traces. + +main() { + print(['x'].where((_) { + // We actually don't really care for the successful case. We just want to + // make sure that the test doesn't crash when it is negative. + throw 'fisk'; // //# 01: runtime error + return true; + }).toList()); +} diff --git a/tests/corelib/indexed_list_access_test.dart b/tests/corelib/indexed_list_access_test.dart new file mode 100644 index 00000000000..b182eeff917 --- /dev/null +++ b/tests/corelib/indexed_list_access_test.dart @@ -0,0 +1,50 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +// Check that indexed access to lists throws correct exception if index +// is not int. + +main() { + checkList(new List(10)); + var growable = new List(); + growable.add(1); + growable.add(1); + checkList(growable); +} + +checkList(var list) { + // Check unoptimized. + Expect.isFalse(checkCatch(getIt, list, 1)); + Expect.isTrue(checkCatch(getIt, list, "hi")); + Expect.isFalse(checkCatch(putIt, list, 1)); + Expect.isTrue(checkCatch(putIt, list, "hi")); + // Optimize 'getIt' and 'putIt'. + for (int i = 0; i < 2000; i++) { + putIt(list, 1); + getIt(list, 1); + } + Expect.isTrue(checkCatch(getIt, list, "hi")); + Expect.isTrue(checkCatch(putIt, list, "hi")); +} + +checkCatch(var f, var list, var index) { + try { + f(list, index); + } on ArgumentError catch (e) { + return true; + } on TypeError catch (t) { + return true; // thrown in type checked mode. + } + return false; +} + +getIt(var a, var i) { + return a[i]; +} + +putIt(var a, var i) { + a[i] = null; +} diff --git a/tests/corelib/int_ceil_test.dart b/tests/corelib/int_ceil_test.dart new file mode 100644 index 00000000000..3d424a67a95 --- /dev/null +++ b/tests/corelib/int_ceil_test.dart @@ -0,0 +1,39 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:expect/expect.dart'; + +main() { + Expect.equals(0, 0.ceil()); + Expect.equals(1, 1.ceil()); + Expect.equals(0x1234, 0x1234.ceil()); + Expect.equals(0x12345678, 0x12345678.ceil()); + Expect.equals(0x123456789AB, 0x123456789AB.ceil()); + Expect.equals(0x123456789ABCDEF, 0x123456789ABCDEF.ceil()); + Expect.equals(0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF, + 0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.ceil()); + Expect.equals(-1, -1.ceil()); + Expect.equals(-0x1234, -0x1234.ceil()); + Expect.equals(-0x12345678, -0x12345678.ceil()); + Expect.equals(-0x123456789AB, -0x123456789AB.ceil()); + Expect.equals(-0x123456789ABCDEF, -0x123456789ABCDEF.ceil()); + Expect.equals(-0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF, + -0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.ceil()); + + Expect.isTrue(0.ceil() is int); + Expect.isTrue(1.ceil() is int); + Expect.isTrue(0x1234.ceil() is int); + Expect.isTrue(0x12345678.ceil() is int); + Expect.isTrue(0x123456789AB.ceil() is int); + Expect.isTrue(0x123456789ABCDEF.ceil() is int); + Expect + .isTrue(0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.ceil() is int); + Expect.isTrue(-1.ceil() is int); + Expect.isTrue(-0x1234.ceil() is int); + Expect.isTrue(-0x12345678.ceil() is int); + Expect.isTrue(-0x123456789AB.ceil() is int); + Expect.isTrue(-0x123456789ABCDEF.ceil() is int); + Expect + .isTrue(-0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.ceil() is int); +} diff --git a/tests/corelib/int_ceil_to_double_test.dart b/tests/corelib/int_ceil_to_double_test.dart new file mode 100644 index 00000000000..993acf17b11 --- /dev/null +++ b/tests/corelib/int_ceil_to_double_test.dart @@ -0,0 +1,39 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:expect/expect.dart'; + +main() { + Expect.equals(0.0, 0.ceilToDouble()); + Expect.equals(1.0, 1.ceilToDouble()); + Expect.equals(0x1234, 0x1234.ceilToDouble()); + Expect.equals(0x12345678, 0x12345678.ceilToDouble()); + Expect.equals(0x123456789AB, 0x123456789AB.ceilToDouble()); + Expect.equals(81985529216486900.0, 0x123456789ABCDEF.ceilToDouble()); + Expect.equals(2.7898229935051914e+55, + 0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.ceilToDouble()); + Expect.equals(-1.0, -1.ceilToDouble()); + Expect.equals(-0x1234, -0x1234.ceilToDouble()); + Expect.equals(-0x12345678, -0x12345678.ceilToDouble()); + Expect.equals(-0x123456789AB, -0x123456789AB.ceilToDouble()); + Expect.equals(-81985529216486900.0, -0x123456789ABCDEF.ceilToDouble()); + Expect.equals(-2.7898229935051914e+55, + -0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.ceilToDouble()); + + Expect.isTrue(0.ceilToDouble() is double); + Expect.isTrue(1.ceilToDouble() is double); + Expect.isTrue(0x1234.ceilToDouble() is double); + Expect.isTrue(0x12345678.ceilToDouble() is double); + Expect.isTrue(0x123456789AB.ceilToDouble() is double); + Expect.isTrue(0x123456789ABCDEF.ceilToDouble() is double); + Expect.isTrue(0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.ceilToDouble() + is double); + Expect.isTrue(-1.ceilToDouble() is double); + Expect.isTrue(-0x1234.ceilToDouble() is double); + Expect.isTrue(-0x12345678.ceilToDouble() is double); + Expect.isTrue(-0x123456789AB.ceilToDouble() is double); + Expect.isTrue(-0x123456789ABCDEF.ceilToDouble() is double); + Expect.isTrue(-0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF + .ceilToDouble() is double); +} diff --git a/tests/corelib/int_floor_test.dart b/tests/corelib/int_floor_test.dart new file mode 100644 index 00000000000..4b235b47a74 --- /dev/null +++ b/tests/corelib/int_floor_test.dart @@ -0,0 +1,39 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:expect/expect.dart'; + +main() { + Expect.equals(0, 0.floor()); + Expect.equals(1, 1.floor()); + Expect.equals(0x1234, 0x1234.floor()); + Expect.equals(0x12345678, 0x12345678.floor()); + Expect.equals(0x123456789AB, 0x123456789AB.floor()); + Expect.equals(0x123456789ABCDEF, 0x123456789ABCDEF.floor()); + Expect.equals(0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF, + 0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.floor()); + Expect.equals(-1, -1.floor()); + Expect.equals(-0x1234, -0x1234.floor()); + Expect.equals(-0x12345678, -0x12345678.floor()); + Expect.equals(-0x123456789AB, -0x123456789AB.floor()); + Expect.equals(-0x123456789ABCDEF, -0x123456789ABCDEF.floor()); + Expect.equals(-0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF, + -0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.floor()); + + Expect.isTrue(0.floor() is int); + Expect.isTrue(1.floor() is int); + Expect.isTrue(0x1234.floor() is int); + Expect.isTrue(0x12345678.floor() is int); + Expect.isTrue(0x123456789AB.floor() is int); + Expect.isTrue(0x123456789ABCDEF.floor() is int); + Expect + .isTrue(0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.floor() is int); + Expect.isTrue(-1.floor() is int); + Expect.isTrue(-0x1234.floor() is int); + Expect.isTrue(-0x12345678.floor() is int); + Expect.isTrue(-0x123456789AB.floor() is int); + Expect.isTrue(-0x123456789ABCDEF.floor() is int); + Expect.isTrue( + -0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.floor() is int); +} diff --git a/tests/corelib/int_floor_to_double_test.dart b/tests/corelib/int_floor_to_double_test.dart new file mode 100644 index 00000000000..e87ae8c41f1 --- /dev/null +++ b/tests/corelib/int_floor_to_double_test.dart @@ -0,0 +1,39 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:expect/expect.dart'; + +main() { + Expect.equals(0.0, 0.floorToDouble()); + Expect.equals(1.0, 1.floorToDouble()); + Expect.equals(0x1234, 0x1234.floorToDouble()); + Expect.equals(0x12345678, 0x12345678.floorToDouble()); + Expect.equals(0x123456789AB, 0x123456789AB.floorToDouble()); + Expect.equals(81985529216486900.0, 0x123456789ABCDEF.floorToDouble()); + Expect.equals(2.7898229935051914e+55, + 0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.floorToDouble()); + Expect.equals(-1.0, -1.floorToDouble()); + Expect.equals(-0x1234, -0x1234.floorToDouble()); + Expect.equals(-0x12345678, -0x12345678.floorToDouble()); + Expect.equals(-0x123456789AB, -0x123456789AB.floorToDouble()); + Expect.equals(-81985529216486900.0, -0x123456789ABCDEF.floorToDouble()); + Expect.equals(-2.7898229935051914e+55, + -0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.floorToDouble()); + + Expect.isTrue(0.floorToDouble() is double); + Expect.isTrue(1.floorToDouble() is double); + Expect.isTrue(0x1234.floorToDouble() is double); + Expect.isTrue(0x12345678.floorToDouble() is double); + Expect.isTrue(0x123456789AB.floorToDouble() is double); + Expect.isTrue(0x123456789ABCDEF.floorToDouble() is double); + Expect.isTrue(0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF + .floorToDouble() is double); + Expect.isTrue(-1.floorToDouble() is double); + Expect.isTrue(-0x1234.floorToDouble() is double); + Expect.isTrue(-0x12345678.floorToDouble() is double); + Expect.isTrue(-0x123456789AB.floorToDouble() is double); + Expect.isTrue(-0x123456789ABCDEF.floorToDouble() is double); + Expect.isTrue(-0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF + .floorToDouble() is double); +} diff --git a/tests/corelib/int_from_environment2_test.dart b/tests/corelib/int_from_environment2_test.dart new file mode 100644 index 00000000000..348f0b04a68 --- /dev/null +++ b/tests/corelib/int_from_environment2_test.dart @@ -0,0 +1,14 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. +// SharedOptions=-Da=x -Db=- -Dc=0xg -Dd=+ -Dd= + +import "package:expect/expect.dart"; + +main() { + Expect.isNull(const int.fromEnvironment('a')); + Expect.isNull(const int.fromEnvironment('b')); + Expect.isNull(const int.fromEnvironment('c')); + Expect.isNull(const int.fromEnvironment('d')); + Expect.isNull(const int.fromEnvironment('e')); +} diff --git a/tests/corelib/int_from_environment3_test.dart b/tests/corelib/int_from_environment3_test.dart new file mode 100644 index 00000000000..996338a2593 --- /dev/null +++ b/tests/corelib/int_from_environment3_test.dart @@ -0,0 +1,11 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +main() { + const int.fromEnvironment('NOT_FOUND', defaultValue: ''); // //# 01: compile-time error + const int.fromEnvironment('NOT_FOUND', defaultValue: true); // //# 02: compile-time error + const int.fromEnvironment(null); // //# 03: compile-time error + const int.fromEnvironment(1); // //# 04: compile-time error + const int.fromEnvironment([]); // //# 05: compile-time error +} diff --git a/tests/corelib/int_from_environment_test.dart b/tests/corelib/int_from_environment_test.dart new file mode 100644 index 00000000000..f6033a5177f --- /dev/null +++ b/tests/corelib/int_from_environment_test.dart @@ -0,0 +1,15 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. +// SharedOptions=-Da=1 -Db=-12 -Dc=0x123 -Dd=-0x1234 -De=+0x112296 -Df=99999999999999999999 + +import "package:expect/expect.dart"; + +main() { + Expect.equals(1, const int.fromEnvironment('a')); + Expect.equals(-12, const int.fromEnvironment('b')); + Expect.equals(0x123, const int.fromEnvironment('c')); + Expect.equals(-0x1234, const int.fromEnvironment('d')); + Expect.equals(0x112296, const int.fromEnvironment('e')); + Expect.equals(99999999999999999999, const int.fromEnvironment('f')); +} diff --git a/tests/corelib/int_modulo_arith_test.dart b/tests/corelib/int_modulo_arith_test.dart new file mode 100644 index 00000000000..7ba4d0b046f --- /dev/null +++ b/tests/corelib/int_modulo_arith_test.dart @@ -0,0 +1,197 @@ +// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +import "dart:math" show pow; + +var smallNumber = 1234567890; // is 31-bit integer. +var mediumNumber = 1234567890123456; // is 53-bit integer +var bigNumber = 590295810358705600000; // is > 64-bit integer, exact as double. + +testModPow() { + test(x, e, m, expectedResult) { + // Check that expected result is correct, using an unoptimized version. + assert(() { + if (1 is double) return true; // Don't have bignums. + slowModPow(x, e, m) { + var r = 1; + while (e > 0) { + if (e.isOdd) r = (r * x) % m; + e >>= 1; + x = (x * x) % m; + } + return r; + } + + return slowModPow(x, e, m) == expectedResult; + }); + var result = x.modPow(e, m); + Expect.equals(expectedResult, result, "$x.modPow($e, $m)"); + } + + test(10, 20, 1, 0); + test(1234567890, 1000000001, 19, 11); + test(1234567890, 19, 1000000001, 122998977); + test(19, 1234567890, 1000000001, 619059596); + test(19, 1000000001, 1234567890, 84910879); + test(1000000001, 19, 1234567890, 872984351); + test(1000000001, 1234567890, 19, 0); + test(12345678901234567890, 10000000000000000001, 19, 2); + test(12345678901234567890, 19, 10000000000000000001, 3239137215315834625); + test(19, 12345678901234567890, 10000000000000000001, 4544207837373941034); + test(19, 10000000000000000001, 12345678901234567890, 11135411705397624859); + test(10000000000000000001, 19, 12345678901234567890, 2034013733189773841); + test(10000000000000000001, 12345678901234567890, 19, 1); + test(12345678901234567890, 19, 10000000000000000001, 3239137215315834625); + test(12345678901234567890, 10000000000000000001, 19, 2); + test(123456789012345678901234567890, 123456789012345678901234567891, + 123456789012345678901234567899, 116401406051033429924651549616); + test(123456789012345678901234567890, 123456789012345678901234567899, + 123456789012345678901234567891, 123456789012345678901234567890); + test(123456789012345678901234567899, 123456789012345678901234567890, + 123456789012345678901234567891, 35088523091000351053091545070); + test(123456789012345678901234567899, 123456789012345678901234567891, + 123456789012345678901234567890, 18310047270234132455316941949); + test(123456789012345678901234567891, 123456789012345678901234567899, + 123456789012345678901234567890, 1); + test(123456789012345678901234567891, 123456789012345678901234567890, + 123456789012345678901234567899, 40128068573873018143207285483); +} + +testModInverse() { + test(x, m, expectedResult) { + //print("$x op $m == $expectedResult"); + // Check that expectedResult is an inverse. + assert(expectedResult < m); + // The 1 % m handles the m = 1 special case. + // This test may overflow if we don't have bignums, so only run on VM. + assert(1 is double || (((x % m) * expectedResult) - 1) % m == 0); + + var result = x.modInverse(m); + Expect.equals(expectedResult, result, "$x modinv $m"); + + if (x > m) { + x = x % m; + var result = x.modInverse(m); + Expect.equals(expectedResult, result, "$x modinv $m"); + } + } + + testThrows(x, m) { + // Throws if not co-prime, which is a symmetric property. + Expect.throws(() => x.modInverse(m), null, "$x modinv $m"); + Expect.throws(() => m.modInverse(x), null, "$m modinv $x"); + } + + test(1, 1, 0); + + testThrows(0, 1000000001); + testThrows(2, 4); + testThrows(99, 9); + testThrows(19, 1000000001); + testThrows(123456789012345678901234567890, 123456789012345678901234567899); + + // Co-prime numbers + test(1234567890, 19, 11); + test(1234567890, 1000000001, 189108911); + test(19, 1234567890, 519818059); + test(1000000001, 1234567890, 1001100101); + + test(12345, 12346, 12345); + test(12345, 12346, 12345); + + test(smallNumber, 137, 42); + test(137, smallNumber, 856087223); + test(mediumNumber, 137, 77); + test(137, mediumNumber, 540686667207353); + test(bigNumber, 137, 128); // //# bignum: ok + // Bigger numbers as modulo is tested in big_integer_arith_vm_test.dart. + // Big doubles are not co-prime, so there is nothing to test for dart2js. +} + +testGcd() { + // Call testFunc with all combinations and orders of plus/minus + // value and other. + callCombos(value, other, testFunc) { + testFunc(value, other); + testFunc(value, -other); + testFunc(-value, other); + testFunc(-value, -other); + if (value == other) return; + testFunc(other, value); + testFunc(other, -value); + testFunc(-other, value); + testFunc(-other, -value); + } + + // Test that gcd of value and other (non-negative) is expectedResult. + // Tests all combinations of positive and negative values and order of + // operands, so use positive values and order is not important. + test(value, other, expectedResult) { + // Check for bug in test. + assert(expectedResult == 0 || value % expectedResult == 0); + assert(expectedResult == 0 || other % expectedResult == 0); + callCombos(value, other, (a, b) { + var result = a.gcd(b); + + /// Check that the result is a divisor. + Expect.equals(0, result == 0 ? a : a % result, "$result | $a"); + Expect.equals(0, result == 0 ? b : b % result, "$result | $b"); + // Check for bug in test. If assert fails, the expected value is too low, + // and the gcd call has found a greater common divisor. + assert(result >= expectedResult); + Expect.equals(expectedResult, result, "$a.gcd($b)"); + }); + } + + // Test that gcd of value and other (non-negative) throws. + testThrows(value, other) { + callCombos(value, other, (a, b) { + Expect.throws(() => a.gcd(b), null, "$a.gcd($b)"); + }); + } + + testThrows(2.5, 5); // Not a method on double. + testThrows(5, 2.5); // Not accepting non-int arguments. + + // Format: + // test(value1, value2, expectedResult); + test(1, 1, 1); // both are 1 + test(1, 2, 1); // one is 1 + test(3, 5, 1); // coprime. + test(37, 37, 37); // Same larger prime. + + test(9999, 7272, 909); // Larger numbers + + test(0, 1000, 1000); // One operand is zero. + test(0, 0, 0); // Both operands are zero. + + // Multiplying both operands by a number multiplies result by same number. + test(693, 609, 21); + test(693 << 5, 609 << 5, 21 << 5); + test(693 * 937, 609 * 937, 21 * 937); + test(693 * pow(2, 32), 609 * pow(2, 32), 21 * pow(2, 32)); + test(693 * pow(2, 52), 609 * pow(2, 52), 21 * pow(2, 52)); + test(693 * pow(2, 53), 609 * pow(2, 53), 21 * pow(2, 53)); // Regression. + test(693 * pow(2, 99), 609 * pow(2, 99), 21 * pow(2, 99)); + + test(1234567890, 19, 1); + test(1234567890, 1000000001, 1); + test(19, 1000000001, 19); + + test(0x3FFFFFFF, 0x3FFFFFFF, 0x3FFFFFFF); + test(0x3FFFFFFF, 0x40000000, 1); + + test(pow(2, 54), pow(2, 53), pow(2, 53)); + + test((pow(2, 52) - 1) * pow(2, 14), (pow(2, 26) - 1) * pow(2, 22), + (pow(2, 26) - 1) * pow(2, 14)); +} + +main() { + testModPow(); // //# modPow: ok + testModInverse(); + testGcd(); +} diff --git a/tests/corelib/int_parse_radix_bad_handler_test.dart b/tests/corelib/int_parse_radix_bad_handler_test.dart new file mode 100644 index 00000000000..58009fa7fce --- /dev/null +++ b/tests/corelib/int_parse_radix_bad_handler_test.dart @@ -0,0 +1,15 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +void main() { + // If handleError isn't an unary function, and it's called, it also throws + // (either TypeError in checked mode, or some failure in unchecked mode). + + // These are compile time errors for strong mode. + Expect.throws(() => int.parse("9", radix: 8, onError: "not a function")); + Expect.throws(() => int.parse("9", radix: 8, onError: () => 42)); + Expect.throws(() => int.parse("9", radix: 8, onError: (v1, v2) => 42)); +} diff --git a/tests/corelib/int_parse_radix_test.dart b/tests/corelib/int_parse_radix_test.dart new file mode 100644 index 00000000000..0757b960ebf --- /dev/null +++ b/tests/corelib/int_parse_radix_test.dart @@ -0,0 +1,147 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; +import "dart:math" show pow; + +void main() { + const String oneByteWhiteSpace = "\x09\x0a\x0b\x0c\x0d\x20" + "\x85" // //# 01: ok + "\xa0"; + const String whiteSpace = "$oneByteWhiteSpace\u1680" + "\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a" + "\u2028\u2029\u202f\u205f\u3000\ufeff"; + + var digits = "0123456789abcdefghijklmnopqrstuvwxyz"; + var zeros = "0" * 64; + + for (int i = 0; i < whiteSpace.length; i++) { + var ws = whiteSpace[i]; + Expect.equals(0, int.parse("${ws}0${ws}", radix: 2)); + } + + void testParse(int result, String radixString, int radix) { + var m = "$radixString/$radix->$result"; + Expect.equals( + result, int.parse(radixString.toLowerCase(), radix: radix), m); + Expect.equals( + result, int.parse(radixString.toUpperCase(), radix: radix), m); + Expect.equals(result, int.parse(" $radixString", radix: radix), m); + Expect.equals(result, int.parse("$radixString ", radix: radix), m); + Expect.equals(result, int.parse(" $radixString ", radix: radix), m); + Expect.equals(result, int.parse("+$radixString", radix: radix), m); + Expect.equals(result, int.parse(" +$radixString", radix: radix), m); + Expect.equals(result, int.parse("+$radixString ", radix: radix), m); + Expect.equals(result, int.parse(" +$radixString ", radix: radix), m); + Expect.equals(-result, int.parse("-$radixString", radix: radix), m); + Expect.equals(-result, int.parse(" -$radixString", radix: radix), m); + Expect.equals(-result, int.parse("-$radixString ", radix: radix), m); + Expect.equals(-result, int.parse(" -$radixString ", radix: radix), m); + Expect.equals( + result, + int.parse("$oneByteWhiteSpace$radixString$oneByteWhiteSpace", + radix: radix), + m); + Expect.equals( + -result, + int.parse("$oneByteWhiteSpace-$radixString$oneByteWhiteSpace", + radix: radix), + m); + Expect.equals(result, + int.parse("$whiteSpace$radixString$whiteSpace", radix: radix), m); + Expect.equals(-result, + int.parse("$whiteSpace-$radixString$whiteSpace", radix: radix), m); + + Expect.equals(result, int.parse("$zeros$radixString", radix: radix), m); + Expect.equals(result, int.parse("+$zeros$radixString", radix: radix), m); + Expect.equals(-result, int.parse("-$zeros$radixString", radix: radix), m); + } + + for (int r = 2; r <= 36; r++) { + for (int i = 0; i <= r * r; i++) { + String radixString = i.toRadixString(r); + testParse(i, radixString, r); + } + } + + for (int i = 2; i <= 36; i++) { // //# 02: ok + // Test with bignums. // //# 02: continued + var digit = digits[i - 1]; // //# 02: continued + testParse(pow(i, 64) - 1, digit * 64, i); // //# 02: continued + testParse(0, zeros, i); // //# 02: continued + } // //# 02: continued + + // Allow both upper- and lower-case letters. + Expect.equals(0xABCD, int.parse("ABCD", radix: 16)); + Expect.equals(0xABCD, int.parse("abcd", radix: 16)); + Expect.equals(15628859, int.parse("09azAZ", radix: 36)); + // Big number. + Expect.equals(0x12345678123456781234567812345678, // //# 02: continued + int.parse("0x1234567812345678" // //# 02: continued + "1234567812345678")); // //# 02: continued + // Allow whitespace before and after the number. + Expect.equals(1, int.parse(" 1", radix: 2)); + Expect.equals(1, int.parse("1 ", radix: 2)); + Expect.equals(1, int.parse(" 1 ", radix: 2)); + Expect.equals(1, int.parse("\n1", radix: 2)); + Expect.equals(1, int.parse("1\n", radix: 2)); + Expect.equals(1, int.parse("\n1\n", radix: 2)); + Expect.equals(1, int.parse("+1", radix: 2)); + + void testFails(String source, int radix) { + Expect.throws(() { + throw int.parse(source, radix: radix, onError: (s) { + throw "FAIL"; + }); + }, isFail, "$source/$radix"); + Expect.equals(-999, int.parse(source, radix: radix, onError: (s) => -999)); + } + + for (int i = 2; i < 36; i++) { + var char = i.toRadixString(36); + testFails(char.toLowerCase(), i); + testFails(char.toUpperCase(), i); + } + testFails("", 2); + testFails("+ 1", 2); // No space between sign and digits. + testFails("- 1", 2); // No space between sign and digits. + testFails("0x", null); + for (int i = 2; i <= 33; i++) { + // No 0x specially allowed. + // At radix 34 and above, "x" is a valid digit. + testFails("0x10", i); + } + + testBadTypes(var source, var radix) { + if (!typeAssertionsEnabled) { + // No promises on what error is thrown if the type doesn't match. + // Likely either ArgumentError or NoSuchMethodError. + Expect.throws(() => int.parse(source, radix: radix, onError: (s) => 0)); + return; + } + // With type assertions enabled we can be more precise. + Expect.throws(() => int.parse(source, radix: radix, onError: (s) => 0), + (e) => e is TypeError || e is CastError); + } + + testBadTypes(9, 10); + testBadTypes(true, 10); + testBadTypes("0", true); + testBadTypes("0", "10"); + + testBadArguments(String source, int radix) { + // If the types match, it should be an ArgumentError of some sort. + Expect.throws(() => int.parse(source, radix: radix, onError: (s) => 0), + (e) => e is ArgumentError); + } + + testBadArguments("0", -1); + testBadArguments("0", 0); + testBadArguments("0", 1); + testBadArguments("0", 37); + + // See also int_parse_radix_bad_handler_test.dart +} + +bool isFail(e) => e == "FAIL"; diff --git a/tests/corelib/int_round_test.dart b/tests/corelib/int_round_test.dart new file mode 100644 index 00000000000..0bd7ec6ed37 --- /dev/null +++ b/tests/corelib/int_round_test.dart @@ -0,0 +1,39 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:expect/expect.dart'; + +main() { + Expect.equals(0, 0.round()); + Expect.equals(1, 1.round()); + Expect.equals(0x1234, 0x1234.round()); + Expect.equals(0x12345678, 0x12345678.round()); + Expect.equals(0x123456789AB, 0x123456789AB.round()); + Expect.equals(0x123456789ABCDEF, 0x123456789ABCDEF.round()); + Expect.equals(0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF, + 0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.round()); + Expect.equals(-1, -1.round()); + Expect.equals(-0x1234, -0x1234.round()); + Expect.equals(-0x12345678, -0x12345678.round()); + Expect.equals(-0x123456789AB, -0x123456789AB.round()); + Expect.equals(-0x123456789ABCDEF, -0x123456789ABCDEF.round()); + Expect.equals(-0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF, + -0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.round()); + + Expect.isTrue(0.round() is int); + Expect.isTrue(1.round() is int); + Expect.isTrue(0x1234.round() is int); + Expect.isTrue(0x12345678.round() is int); + Expect.isTrue(0x123456789AB.round() is int); + Expect.isTrue(0x123456789ABCDEF.round() is int); + Expect + .isTrue(0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.round() is int); + Expect.isTrue(-1.round() is int); + Expect.isTrue(-0x1234.round() is int); + Expect.isTrue(-0x12345678.round() is int); + Expect.isTrue(-0x123456789AB.round() is int); + Expect.isTrue(-0x123456789ABCDEF.round() is int); + Expect.isTrue( + -0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.round() is int); +} diff --git a/tests/corelib/int_round_to_double_test.dart b/tests/corelib/int_round_to_double_test.dart new file mode 100644 index 00000000000..16cc95df88b --- /dev/null +++ b/tests/corelib/int_round_to_double_test.dart @@ -0,0 +1,39 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:expect/expect.dart'; + +main() { + Expect.equals(0.0, 0.roundToDouble()); + Expect.equals(1.0, 1.roundToDouble()); + Expect.equals(0x1234, 0x1234.roundToDouble()); + Expect.equals(0x12345678, 0x12345678.roundToDouble()); + Expect.equals(0x123456789AB, 0x123456789AB.roundToDouble()); + Expect.equals(81985529216486900.0, 0x123456789ABCDEF.roundToDouble()); + Expect.equals(2.7898229935051914e+55, + 0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.roundToDouble()); + Expect.equals(-1.0, -1.roundToDouble()); + Expect.equals(-0x1234, -0x1234.roundToDouble()); + Expect.equals(-0x12345678, -0x12345678.roundToDouble()); + Expect.equals(-0x123456789AB, -0x123456789AB.roundToDouble()); + Expect.equals(-81985529216486900.0, -0x123456789ABCDEF.roundToDouble()); + Expect.equals(-2.7898229935051914e+55, + -0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.roundToDouble()); + + Expect.isTrue(0.roundToDouble() is double); + Expect.isTrue(1.roundToDouble() is double); + Expect.isTrue(0x1234.roundToDouble() is double); + Expect.isTrue(0x12345678.roundToDouble() is double); + Expect.isTrue(0x123456789AB.roundToDouble() is double); + Expect.isTrue(0x123456789ABCDEF.roundToDouble() is double); + Expect.isTrue(0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF + .roundToDouble() is double); + Expect.isTrue(-1.roundToDouble() is double); + Expect.isTrue(-0x1234.roundToDouble() is double); + Expect.isTrue(-0x12345678.roundToDouble() is double); + Expect.isTrue(-0x123456789AB.roundToDouble() is double); + Expect.isTrue(-0x123456789ABCDEF.roundToDouble() is double); + Expect.isTrue(-0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF + .roundToDouble() is double); +} diff --git a/tests/corelib/int_to_int_test.dart b/tests/corelib/int_to_int_test.dart new file mode 100644 index 00000000000..51bd26d37f1 --- /dev/null +++ b/tests/corelib/int_to_int_test.dart @@ -0,0 +1,39 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:expect/expect.dart'; + +main() { + Expect.equals(0, 0.toInt()); + Expect.equals(1, 1.toInt()); + Expect.equals(0x1234, 0x1234.toInt()); + Expect.equals(0x12345678, 0x12345678.toInt()); + Expect.equals(0x123456789AB, 0x123456789AB.toInt()); + Expect.equals(0x123456789ABCDEF, 0x123456789ABCDEF.toInt()); + Expect.equals(0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF, + 0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.toInt()); + Expect.equals(-1, -1.toInt()); + Expect.equals(-0x1234, -0x1234.toInt()); + Expect.equals(-0x12345678, -0x12345678.toInt()); + Expect.equals(-0x123456789AB, -0x123456789AB.toInt()); + Expect.equals(-0x123456789ABCDEF, -0x123456789ABCDEF.toInt()); + Expect.equals(-0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF, + -0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.toInt()); + + Expect.isTrue(0.toInt() is int); + Expect.isTrue(1.toInt() is int); + Expect.isTrue(0x1234.toInt() is int); + Expect.isTrue(0x12345678.toInt() is int); + Expect.isTrue(0x123456789AB.toInt() is int); + Expect.isTrue(0x123456789ABCDEF.toInt() is int); + Expect + .isTrue(0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.toInt() is int); + Expect.isTrue(-1.toInt() is int); + Expect.isTrue(-0x1234.toInt() is int); + Expect.isTrue(-0x12345678.toInt() is int); + Expect.isTrue(-0x123456789AB.toInt() is int); + Expect.isTrue(-0x123456789ABCDEF.toInt() is int); + Expect.isTrue( + -0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.toInt() is int); +} diff --git a/tests/corelib/int_truncate_test.dart b/tests/corelib/int_truncate_test.dart new file mode 100644 index 00000000000..8dff5ad3d9a --- /dev/null +++ b/tests/corelib/int_truncate_test.dart @@ -0,0 +1,39 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:expect/expect.dart'; + +main() { + Expect.equals(0, 0.truncate()); + Expect.equals(1, 1.truncate()); + Expect.equals(0x1234, 0x1234.truncate()); + Expect.equals(0x12345678, 0x12345678.truncate()); + Expect.equals(0x123456789AB, 0x123456789AB.truncate()); + Expect.equals(0x123456789ABCDEF, 0x123456789ABCDEF.truncate()); + Expect.equals(0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF, + 0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.truncate()); + Expect.equals(-1, -1.truncate()); + Expect.equals(-0x1234, -0x1234.truncate()); + Expect.equals(-0x12345678, -0x12345678.truncate()); + Expect.equals(-0x123456789AB, -0x123456789AB.truncate()); + Expect.equals(-0x123456789ABCDEF, -0x123456789ABCDEF.truncate()); + Expect.equals(-0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF, + -0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.truncate()); + + Expect.isTrue(0.truncate() is int); + Expect.isTrue(1.truncate() is int); + Expect.isTrue(0x1234.truncate() is int); + Expect.isTrue(0x12345678.truncate() is int); + Expect.isTrue(0x123456789AB.truncate() is int); + Expect.isTrue(0x123456789ABCDEF.truncate() is int); + Expect.isTrue( + 0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.truncate() is int); + Expect.isTrue(-1.truncate() is int); + Expect.isTrue(-0x1234.truncate() is int); + Expect.isTrue(-0x12345678.truncate() is int); + Expect.isTrue(-0x123456789AB.truncate() is int); + Expect.isTrue(-0x123456789ABCDEF.truncate() is int); + Expect.isTrue( + -0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.truncate() is int); +} diff --git a/tests/corelib/int_truncate_to_double_test.dart b/tests/corelib/int_truncate_to_double_test.dart new file mode 100644 index 00000000000..197e1458d65 --- /dev/null +++ b/tests/corelib/int_truncate_to_double_test.dart @@ -0,0 +1,39 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:expect/expect.dart'; + +main() { + Expect.equals(0.0, 0.truncateToDouble()); + Expect.equals(1.0, 1.truncateToDouble()); + Expect.equals(0x1234, 0x1234.truncateToDouble()); + Expect.equals(0x12345678, 0x12345678.truncateToDouble()); + Expect.equals(0x123456789AB, 0x123456789AB.truncateToDouble()); + Expect.equals(81985529216486900.0, 0x123456789ABCDEF.truncateToDouble()); + Expect.equals(2.7898229935051914e+55, + 0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.truncateToDouble()); + Expect.equals(-1.0, -1.truncateToDouble()); + Expect.equals(-0x1234, -0x1234.truncateToDouble()); + Expect.equals(-0x12345678, -0x12345678.truncateToDouble()); + Expect.equals(-0x123456789AB, -0x123456789AB.truncateToDouble()); + Expect.equals(-81985529216486900.0, -0x123456789ABCDEF.truncateToDouble()); + Expect.equals(-2.7898229935051914e+55, + -0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF.truncateToDouble()); + + Expect.isTrue(0.truncateToDouble() is double); + Expect.isTrue(1.truncateToDouble() is double); + Expect.isTrue(0x1234.truncateToDouble() is double); + Expect.isTrue(0x12345678.truncateToDouble() is double); + Expect.isTrue(0x123456789AB.truncateToDouble() is double); + Expect.isTrue(0x123456789ABCDEF.truncateToDouble() is double); + Expect.isTrue(0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF + .truncateToDouble() is double); + Expect.isTrue(-1.truncateToDouble() is double); + Expect.isTrue(-0x1234.truncateToDouble() is double); + Expect.isTrue(-0x12345678.truncateToDouble() is double); + Expect.isTrue(-0x123456789AB.truncateToDouble() is double); + Expect.isTrue(-0x123456789ABCDEF.truncateToDouble() is double); + Expect.isTrue(-0x123456789ABCDEF0123456789ABCDEF0123456789ABCDEF + .truncateToDouble() is double); +} diff --git a/tests/corelib/integer_to_radix_string_test.dart b/tests/corelib/integer_to_radix_string_test.dart new file mode 100644 index 00000000000..3b2fac8da5d --- /dev/null +++ b/tests/corelib/integer_to_radix_string_test.dart @@ -0,0 +1,95 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + // Test that we accept radix 2 to 36 and that we use lower-case + // letters. + var expected = [ + '0', + '1', + '2', + '3', + '4', + '5', + '6', + '7', + '8', + '9', + 'a', + 'b', + 'c', + 'd', + 'e', + 'f', + 'g', + 'h', + 'i', + 'j', + 'k', + 'l', + 'm', + 'n', + 'o', + 'p', + 'q', + 'r', + 's', + 't', + 'u', + 'v', + 'w', + 'x', + 'y', + 'z' + ]; + for (var radix = 2; radix <= 36; radix++) { + for (var i = 0; i < radix; i++) { + Expect.equals(expected[i], i.toRadixString(radix)); + } + } + + var illegalRadices = [-1, 0, 1, 37]; + for (var radix in illegalRadices) { + try { + 42.toRadixString(radix); + Expect.fail("Exception expected"); + } on ArgumentError catch (e) { + // Nothing to do. + } + } + + // Try large numbers (regression test for issue 15316). + var bignums = [ + 0x80000000, + 0x100000000, + 0x10000000000000, + 0x10000000000001, // 53 significant bits. + 0x20000000000000, + 0x20000000000002, + 0x1000000000000000, + 0x1000000000000100, + 0x2000000000000000, + 0x2000000000000200, + 0x8000000000000000, + 0x8000000000000800, + 0x10000000000000000, + 0x10000000000001000, + 0x100000000000010000, + 0x1000000000000100000, + 0x10000000000001000000, + 0x100000000000010000000, + 0x1000000000000100000000, + 0x10000000000001000000000, + ]; + for (var bignum in bignums) { + for (int radix = 2; radix <= 36; radix++) { + String digits = bignum.toRadixString(radix); + int result = int.parse(digits, radix: radix); + Expect.equals( + bignum, result, "${bignum.toRadixString(16)} -> $digits/$radix"); + } + } +} diff --git a/tests/corelib/integer_to_string_test.dart b/tests/corelib/integer_to_string_test.dart new file mode 100644 index 00000000000..64a64b0504f --- /dev/null +++ b/tests/corelib/integer_to_string_test.dart @@ -0,0 +1,89 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + /// Test that converting [value] to a string gives [expect]. + /// Also test that `-value` gives `"-"+expect`. + test(int value, String expect) { + Expect.equals(expect, value.toString()); + Expect.equals(expect, "$value"); + Expect.equals(expect, (new StringBuffer()..write(value)).toString()); + if (value == 0) return; + expect = "-$expect"; + value = -value; + Expect.equals(expect, value.toString()); + Expect.equals(expect, "$value"); + Expect.equals(expect, (new StringBuffer()..write(value)).toString()); + } + + // Very simple tests. + test(0, "0"); + test(1, "1"); + test(2, "2"); + test(5, "5"); + + // Binary special cases. + + // ~2^30. + test(0x3fffffff, "1073741823"); + test(0x40000000, "1073741824"); + test(0x40000001, "1073741825"); + // ~2^31. + test(0x7fffffff, "2147483647"); + test(0x80000000, "2147483648"); + test(0x80000001, "2147483649"); + // ~2^32. + test(0xffffffff, "4294967295"); + test(0x100000000, "4294967296"); + test(0x100000001, "4294967297"); + + // ~2^51. + test(0x7ffffffffffff, "2251799813685247"); + test(0x8000000000000, "2251799813685248"); + test(0x8000000000001, "2251799813685249"); + // ~2^52. + test(0xfffffffffffff, "4503599627370495"); + test(0x10000000000000, "4503599627370496"); + test(0x10000000000001, "4503599627370497"); + // ~2^53. + test(0x1fffffffffffff, "9007199254740991"); + test(0x20000000000000, "9007199254740992"); + test(0x20000000000001, "9007199254740993"); // //# 01: ok + // ~2^62. + test(0x3fffffffffffffff, "4611686018427387903"); // //# 01: continued + test(0x4000000000000000, "4611686018427387904"); // //# 01: continued + test(0x4000000000000001, "4611686018427387905"); // //# 01: continued + // ~2^63. + test(0x7fffffffffffffff, "9223372036854775807"); // //# 01: continued + test(0x8000000000000000, "9223372036854775808"); // //# 01: continued + test(0x8000000000000001, "9223372036854775809"); // //# 01: continued + // ~2^64. + test(0xffffffffffffffff, "18446744073709551615"); // //# 01: continued + test(0x10000000000000000, "18446744073709551616"); // //# 01: continued + test(0x10000000000000001, "18446744073709551617"); // //# 01: continued + // Big bignum. + test(123456789012345678901234567890, // //# 01: continued + "123456789012345678901234567890"); // //# 01: continued + + // Decimal special cases. + + int number = 10; + // Numbers 99..99, 100...00, and 100..01 up to 23 digits. + for (int i = 1; i < 15; i++) { + // Works in dart2js up to 10^15. + test(number - 1, "9" * i); + test(number, "1" + "0" * i); + test(number + 1, "1" + "0" * (i - 1) + "1"); + number *= 10; + } + // Fails to represent exactly in dart2js. + for (int i = 15; i < 22; i++) { // //# 01: continued + test(number - 1, "9" * i); // //# 01: continued + test(number, "1" + "0" * i); // //# 01: continued + test(number + 1, "1" + "0" * (i - 1) + "1"); // //# 01: continued + number *= 10; // //# 01: continued + } // //# 01: continued +} diff --git a/tests/corelib/is_operator_basic_types_test.dart b/tests/corelib/is_operator_basic_types_test.dart new file mode 100644 index 00000000000..772afb2fb50 --- /dev/null +++ b/tests/corelib/is_operator_basic_types_test.dart @@ -0,0 +1,61 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. +// Dart test program for the "is" type test operator. + +import "package:expect/expect.dart"; + +check(args) { + var list = args[0]; + var string = args[1]; + var nullObject = args[2]; + + Expect.isTrue(list is Object); + Expect.isTrue(list is List); + Expect.isTrue(list is Iterable); + Expect.isFalse(list is Comparable); + Expect.isFalse(list is Pattern); + Expect.isFalse(list is String); + + Expect.isFalse(list is! List); + Expect.isFalse(list is! Iterable); + Expect.isTrue(list is! Comparable); + Expect.isTrue(list is! Pattern); + Expect.isTrue(list is! String); + + Expect.isTrue(string is Object); + Expect.isFalse(string is List); + Expect.isFalse(string is Iterable); + Expect.isTrue(string is Comparable); + Expect.isTrue(string is Pattern); + Expect.isTrue(string is String); + + Expect.isTrue(string is! List); + Expect.isTrue(string is! Iterable); + Expect.isFalse(string is! Comparable); + Expect.isFalse(string is! Pattern); + Expect.isFalse(string is! String); + + Expect.isTrue(nullObject is Object); + Expect.isFalse(nullObject is List); + Expect.isFalse(nullObject is Iterable); + Expect.isFalse(nullObject is Comparable); + Expect.isFalse(nullObject is Pattern); + Expect.isFalse(nullObject is String); + + Expect.isTrue(nullObject is! List); + Expect.isTrue(nullObject is! Iterable); + Expect.isTrue(nullObject is! Comparable); + Expect.isTrue(nullObject is! Pattern); + Expect.isTrue(nullObject is! String); +} + +main() { + // Try to make it hard for an optimizing compiler to inline the + // tests. + check([[], 'string', null]); + + // Try to make it even harder. + var string = new String.fromCharCodes([new DateTime.now().year % 100 + 1]); + check([string.codeUnits, string, null]); +} diff --git a/tests/corelib/iterable_contains2_test.dart b/tests/corelib/iterable_contains2_test.dart new file mode 100644 index 00000000000..d4714c72bef --- /dev/null +++ b/tests/corelib/iterable_contains2_test.dart @@ -0,0 +1,38 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +// Tests for the contains methods on lists. + +class A { + const A(); +} + +class B extends A { + const B(); +} + +main() { + var list = [new B()]; + var set = new Set(); + set.add(new B()); + var iterable1 = list.map((x) => x); + var iterable2 = list.take(1); + var list2 = const [const B()]; + var iterable3 = list2.map((x) => x); + var iterable4 = list2.take(1); + var iterables = [ + list, + set, + iterable1, + iterable2, + list2, + iterable3, + iterable4 + ]; + for (var iterable in iterables) { + Expect.isFalse(iterable.contains(new A())); + } +} diff --git a/tests/corelib/iterable_contains_test.dart b/tests/corelib/iterable_contains_test.dart new file mode 100644 index 00000000000..052298e40a1 --- /dev/null +++ b/tests/corelib/iterable_contains_test.dart @@ -0,0 +1,48 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +// Tests for the contains methods on lists. + +test(list, notInList) { + testList(list) { + for (int i = 0; i < list.length; i++) { + var elem = list[i]; + Expect.isTrue(list.contains(list[i]), "$list.contains($elem)"); + } + Expect.isFalse(list.contains(notInList), "!$list.contains($notInList)"); + } + + List fixedList = new List(list.length); + List growList = new List(); + for (int i = 0; i < list.length; i++) { + fixedList[i] = list[i]; + growList.add(list[i]); + } + testList(list); + testList(fixedList); + testList(growList); +} + +class C { + const C(); +} + +class Niet { + bool operator ==(other) => false; +} + +main() { + test(const ["a", "b", "c", null], "d"); + test(const [1, 2, 3, null], 0); + test(const [true, false], null); + test(const [const C(), const C(), null], new C()); + test([new C(), new C(), new C(), null], new C()); + test(const [0.0, 1.0, 5e-324, 1e+308, double.INFINITY], 2.0); + Expect.isTrue(const [-0.0].contains(0.0)); + Expect.isFalse(const [double.NAN].contains(double.NAN)); + var niet = new Niet(); + Expect.isFalse([niet].contains(niet)); +} diff --git a/tests/corelib/iterable_element_at_test.dart b/tests/corelib/iterable_element_at_test.dart new file mode 100644 index 00000000000..364e94a5c8c --- /dev/null +++ b/tests/corelib/iterable_element_at_test.dart @@ -0,0 +1,42 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + List list1 = [1, 2, 3]; + List list2 = const [4, 5, 6]; + List list3 = []; + Set set1 = new Set(); + set1..add(11)..add(12)..add(13); + Set set2 = new Set(); + + Expect.equals(1, list1.elementAt(0)); + Expect.equals(2, list1.elementAt(1)); + Expect.equals(3, list1.elementAt(2)); + Expect.throws( + () => list1.elementAt("2"), (e) => e is ArgumentError || e is TypeError); + Expect.throws(() => list1.elementAt(-1), (e) => e is ArgumentError); + Expect.throws(() => list1.elementAt(3), (e) => e is RangeError); + + Expect.equals(4, list2.elementAt(0)); + Expect.equals(5, list2.elementAt(1)); + Expect.equals(6, list2.elementAt(2)); + Expect.throws( + () => list2.elementAt("2"), (e) => e is ArgumentError || e is TypeError); + Expect.throws(() => list2.elementAt(-1), (e) => e is ArgumentError); + Expect.throws(() => list2.elementAt(3), (e) => e is RangeError); + + Expect.isTrue(set1.contains(set1.elementAt(0))); + Expect.isTrue(set1.contains(set1.elementAt(1))); + Expect.isTrue(set1.contains(set1.elementAt(2))); + Expect.throws(() => set1.elementAt(-1), (e) => e is ArgumentError); + Expect.throws(() => set1.elementAt(3), (e) => e is RangeError); + + Expect.throws( + () => set2.elementAt("2"), (e) => e is ArgumentError || e is TypeError); + Expect.throws(() => set2.elementAt(-1), (e) => e is ArgumentError); + Expect.throws(() => set2.elementAt(0), (e) => e is RangeError); + Expect.throws(() => set2.elementAt(1), (e) => e is RangeError); +} diff --git a/tests/corelib/iterable_empty_test.dart b/tests/corelib/iterable_empty_test.dart new file mode 100644 index 00000000000..79221982f51 --- /dev/null +++ b/tests/corelib/iterable_empty_test.dart @@ -0,0 +1,71 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + testEmpty(name, it, [depth = 2]) { + Expect.isTrue(it.isEmpty, name); + Expect.isFalse(it.isNotEmpty, name); + Expect.equals(0, it.length, name); + Expect.isFalse(it.contains(null), name); + Expect.isFalse(it.any((x) => true), name); + Expect.isTrue(it.every((x) => false), name); + Expect.throws(() => it.first, (e) => e is StateError, name); + Expect.throws(() => it.last, (e) => e is StateError, name); + Expect.throws(() => it.single, (e) => e is StateError, name); + Expect.throws(() => it.elementAt(0), (e) => e is RangeError, name); + Expect.throws(() => it.reduce((a, b) => a), (e) => e is StateError, name); + Expect.throws( + () => it.singleWhere((_) => true), (e) => e is StateError, name); + Expect.equals(42, it.fold(42, (a, b) => "not 42"), name); + Expect.equals(42, it.firstWhere((v) => true, orElse: () => 42), name); + Expect.equals(42, it.lastWhere((v) => true, orElse: () => 42), name); + Expect.equals("", it.join("separator"), name); + Expect.equals("()", it.toString(), name); + Expect.listEquals([], it.toList(), name); + Expect.listEquals([], it.toList(growable: false), name); + Expect.listEquals([], it.toList(growable: true), name); + Expect.equals(0, it.toSet().length, name); + // Doesn't throw: + it.forEach((v) => throw v); + for (var v in it) { + throw v; + } + // Check that returned iterables are also empty. + if (depth > 0) { + testEmpty("$name-map", it.map((x) => x), depth - 1); + testEmpty("$name-where", it.where((x) => true), depth - 1); + testEmpty("$name-expand", it.expand((x) => [x]), depth - 1); + testEmpty("$name-skip", it.skip(1), depth - 1); + testEmpty("$name-take", it.take(2), depth - 1); + testEmpty("$name-skipWhile", it.skipWhile((v) => false), depth - 1); + testEmpty("$name-takeWhile", it.takeWhile((v) => true), depth - 1); + } + } + + testType(name, it, [depth = 2]) { + Expect.isTrue(it is Iterable, name); + Expect.isFalse(it is Iterable, name); + if (depth > 0) { + testType("$name-where", it.where((_) => true), depth - 1); + testType("$name-skip", it.skip(1), depth - 1); + testType("$name-take", it.take(1), depth - 1); + testType("$name-skipWhile", it.skipWhile((_) => false), depth - 1); + testType("$name-takeWhile", it.takeWhile((_) => true), depth - 1); + testType("$name-toList", it.toList(), depth - 1); + testType("$name-toList", it.toList(growable: false), depth - 1); + testType("$name-toList", it.toList(growable: true), depth - 1); + testType("$name-toSet", it.toSet(), depth - 1); + } + } + + test(name, it) { + testEmpty(name, it); + testType(name, it); + } + + test("const", const Iterable.empty()); + test("new", new Iterable.empty()); +} diff --git a/tests/corelib/iterable_expand_test.dart b/tests/corelib/iterable_expand_test.dart new file mode 100644 index 00000000000..a02787a6108 --- /dev/null +++ b/tests/corelib/iterable_expand_test.dart @@ -0,0 +1,74 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; +import 'dart:collection'; + +class MyList extends ListBase { + List list; + MyList(this.list); + + get length => list.length; + set length(val) { + list.length = val; + } + + operator [](index) => list[index]; + operator []=(index, val) => list[index] = val; + + String toString() => "[" + join(", ") + "]"; +} + +main() { + test(expectation, iterable) { + Expect.listEquals(expectation, iterable.toList()); + } + + // Function not called on empty iterable. + test( + [], + [].expand((x) { + throw "not called"; + })); + + // Creating the iterable doesn't call the function. + [1].expand((x) { + throw "not called"; + }); + + test([1], [1].expand((x) => [x])); + test([1, 2, 3], [1, 2, 3].expand((x) => [x])); + + test([], [1].expand((x) => [])); + test([], [1, 2, 3].expand((x) => [])); + test([2], [1, 2, 3].expand((x) => x == 2 ? [2] : [])); + + test([1, 1, 2, 2, 3, 3], [1, 2, 3].expand((x) => [x, x])); + test([1, 1, 2], [1, 2, 3].expand((x) => [x, x, x].skip(x))); + + test([1], new MyList([1]).expand((x) => [x])); + test([1, 2, 3], new MyList([1, 2, 3]).expand((x) => [x])); + + test([], new MyList([1]).expand((x) => [])); + test([], new MyList([1, 2, 3]).expand((x) => [])); + test([2], new MyList([1, 2, 3]).expand((x) => x == 2 ? [2] : [])); + + test([1, 1, 2, 2, 3, 3], new MyList([1, 2, 3]).expand((x) => [x, x])); + test([1, 1, 2], new MyList([1, 2, 3]).expand((x) => [x, x, x].skip(x))); + + // if function throws, iteration is stopped. + Iterable iterable = [1, 2, 3].expand((x) { + if (x == 2) throw "FAIL"; + return [x, x]; + }); + Iterator it = iterable.iterator; + Expect.isTrue(it.moveNext()); + Expect.equals(1, it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(1, it.current); + Expect.throws(it.moveNext, (e) => e == "FAIL"); + // After throwing, iteration is ended. + Expect.equals(null, it.current); + Expect.isFalse(it.moveNext()); +} diff --git a/tests/corelib/iterable_first_test.dart b/tests/corelib/iterable_first_test.dart new file mode 100644 index 00000000000..8e3e7c8c9eb --- /dev/null +++ b/tests/corelib/iterable_first_test.dart @@ -0,0 +1,22 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + List list1 = [1, 2, 3]; + List list2 = const [4, 5]; + List list3 = []; + Set set1 = new Set(); + set1..add(11)..add(12)..add(13); + Set set2 = new Set(); + + Expect.equals(1, list1.first); + Expect.equals(4, list2.first); + Expect.throws(() => list3.first, (e) => e is StateError); + + Expect.isTrue(set1.contains(set1.first)); + + Expect.throws(() => set2.first, (e) => e is StateError); +} diff --git a/tests/corelib/iterable_first_where_test.dart b/tests/corelib/iterable_first_where_test.dart new file mode 100644 index 00000000000..526b685ef8f --- /dev/null +++ b/tests/corelib/iterable_first_where_test.dart @@ -0,0 +1,43 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:expect/expect.dart'; + +main() { + List list1 = [1, 2, 3]; + List list2 = const [4, 5]; + List list3 = []; + Set set1 = new Set(); + set1..add(11)..add(12)..add(13); + Set set2 = new Set(); + + Expect.equals(2, list1.firstWhere((x) => x.isEven)); + Expect.equals(1, list1.firstWhere((x) => x.isOdd)); + Expect.throws(() => list1.firstWhere((x) => x > 3), (e) => e is StateError); + Expect.equals(null, list1.firstWhere((x) => x > 3, orElse: () => null)); + Expect.equals(499, list1.firstWhere((x) => x > 3, orElse: () => 499)); + + Expect.equals(4, list2.firstWhere((x) => x.isEven)); + Expect.equals(5, list2.firstWhere((x) => x.isOdd)); + Expect.throws(() => list2.firstWhere((x) => x == 0), (e) => e is StateError); + Expect.equals(null, list2.firstWhere((x) => false, orElse: () => null)); + Expect.equals(499, list2.firstWhere((x) => false, orElse: () => 499)); + + Expect.throws(() => list3.firstWhere((x) => x == 0), (e) => e is StateError); + Expect.throws(() => list3.firstWhere((x) => true), (e) => e is StateError); + Expect.equals(null, list3.firstWhere((x) => true, orElse: () => null)); + Expect.equals("str", list3.firstWhere((x) => false, orElse: () => "str")); + + Expect.equals(12, set1.firstWhere((x) => x.isEven)); + var odd = set1.firstWhere((x) => x.isOdd); + Expect.isTrue(odd == 11 || odd == 13); + Expect.throws(() => set1.firstWhere((x) => false), (e) => e is StateError); + Expect.equals(null, set1.firstWhere((x) => false, orElse: () => null)); + Expect.equals(499, set1.firstWhere((x) => false, orElse: () => 499)); + + Expect.throws(() => set2.firstWhere((x) => false), (e) => e is StateError); + Expect.throws(() => set2.firstWhere((x) => true), (e) => e is StateError); + Expect.equals(null, set2.firstWhere((x) => true, orElse: () => null)); + Expect.equals(499, set2.firstWhere((x) => false, orElse: () => 499)); +} diff --git a/tests/corelib/iterable_fold_test.dart b/tests/corelib/iterable_fold_test.dart new file mode 100644 index 00000000000..49c1bd3f15d --- /dev/null +++ b/tests/corelib/iterable_fold_test.dart @@ -0,0 +1,202 @@ +// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; +import 'dart:collection'; +import 'dart:typed_data'; + +class MyList extends ListBase { + List list; + MyList(this.list); + + get length => list.length; + set length(val) { + list.length = val; + } + + operator [](index) => list[index]; + operator []=(index, val) => list[index] = val; +} + +id(x) => x; + +main() { + for (var iterable in [ + const [1, 2, 3], + [1, 2, 3], + new List(3) + ..[0] = 1 + ..[1] = 2 + ..[2] = 3, + {1: 1, 2: 2, 3: 3}.keys, + {1: 1, 2: 2, 3: 3}.values, + new Iterable.generate(3, (x) => x + 1), + new List.generate(3, (x) => x + 1), + [0, 1, 2, 3].where((x) => x > 0), + [0, 1, 2].map((x) => x + 1), + [ + [1, 2], + [3] + ].expand(id), + [3, 2, 1].reversed, + [0, 1, 2, 3].skip(1), + [1, 2, 3, 4].take(3), + new Uint8List(3) + ..[0] = 1 + ..[1] = 2 + ..[2] = 3, + (new HashMap() + ..[1] = 1 + ..[2] = 2 + ..[3] = 3) + .keys, + (new HashMap() + ..[1] = 1 + ..[2] = 2 + ..[3] = 3) + .values, + (new SplayTreeMap() + ..[1] = 0 + ..[2] = 0 + ..[3] = 0) + .keys, + (new SplayTreeMap() + ..[0] = 1 + ..[1] = 2 + ..[2] = 3) + .values, + new HashSet()..add(1)..add(2)..add(3), + new LinkedHashSet()..add(1)..add(2)..add(3), + new SplayTreeSet()..add(1)..add(2)..add(3), + "\x01\x02\x03".codeUnits, + "\x01\x02\x03".runes, + new MyList([1, 2, 3]), + ]) { + int callCount = 0; + var result = iterable.fold(0, (x, y) { + callCount++; + return x + y; + }); + Expect.equals(6, result, "${iterable.runtimeType}"); + Expect.equals(3, callCount); + } + + // Empty iterables are allowed. + for (var iterable in [ + const [], + [], + new List(0), + {}.keys, + {}.values, + new Iterable.generate(0, (x) => x + 1), + new List.generate(0, (x) => x + 1), + [0, 1, 2, 3].where((x) => false), + [].map((x) => x + 1), + [[], []].expand(id), + [].reversed, + [0, 1, 2, 3].skip(4), + [1, 2, 3, 4].take(0), + new Uint8List(0), + (new HashMap()).keys, + (new HashMap()).values, + (new SplayTreeMap()).keys, + (new SplayTreeMap()).values, + new HashSet(), + new LinkedHashSet(), + new SplayTreeSet(), + "".codeUnits, + "".runes, + new MyList([]), + ]) { + Expect.equals(42, iterable.fold(42, (x, y) => throw "Unreachable")); + } + + // Singleton iterables are calling reduce function. + for (var iterable in [ + const [1], + [1], + new List(1)..[0] = 1, + {1: 1}.keys, + {1: 1}.values, + new Iterable.generate(1, (x) => x + 1), + new List.generate(1, (x) => x + 1), + [0, 1, 2, 3].where((x) => x == 1), + [0].map((x) => x + 1), + [ + [], + [1] + ].expand(id), + [1].reversed, + [0, 1].skip(1), + [1, 2, 3, 4].take(1), + new Uint8List(1)..[0] = 1, + (new HashMap()..[1] = 0).keys, + (new HashMap()..[0] = 1).values, + (new SplayTreeMap()..[1] = 0).keys, + (new SplayTreeMap()..[0] = 1).values, + new HashSet()..add(1), + new LinkedHashSet()..add(1), + new SplayTreeSet()..add(1), + "\x01".codeUnits, + "\x01".runes, + new MyList([1]), + ]) { + Expect.equals(43, iterable.fold(42, (x, y) => x + y)); + } + + // Concurrent modifications not allowed. + testModification(base, modify, transform) { + var iterable = transform(base); + Expect.throws(() { + iterable.fold(0, (x, y) { + modify(base); + return x + y; + }); + }, (e) => e is ConcurrentModificationError); + } + + void add4(collection) { + collection.add(4); + } + + void put4(map) { + map[4] = 4; + } + + testModification([1, 2, 3], add4, id); + testModification(new HashSet()..add(1)..add(2)..add(3), add4, id); + testModification(new LinkedHashSet()..add(1)..add(2)..add(3), add4, id); + testModification(new SplayTreeSet()..add(1)..add(2)..add(3), add4, id); + testModification(new MyList([1, 2, 3]), add4, id); + + testModification([0, 1, 2, 3], add4, (x) => x.where((x) => x > 0)); + testModification([0, 1, 2], add4, (x) => x.map((x) => x + 1)); + testModification([ + [1, 2], + [3] + ], add4, (x) => x.expand((x) => x)); + testModification([3, 2, 1], add4, (x) => x.reversed); + testModification({1: 1, 2: 2, 3: 3}, put4, (x) => x.keys); + testModification({1: 1, 2: 2, 3: 3}, put4, (x) => x.values); + var hashMap = new HashMap() + ..[1] = 1 + ..[2] = 2 + ..[3] = 3; + testModification(hashMap, put4, (x) => x.keys); + hashMap = new HashMap() + ..[1] = 1 + ..[2] = 2 + ..[3] = 3; + testModification(hashMap, put4, (x) => x.values); + var splayMap = new SplayTreeMap() + ..[1] = 1 + ..[2] = 2 + ..[3] = 3; + testModification(splayMap, put4, (x) => x.keys); + splayMap = new SplayTreeMap() + ..[1] = 1 + ..[2] = 2 + ..[3] = 3; + testModification(splayMap, put4, (x) => x.values); +} diff --git a/tests/corelib/iterable_generate_test.dart b/tests/corelib/iterable_generate_test.dart new file mode 100644 index 00000000000..4c2a9d58aa7 --- /dev/null +++ b/tests/corelib/iterable_generate_test.dart @@ -0,0 +1,79 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + void test(expectedList, generatedIterable) { + Expect.equals(expectedList.length, generatedIterable.length); + Expect.listEquals(expectedList, generatedIterable.toList()); + } + + test([], new Iterable.generate(0)); + test([0], new Iterable.generate(1)); + test([0, 1, 2, 3, 4], new Iterable.generate(5)); + test(["0", "1", "2", "3", "4"], new Iterable.generate(5, (x) => "$x")); + test([2, 3, 4, 5, 6], new Iterable.generate(7).skip(2)); + test([0, 1, 2, 3, 4], new Iterable.generate(7).take(5)); + test([], new Iterable.generate(5).skip(6)); + test([], new Iterable.generate(5).take(0)); + test([], new Iterable.generate(5).take(3).skip(3)); + test([], new Iterable.generate(5).skip(6).take(0)); + + // Test types. + + Iterable it = new Iterable.generate(5); + Expect.isTrue(it is Iterable); + Expect.isTrue(it.iterator is Iterator); + Expect.isTrue(it is! Iterable); + Expect.isTrue(it.iterator is! Iterator); + test([0, 1, 2, 3, 4], it); + + Iterable st = new Iterable.generate(5, (x) => "$x"); + Expect.isTrue(st is Iterable); + Expect.isTrue(st.iterator is Iterator); + Expect.isFalse(st is Iterable); + Expect.isFalse(st.iterator is Iterator); + test(["0", "1", "2", "3", "4"], st); + + if (typeAssertionsEnabled) { + Expect.throws(() => new Iterable.generate(5)); + } + + // Omitted generator function means `(int x) => x`, and the type parameters + // must then be compatible with `int`. + // Check that we catch invalid type parameters. + + // Valid types: + Iterable iter1 = new Iterable.generate(5); + Expect.equals(2, iter1.elementAt(2)); + Iterable iter2 = new Iterable.generate(5); + Expect.equals(2, iter2.elementAt(2)); + Iterable iter3 = new Iterable.generate(5); + Expect.equals(2, iter3.elementAt(2)); + Iterable iter4 = new Iterable.generate(5); + Expect.equals(2, iter4.elementAt(2)); + + // Invalid types: + Expect.throws(() => new Iterable.generate(5)); + if (typeAssertionsEnabled) { // //# 01: ok + Expect.throws(() => new Iterable.generate(5).elementAt(2)); //# 01: continued + } else { // //# 01: continued + Iterable iter5 = new Iterable.generate(5); // //# 01: continued + Expect.equals(2, iter5.elementAt(2)); // //# 01: continued + } // //# 01: continued + Expect.throws(() => new Iterable.generate(5)); + + // Regression: https://github.com/dart-lang/sdk/issues/26358 + var count = 0; + var iter = new Iterable.generate(5, (v) { + count++; + return v; + }); + Expect.equals(0, count); + Expect.equals(2, iter.elementAt(2)); // Doesn't compute the earlier values. + Expect.equals(1, count); + Expect.equals(2, iter.skip(2).first); // Doesn't compute the skipped values. + Expect.equals(2, count); +} diff --git a/tests/corelib/iterable_join_test.dart b/tests/corelib/iterable_join_test.dart new file mode 100644 index 00000000000..e4f2f44afee --- /dev/null +++ b/tests/corelib/iterable_join_test.dart @@ -0,0 +1,148 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +class IC { + int count = 0; + String toString() => "${count++}"; +} + +testJoin(String expect, Iterable iterable, [String separator]) { + if (separator != null) { + Expect.equals(expect, iterable.join(separator)); + } else { + Expect.equals(expect, iterable.join()); + } +} + +testCollections() { + testJoin("", [], ","); + testJoin("", [], ""); + testJoin("", []); + testJoin("", new Set(), ","); + testJoin("", new Set(), ""); + testJoin("", new Set()); + + testJoin("42", [42], ","); + testJoin("42", [42], ""); + testJoin("42", [42]); + testJoin("42", new Set()..add(42), ","); + testJoin("42", new Set()..add(42), ""); + testJoin("42", new Set()..add(42)); + + testJoin("a,b,c,d", ["a", "b", "c", "d"], ","); + testJoin("abcd", ["a", "b", "c", "d"], ""); + testJoin("abcd", ["a", "b", "c", "d"]); + testJoin("null,b,c,d", [null, "b", "c", "d"], ","); + testJoin("1,2,3,4", [1, 2, 3, 4], ","); + var ic = new IC(); + testJoin("0,1,2,3", [ic, ic, ic, ic], ","); + + var set = new Set()..add(1)..add(2)..add(3); + var perm = new Set() + ..add("123") + ..add("132") + ..add("213") + ..add("231") + ..add("312") + ..add("321"); + var setString = set.join(); + Expect.isTrue(perm.contains(setString), "set: $setString"); + + void testArray(array) { + testJoin("1,3,5,7,9", array.where((i) => i.isOdd), ","); + testJoin("0,2,4,6,8,10,12,14,16,18", array.map((i) => i * 2), ","); + testJoin("5,6,7,8,9", array.skip(5), ","); + testJoin("5,6,7,8,9", array.skipWhile((i) => i < 5), ","); + testJoin("0,1,2,3,4", array.take(5), ","); + testJoin("0,1,2,3,4", array.takeWhile((i) => i < 5), ","); + } + + testArray([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + var fixedArray = new List(10); + for (int i = 0; i < 10; i++) { + fixedArray[i] = i; + } + testArray(fixedArray); + testArray(const [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); + + testJoin("a,b,c,d", ["a", "b", "c", "d"].map((x) => x), ","); + testJoin("abcd", ["a", "b", "c", "d"].map((x) => x), ""); + testJoin("abcd", ["a", "b", "c", "d"].map((x) => x)); + testJoin("null,b,c,d", [null, "b", "c", "d"].map((x) => x), ","); + testJoin("1,2,3,4", [1, 2, 3, 4].map((x) => x), ","); + testJoin("4,5,6,7", [ic, ic, ic, ic].map((x) => x), ","); +} + +void testStringVariants() { + // ASCII + testJoin("axbxcxd", ["a", "b", "c", "d"], "x"); + testJoin("a\u2000b\u2000c\u2000d", ["a", "b", "c", "d"], "\u2000"); + testJoin("abcd", ["a", "b", "c", "d"], ""); + testJoin("abcd", ["a", "b", "c", "d"]); + // Non-ASCII + testJoin("axbxcx\u2000", ["a", "b", "c", "\u2000"], "x"); + testJoin("a\u2000b\u2000c\u2000\u2000", ["a", "b", "c", "\u2000"], "\u2000"); + testJoin("abc\u2000", ["a", "b", "c", "\u2000"], ""); + testJoin("abc\u2000", ["a", "b", "c", "\u2000"]); + // Long-ASCII + testJoin("ax" * 255 + "a", new List.generate(256, (_) => "a"), "x"); + testJoin("a" * 256, new List.generate(256, (_) => "a")); + // Long-Non-ASCII + testJoin("a\u2000" * 255 + "a", new List.generate(256, (_) => "a"), "\u2000"); + testJoin("\u2000" * 256, new List.generate(256, (_) => "\u2000")); + testJoin( + "\u2000x" * 255 + "\u2000", new List.generate(256, (_) => "\u2000"), "x"); + + var o1 = new Stringable("x"); + var o2 = new Stringable("\ufeff"); + testJoin("xa" * 3 + "x", [o1, o1, o1, o1], "a"); + testJoin("x" * 4, [o1, o1, o1, o1], ""); + testJoin("x" * 4, [o1, o1, o1, o1]); + + testJoin("\ufeffx" * 3 + "\ufeff", [o2, o2, o2, o2], "x"); + testJoin("\ufeff" * 4, [o2, o2, o2, o2], ""); + testJoin("\ufeff" * 4, [o2, o2, o2, o2]); + + testJoin("a\u2000x\ufeff", ["a", "\u2000", o1, o2]); + testJoin("a\u2000\ufeffx", ["a", "\u2000", o2, o1]); + testJoin("ax\u2000\ufeff", ["a", o1, "\u2000", o2]); + testJoin("ax\ufeff\u2000", ["a", o1, o2, "\u2000"]); + testJoin("a\ufeffx\u2000", ["a", o2, o1, "\u2000"]); + testJoin("a\ufeff\u2000x", ["a", o2, "\u2000", o1]); + + testJoin("\u2000ax\ufeff", ["\u2000", "a", o1, o2]); + testJoin("\u2000a\ufeffx", ["\u2000", "a", o2, o1]); + testJoin("xa\u2000\ufeff", [o1, "a", "\u2000", o2]); + testJoin("xa\ufeff\u2000", [o1, "a", o2, "\u2000"]); + testJoin("\ufeffax\u2000", [o2, "a", o1, "\u2000"]); + testJoin("\ufeffa\u2000x", [o2, "a", "\u2000", o1]); + + testJoin("\u2000xa\ufeff", ["\u2000", o1, "a", o2]); + testJoin("\u2000\ufeffax", ["\u2000", o2, "a", o1]); + testJoin("x\u2000a\ufeff", [o1, "\u2000", "a", o2]); + testJoin("x\ufeffa\u2000", [o1, o2, "a", "\u2000"]); + testJoin("\ufeffxa\u2000", [o2, o1, "a", "\u2000"]); + testJoin("\ufeff\u2000ax", [o2, "\u2000", "a", o1]); + + testJoin("\u2000x\ufeffa", ["\u2000", o1, o2, "a"]); + testJoin("\u2000\ufeffxa", ["\u2000", o2, o1, "a"]); + testJoin("x\u2000\ufeffa", [o1, "\u2000", o2, "a"]); + testJoin("x\ufeff\u2000a", [o1, o2, "\u2000", "a"]); + testJoin("\ufeffx\u2000a", [o2, o1, "\u2000", "a"]); + testJoin("\ufeff\u2000xa", [o2, "\u2000", o1, "a"]); +} + +class Stringable { + final String value; + Stringable(this.value); + String toString() => value; +} + +main() { + testCollections(); + testStringVariants(); + // TODO(lrn): test scalar lists. +} diff --git a/tests/corelib/iterable_last_test.dart b/tests/corelib/iterable_last_test.dart new file mode 100644 index 00000000000..482daa06ccb --- /dev/null +++ b/tests/corelib/iterable_last_test.dart @@ -0,0 +1,22 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + List list1 = [1, 2, 3]; + List list2 = const [4, 5]; + List list3 = []; + Set set1 = new Set(); + set1..add(11)..add(12)..add(13); + Set set2 = new Set(); + + Expect.equals(3, list1.last); + Expect.equals(5, list2.last); + Expect.throws(() => list3.last, (e) => e is StateError); + + Expect.isTrue(set1.contains(set1.last)); + + Expect.throws(() => set2.last, (e) => e is StateError); +} diff --git a/tests/corelib/iterable_last_where_test.dart b/tests/corelib/iterable_last_where_test.dart new file mode 100644 index 00000000000..8cbf06e8c39 --- /dev/null +++ b/tests/corelib/iterable_last_where_test.dart @@ -0,0 +1,43 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:expect/expect.dart'; + +main() { + List list1 = [1, 2, 3]; + List list2 = const [4, 5, 6]; + List list3 = []; + Set set1 = new Set(); + set1..add(11)..add(12)..add(13); + Set set2 = new Set(); + + Expect.equals(2, list1.lastWhere((x) => x.isEven)); + Expect.equals(3, list1.lastWhere((x) => x.isOdd)); + Expect.throws(() => list1.lastWhere((x) => x > 3), (e) => e is StateError); + Expect.equals(null, list1.lastWhere((x) => x > 3, orElse: () => null)); + Expect.equals(499, list1.lastWhere((x) => x > 3, orElse: () => 499)); + + Expect.equals(6, list2.lastWhere((x) => x.isEven)); + Expect.equals(5, list2.lastWhere((x) => x.isOdd)); + Expect.throws(() => list2.lastWhere((x) => x == 0), (e) => e is StateError); + Expect.equals(null, list2.lastWhere((x) => false, orElse: () => null)); + Expect.equals(499, list2.lastWhere((x) => false, orElse: () => 499)); + + Expect.throws(() => list3.lastWhere((x) => x == 0), (e) => e is StateError); + Expect.throws(() => list3.lastWhere((x) => true), (e) => e is StateError); + Expect.equals(null, list3.lastWhere((x) => true, orElse: () => null)); + Expect.equals("str", list3.lastWhere((x) => false, orElse: () => "str")); + + Expect.equals(12, set1.lastWhere((x) => x.isEven)); + var odd = set1.lastWhere((x) => x.isOdd); + Expect.isTrue(odd == 11 || odd == 13); + Expect.throws(() => set1.lastWhere((x) => false), (e) => e is StateError); + Expect.equals(null, set1.lastWhere((x) => false, orElse: () => null)); + Expect.equals(499, set1.lastWhere((x) => false, orElse: () => 499)); + + Expect.throws(() => set2.lastWhere((x) => false), (e) => e is StateError); + Expect.throws(() => set2.lastWhere((x) => true), (e) => e is StateError); + Expect.equals(null, set2.lastWhere((x) => true, orElse: () => null)); + Expect.equals(499, set2.lastWhere((x) => false, orElse: () => 499)); +} diff --git a/tests/corelib/iterable_length_test.dart b/tests/corelib/iterable_length_test.dart new file mode 100644 index 00000000000..20c9663c62a --- /dev/null +++ b/tests/corelib/iterable_length_test.dart @@ -0,0 +1,44 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "dart:collection"; +import "package:expect/expect.dart"; + +class A extends IterableBase { + int count; + A(this.count); + + Iterator get iterator { + return new AIterator(count); + } +} + +class AIterator implements Iterator { + int _count; + int _current; + + AIterator(this._count); + + bool moveNext() { + if (_count > 0) { + _current = _count; + _count--; + return true; + } + _current = null; + return false; + } + + get current => _current; +} + +main() { + var a = new A(10); + Expect.equals(10, a.length); + a = new A(0); + Expect.equals(0, a.length); + a = new A(5); + Expect.equals(5, a.map((e) => e + 1).length); + Expect.equals(3, a.where((e) => e >= 3).length); +} diff --git a/tests/corelib/iterable_mapping_test.dart b/tests/corelib/iterable_mapping_test.dart new file mode 100644 index 00000000000..0d5997542ff --- /dev/null +++ b/tests/corelib/iterable_mapping_test.dart @@ -0,0 +1,50 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + List list1 = [1, 2, 3]; + List list2 = const [4, 5]; + List list3 = []; + Set set1 = new Set(); + set1.addAll([11, 12, 13]); + Set set2 = new Set(); + + Iterable mapped = list1.map((x) => x + 1); + Expect.listEquals([2, 3, 4], mapped.toList()); + + mapped = mapped.map((x) => x + 1); + Expect.listEquals([3, 4, 5], mapped.toList()); + + mapped = list2.map((x) => x + 1); + Expect.listEquals([5, 6], mapped.toList()); + + mapped = mapped.map((x) => x + 1); + Expect.listEquals([6, 7], mapped.toList()); + + mapped = list3.map((x) => x + 1); + Expect.listEquals([], mapped.toList()); + + mapped = mapped.map((x) => x + 1); + Expect.listEquals([], mapped.toList()); + + var expected = new Set()..addAll([12, 13, 14]); + mapped = set1.map((x) => x + 1); + Expect.isFalse(mapped is List); + Expect.setEquals(expected, mapped.toSet()); + + expected = new Set()..addAll([13, 14, 15]); + mapped = mapped.map((x) => x + 1); + Expect.isFalse(mapped is List); + Expect.setEquals(expected, mapped.toSet()); + + mapped = set2.map((x) => x + 1); + Expect.isFalse(mapped is List); + Expect.listEquals([], mapped.toList()); + + mapped = mapped.map((x) => x + 1); + Expect.isFalse(mapped is List); + Expect.listEquals([], mapped.toList()); +} diff --git a/tests/corelib/iterable_reduce_test.dart b/tests/corelib/iterable_reduce_test.dart new file mode 100644 index 00000000000..755a749eb92 --- /dev/null +++ b/tests/corelib/iterable_reduce_test.dart @@ -0,0 +1,205 @@ +// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; +import 'dart:collection'; +import 'dart:typed_data'; + +class MyList extends ListBase { + List list; + MyList(this.list); + + get length => list.length; + set length(val) { + list.length = val; + } + + operator [](index) => list[index]; + operator []=(index, val) => list[index] = val; +} + +id(x) => x; + +main() { + // Test functionality. + for (var iterable in [ + const [1, 2, 3], + [1, 2, 3], + new List(3) + ..[0] = 1 + ..[1] = 2 + ..[2] = 3, + {1: 1, 2: 2, 3: 3}.keys, + {1: 1, 2: 2, 3: 3}.values, + new Iterable.generate(3, (x) => x + 1), + new List.generate(3, (x) => x + 1), + [0, 1, 2, 3].where((x) => x > 0), + [0, 1, 2].map((x) => x + 1), + [ + [1, 2], + [3] + ].expand(id), + [3, 2, 1].reversed, + [0, 1, 2, 3].skip(1), + [1, 2, 3, 4].take(3), + new Uint8List(3) + ..[0] = 1 + ..[1] = 2 + ..[2] = 3, + (new HashMap() + ..[1] = 1 + ..[2] = 2 + ..[3] = 3) + .keys, + (new HashMap() + ..[1] = 1 + ..[2] = 2 + ..[3] = 3) + .values, + (new SplayTreeMap() + ..[1] = 0 + ..[2] = 0 + ..[3] = 0) + .keys, + (new SplayTreeMap() + ..[0] = 1 + ..[1] = 2 + ..[2] = 3) + .values, + new HashSet()..add(1)..add(2)..add(3), + new LinkedHashSet()..add(1)..add(2)..add(3), + new SplayTreeSet()..add(1)..add(2)..add(3), + "\x01\x02\x03".codeUnits, + "\x01\x02\x03".runes, + new MyList([1, 2, 3]), + ]) { + int callCount = 0; + var result = iterable.reduce((x, y) { + callCount++; + return x + y; + }); + Expect.equals(6, result, "${iterable.runtimeType}"); + Expect.equals(2, callCount); + } + + // Empty iterables not allowed. + for (var iterable in [ + const [], + [], + new List(0), + {}.keys, + {}.values, + new Iterable.generate(0, (x) => x + 1), + new List.generate(0, (x) => x + 1), + [0, 1, 2, 3].where((x) => false), + [].map((x) => x + 1), + [[], []].expand(id), + [].reversed, + [0, 1, 2, 3].skip(4), + [1, 2, 3, 4].take(0), + new Uint8List(0), + (new HashMap()).keys, + (new HashMap()).values, + (new SplayTreeMap()).keys, + (new SplayTreeMap()).values, + new HashSet(), + new LinkedHashSet(), + new SplayTreeSet(), + "".codeUnits, + "".runes, + new MyList([]), + ]) { + Expect.throws(() { + iterable.reduce((x, y) => throw "Unreachable"); + }, (e) => e is StateError); + } + + // Singleton iterables not calling reduce function. + for (var iterable in [ + const [1], + [1], + new List(1)..[0] = 1, + {1: 1}.keys, + {1: 1}.values, + new Iterable.generate(1, (x) => x + 1), + new List.generate(1, (x) => x + 1), + [0, 1, 2, 3].where((x) => x == 1), + [0].map((x) => x + 1), + [ + [], + [1] + ].expand(id), + [1].reversed, + [0, 1].skip(1), + [1, 2, 3, 4].take(1), + new Uint8List(1)..[0] = 1, + (new HashMap()..[1] = 0).keys, + (new HashMap()..[0] = 1).values, + (new SplayTreeMap()..[1] = 0).keys, + (new SplayTreeMap()..[0] = 1).values, + new HashSet()..add(1), + new LinkedHashSet()..add(1), + new SplayTreeSet()..add(1), + "\x01".codeUnits, + "\x01".runes, + new MyList([1]), + ]) { + Expect.equals(1, iterable.reduce((x, y) => throw "Unreachable")); + } + + // Concurrent modifications not allowed. + testModification(base, modify, transform) { + var iterable = transform(base); + Expect.throws(() { + iterable.reduce((x, y) { + modify(base); + return x + y; + }); + }, (e) => e is ConcurrentModificationError); + } + + void add4(collection) { + collection.add(4); + } + + void put4(map) { + map[4] = 4; + } + + testModification([1, 2, 3], add4, id); + testModification(new HashSet()..add(1)..add(2)..add(3), add4, id); + testModification(new LinkedHashSet()..add(1)..add(2)..add(3), add4, id); + testModification(new SplayTreeSet()..add(1)..add(2)..add(3), add4, id); + testModification(new MyList([1, 2, 3]), add4, id); + + testModification([0, 1, 2, 3], add4, (x) => x.where((x) => x > 0)); + testModification([0, 1, 2], add4, (x) => x.map((x) => x + 1)); + testModification([ + [1, 2], + [3] + ], add4, (x) => x.expand((x) => x)); + testModification([3, 2, 1], add4, (x) => x.reversed); + testModification({1: 1, 2: 2, 3: 3}, put4, (x) => x.keys); + testModification({1: 1, 2: 2, 3: 3}, put4, (x) => x.values); + var hashMap = new HashMap() + ..[1] = 1 + ..[2] = 2 + ..[3] = 3; + testModification(hashMap, put4, (x) => x.keys); + hashMap = new HashMap() + ..[1] = 1 + ..[2] = 2 + ..[3] = 3; + testModification(hashMap, put4, (x) => x.values); + var splayMap = new SplayTreeMap() + ..[1] = 1 + ..[2] = 2 + ..[3] = 3; + testModification(splayMap, put4, (x) => x.keys); + splayMap = new SplayTreeMap() + ..[1] = 1 + ..[2] = 2 + ..[3] = 3; + testModification(splayMap, put4, (x) => x.values); +} diff --git a/tests/corelib/iterable_return_type_test.dart b/tests/corelib/iterable_return_type_test.dart new file mode 100644 index 00000000000..dbbd66263d6 --- /dev/null +++ b/tests/corelib/iterable_return_type_test.dart @@ -0,0 +1,90 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// Regression test for dart2js where [List.addAll] was not typed +// correctly. + +import "package:expect/expect.dart"; + +import 'dart:collection'; +import 'dart:typed_data'; + +testIntIterable(iterable) { + Expect.isTrue(iterable is Iterable); + Expect.isFalse(iterable is Iterable); +} + +void testIterable(Iterable iterable, [int depth = 3]) { + testIntIterable(iterable); + if (depth > 0) { + testIterable(iterable.where((x) => true), depth - 1); + testIterable(iterable.skip(1), depth - 1); + testIterable(iterable.take(1), depth - 1); + testIterable(iterable.skipWhile((x) => false), depth - 1); + testIterable(iterable.takeWhile((x) => true), depth - 1); + testList(iterable.toList(growable: true), depth - 1); + testList(iterable.toList(growable: false), depth - 1); + testIterable(iterable.toSet(), depth - 1); + } +} + +void testList(List list, [int depth = 3]) { + testIterable(list, depth); + if (depth > 0) { + testIterable(list.getRange(0, list.length), depth - 1); + testIterable(list.reversed, depth - 1); + testMap(list.asMap(), depth - 1); + } +} + +void testMap(Map map, [int depth = 3]) { + Expect.isTrue(map is Map); + Expect.isFalse(map is Map); + Expect.isFalse(map is Map); + if (depth > 0) { + testIterable(map.keys, depth - 1); + testIterable(map.values, depth - 1); + } +} + +main() { + // Empty lists. + testList([]); + testList(new List(0)); + testList(new List()); + testList(const []); + testList(new List.generate(0, (x) => x + 1)); + // Singleton lists. + testList([1]); + testList(new List(1)..[0] = 1); + testList(new List()..add(1)); + testList(const [1]); + testList(new List.generate(1, (x) => x + 1)); + + // Typed lists. + testList(new Uint8List(1)..[0] = 1); // //# 01: ok + testList(new Int8List(1)..[0] = 1); // //# 01: continued + testList(new Uint16List(1)..[0] = 1); // //# 01: continued + testList(new Int16List(1)..[0] = 1); // //# 01: continued + testList(new Uint32List(1)..[0] = 1); // //# 01: continued + testList(new Int32List(1)..[0] = 1); // //# 01: continued + testList(new Uint64List(1)..[0] = 1); // //# 02: ok + testList(new Int64List(1)..[0] = 1); // //# 02: continued + + testIterable(new Set()..add(1)); + testIterable(new HashSet()..add(1)); + testIterable(new LinkedHashSet()..add(1)); + testIterable(new SplayTreeSet()..add(1)); + + testIterable(new Queue()..add(1)); + testIterable(new DoubleLinkedQueue()..add(1)); + testIterable(new ListQueue()..add(1)); + + testMap(new Map()..[1] = 1); + testMap(new HashMap()..[1] = 1); + testMap(new LinkedHashMap()..[1] = 1); + testMap(new SplayTreeMap()..[1] = 1); + testMap({1: 1}); + testMap(const {1: 1}); +} diff --git a/tests/corelib/iterable_single_test.dart b/tests/corelib/iterable_single_test.dart new file mode 100644 index 00000000000..2b0849e88d6 --- /dev/null +++ b/tests/corelib/iterable_single_test.dart @@ -0,0 +1,31 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + List list1a = [1]; + List list1b = [1, 2, 3]; + List list1c = []; + List list2a = const [5]; + List list2b = const [4, 5]; + List list2c = const []; + Set set1 = new Set(); + set1..add(22); + Set set2 = new Set(); + set2..add(11)..add(12)..add(13); + Set set3 = new Set(); + + Expect.equals(1, list1a.single); + Expect.throws(() => list1b.single, (e) => e is StateError); + Expect.throws(() => list1c.single, (e) => e is StateError); + + Expect.equals(5, list2a.single); + Expect.throws(() => list2b.single, (e) => e is StateError); + Expect.throws(() => list2c.single, (e) => e is StateError); + + Expect.equals(22, set1.single); + Expect.throws(() => set2.single, (e) => e is StateError); + Expect.throws(() => set3.single, (e) => e is StateError); +} diff --git a/tests/corelib/iterable_single_where_test.dart b/tests/corelib/iterable_single_where_test.dart new file mode 100644 index 00000000000..4c079104391 --- /dev/null +++ b/tests/corelib/iterable_single_where_test.dart @@ -0,0 +1,32 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:expect/expect.dart'; + +main() { + List list1 = [1, 2, 3]; + List list2 = const [4, 5, 6]; + List list3 = []; + Set set1 = new Set(); + set1..add(11)..add(12)..add(13); + Set set2 = new Set(); + + Expect.equals(2, list1.singleWhere((x) => x.isEven)); + Expect.equals(3, list1.singleWhere((x) => x == 3)); + Expect.throws( + () => list1.singleWhere((x) => x.isOdd), (e) => e is StateError); + + Expect.equals(6, list2.singleWhere((x) => x == 6)); + Expect.equals(5, list2.singleWhere((x) => x.isOdd)); + Expect.throws( + () => list2.singleWhere((x) => x.isEven), (e) => e is StateError); + + Expect.throws(() => list3.singleWhere((x) => x == 0), (e) => e is StateError); + + Expect.equals(12, set1.singleWhere((x) => x.isEven)); + Expect.equals(11, set1.singleWhere((x) => x == 11)); + Expect.throws(() => set1.singleWhere((x) => x.isOdd)); + + Expect.throws(() => set2.singleWhere((x) => true), (e) => e is StateError); +} diff --git a/tests/corelib/iterable_skip_test.dart b/tests/corelib/iterable_skip_test.dart new file mode 100644 index 00000000000..8af142bcdf8 --- /dev/null +++ b/tests/corelib/iterable_skip_test.dart @@ -0,0 +1,258 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + List list1 = [1, 2, 3]; + List list2 = const [4, 5]; + List list3 = []; + Set set1 = new Set(); + set1..add(11)..add(12)..add(13); + Set set2 = new Set(); + + Iterable skip0 = list1.skip(0); + Expect.isTrue(skip0 is! List); + Iterator it = skip0.iterator; + Expect.isNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(1, it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(2, it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(3, it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + Iterable skip1 = list1.skip(1); + Expect.isTrue(skip1 is! List); + Expect.isTrue(skip1.skip(2).skip(1) is! List); + it = skip1.iterator; + Expect.isNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(2, it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(3, it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + Iterable skip2 = list1.skip(2); + Expect.isTrue(skip2 is! List); + Expect.isTrue(skip2.skip(2).skip(1) is! List); + it = skip2.iterator; + Expect.isNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(3, it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + Iterable skip3 = list1.skip(3); + Expect.isTrue(skip3 is! List); + Expect.isTrue(skip3.skip(2).skip(1) is! List); + it = skip3.iterator; + Expect.isNull(it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + Iterable skip4 = list1.skip(4); + Expect.isTrue(skip4 is! List); + Expect.isTrue(skip4.skip(2).skip(1) is! List); + it = skip4.iterator; + Expect.isNull(it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + skip0 = list1.skip(0); + skip1 = skip0.skip(1); + skip2 = skip1.skip(1); + skip3 = skip2.skip(1); + skip4 = skip3.skip(1); + it = skip0.iterator; + Expect.isNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(1, it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(2, it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(3, it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + it = skip1.iterator; + Expect.isNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(2, it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(3, it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + it = skip2.iterator; + Expect.isNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(3, it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + it = skip3.iterator; + Expect.isNull(it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + it = skip4.iterator; + Expect.isNull(it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + skip0 = list2.skip(0); + Expect.isTrue(skip0 is! List); + Expect.isTrue(skip0.skip(2).skip(1) is! List); + it = skip0.iterator; + Expect.isNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(4, it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(5, it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + skip1 = list2.skip(1); + Expect.isTrue(skip1 is! List); + Expect.isTrue(skip1.skip(2).skip(1) is! List); + it = skip1.iterator; + Expect.isNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(5, it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + skip2 = list2.skip(2); + Expect.isTrue(skip2 is! List); + Expect.isTrue(skip2.skip(2).skip(1) is! List); + it = skip2.iterator; + Expect.isNull(it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + skip3 = list2.skip(3); + Expect.isTrue(skip3 is! List); + Expect.isTrue(skip3.skip(2).skip(1) is! List); + it = skip3.iterator; + Expect.isNull(it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + Iterable skip02 = list3.skip(0); + Expect.isTrue(skip02 is! List); + Expect.isTrue(skip02.skip(2).skip(1) is! List); + Iterator it2 = skip02.iterator; + Expect.isNull(it2.current); + Expect.isFalse(it2.moveNext()); + Expect.isNull(it2.current); + + Iterable skip12 = list3.skip(1); + Expect.isTrue(skip12 is! List); + Expect.isTrue(skip12.skip(2).skip(1) is! List); + it2 = skip12.iterator; + Expect.isNull(it2.current); + Expect.isFalse(it2.moveNext()); + Expect.isNull(it2.current); + + skip0 = set1.skip(0); + List copied = skip0.toList(); + Expect.equals(3, copied.length); + Expect.isTrue(set1.contains(copied[0])); + Expect.isTrue(set1.contains(copied[1])); + Expect.isTrue(set1.contains(copied[2])); + Expect.isTrue(copied[0] != copied[1]); + Expect.isTrue(copied[0] != copied[2]); + Expect.isTrue(copied[1] != copied[2]); + it = skip0.iterator; + Expect.isNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.isNotNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.isNotNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.isNotNull(it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + skip1 = set1.skip(1); + copied = skip1.toList(); + Expect.equals(2, copied.length); + Expect.isTrue(set1.contains(copied[0])); + Expect.isTrue(set1.contains(copied[1])); + Expect.isTrue(copied[0] != copied[1]); + it = skip1.iterator; + Expect.isNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.isNotNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.isNotNull(it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + skip2 = set1.skip(2); + copied = skip2.toList(); + Expect.equals(1, copied.length); + Expect.isTrue(set1.contains(copied[0])); + it = skip2.iterator; + Expect.isNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.isNotNull(it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + skip3 = set1.skip(3); + it = skip3.iterator; + Expect.isNull(it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + skip4 = set1.skip(4); + it = skip4.iterator; + Expect.isNull(it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + skip0 = set2.skip(0); + it = skip0.iterator; + Expect.isNull(it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + skip1 = set2.skip(1); + it = skip1.iterator; + Expect.isNull(it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + testSkipTake(Iterable input, int skip, int take) { + List expected = []; + Iterator iter = input.iterator; + for (int i = 0; i < skip; i++) iter.moveNext(); + for (int i = 0; i < take; i++) { + if (!iter.moveNext()) break; + expected.add(iter.current); + } + Expect.listEquals(expected, input.skip(skip).take(take).toList()); + } + + List longList = [1, 4, 5, 3, 8, 11, 12, 6, 9, 10, 13, 7, 2, 14, 15]; + Set bigSet = longList.toSet(); + + for (Iterable collection in [longList, longList.reversed, bigSet]) { + testSkipTake(collection, 0, 0); + testSkipTake(collection, 0, 5); + testSkipTake(collection, 0, 15); + testSkipTake(collection, 0, 25); + testSkipTake(collection, 5, 0); + testSkipTake(collection, 5, 5); + testSkipTake(collection, 5, 10); + testSkipTake(collection, 5, 20); + testSkipTake(collection, 15, 0); + testSkipTake(collection, 15, 5); + testSkipTake(collection, 20, 0); + testSkipTake(collection, 20, 5); + Expect.throws(() => collection.skip(-1), (e) => e is RangeError); + Expect.throws(() => collection.skip(1).skip(-1), (e) => e is RangeError); + } +} diff --git a/tests/corelib/iterable_skip_while_test.dart b/tests/corelib/iterable_skip_while_test.dart new file mode 100644 index 00000000000..43d8fd141b0 --- /dev/null +++ b/tests/corelib/iterable_skip_while_test.dart @@ -0,0 +1,146 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + List list1 = [1, 2, 3]; + List list2 = const [4, 5]; + List list3 = []; + Set set1 = new Set(); + set1..add(11)..add(12)..add(13); + Set set2 = new Set(); + + Iterable skipWhileTrue = list1.skipWhile((x) => true); + Iterator it = skipWhileTrue.iterator; + Expect.isNull(it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + Iterable skipWhileOdd = list1.skipWhile((x) => x.isOdd); + it = skipWhileOdd.iterator; + Expect.isNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(2, it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(3, it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + Iterable skipWhileLessThan3 = list1.skipWhile((x) => x < 3); + it = skipWhileLessThan3.iterator; + Expect.isNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(3, it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + Iterable skipWhileFalse = list1.skipWhile((x) => false); + it = skipWhileFalse.iterator; + Expect.isNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(1, it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(2, it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(3, it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + Iterable skipWhileEven = list1.skipWhile((x) => x.isEven); + it = skipWhileEven.iterator; + Expect.isNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(1, it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(2, it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(3, it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + skipWhileTrue = list2.skipWhile((x) => true); + it = skipWhileTrue.iterator; + Expect.isNull(it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + skipWhileEven = list2.skipWhile((x) => x.isEven); + it = skipWhileEven.iterator; + Expect.isNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(5, it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + skipWhileOdd = list2.skipWhile((x) => x.isOdd); + it = skipWhileOdd.iterator; + Expect.isNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(4, it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(5, it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + skipWhileFalse = list2.skipWhile((x) => false); + it = skipWhileFalse.iterator; + Expect.isNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(4, it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(5, it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + Iterable skipWhileFalse2 = list3.skipWhile((x) => false); + Iterator it2 = skipWhileFalse2.iterator; + Expect.isNull(it2.current); + Expect.isFalse(it2.moveNext()); + Expect.isNull(it2.current); + + Iterable skipWhileTrue2 = list3.skipWhile((x) => true); + it2 = skipWhileTrue2.iterator; + Expect.isNull(it2.current); + Expect.isFalse(it2.moveNext()); + Expect.isNull(it2.current); + + skipWhileTrue = set1.skipWhile((x) => true); + it = skipWhileTrue.iterator; + Expect.isNull(it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + skipWhileFalse = set1.skipWhile((x) => false); + List copied = skipWhileFalse.toList(); + Expect.equals(3, copied.length); + Expect.isTrue(set1.contains(copied[0])); + Expect.isTrue(set1.contains(copied[1])); + Expect.isTrue(set1.contains(copied[1])); + Expect.isTrue(copied[0] != copied[1]); + Expect.isTrue(copied[0] != copied[2]); + Expect.isTrue(copied[1] != copied[2]); + it = skipWhileFalse.iterator; + Expect.isNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.isTrue(it.current != null); + Expect.isTrue(it.moveNext()); + Expect.isTrue(it.current != null); + Expect.isTrue(it.moveNext()); + Expect.isTrue(it.current != null); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + skipWhileTrue = set2.skipWhile((x) => true); + it = skipWhileTrue.iterator; + Expect.isNull(it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + skipWhileFalse = set2.skipWhile((x) => false); + it = skipWhileFalse.iterator; + Expect.isNull(it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); +} diff --git a/tests/corelib/iterable_take_test.dart b/tests/corelib/iterable_take_test.dart new file mode 100644 index 00000000000..2067cc7c6c7 --- /dev/null +++ b/tests/corelib/iterable_take_test.dart @@ -0,0 +1,227 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + List list1 = [1, 2, 3]; + List list2 = const [4, 5]; + List list3 = []; + Set set1 = new Set(); + set1..add(11)..add(12)..add(13); + Set set2 = new Set(); + + Iterable take0 = list1.take(0); + Iterator it = take0.iterator; + Expect.isNull(it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + Iterable take1 = list1.take(1); + it = take1.iterator; + Expect.isNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(1, it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + Iterable take2 = list1.take(2); + it = take2.iterator; + Expect.isNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(1, it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(2, it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + Iterable take3 = list1.take(3); + it = take3.iterator; + Expect.isNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(1, it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(2, it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(3, it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + Iterable take4 = list1.take(4); + it = take4.iterator; + Expect.isNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(1, it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(2, it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(3, it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + take4 = list1.take(4); + take3 = take4.take(3); + take2 = take3.take(2); + take1 = take2.take(1); + take0 = take1.take(0); + it = take0.iterator; + Expect.isNull(it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + it = take1.iterator; + Expect.isNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(1, it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + it = take2.iterator; + Expect.isNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(1, it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(2, it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + it = take3.iterator; + Expect.isNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(1, it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(2, it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(3, it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + it = take4.iterator; + Expect.isNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(1, it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(2, it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(3, it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + take0 = list2.take(0); + it = take0.iterator; + Expect.isNull(it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + take1 = list2.take(1); + it = take1.iterator; + Expect.isNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(4, it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + take2 = list2.take(2); + it = take2.iterator; + Expect.isNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(4, it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(5, it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + take3 = list2.take(3); + it = take3.iterator; + Expect.isNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(4, it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(5, it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + Iterable take02 = list3.take(0); + Iterator it2 = take02.iterator; + Expect.isNull(it2.current); + Expect.isFalse(it2.moveNext()); + Expect.isNull(it2.current); + + Iterable take12 = list3.take(1); + it2 = take12.iterator; + Expect.isNull(it2.current); + Expect.isFalse(it2.moveNext()); + Expect.isNull(it2.current); + + take0 = set1.take(0); + it = take0.iterator; + Expect.isNull(it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + take1 = set1.take(1); + List copied = take1.toList(); + Expect.equals(1, copied.length); + Expect.isTrue(set1.contains(copied[0])); + it = take1.iterator; + Expect.isNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.isNotNull(it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + take2 = set1.take(2); + copied = take2.toList(); + Expect.equals(2, copied.length); + Expect.isTrue(set1.contains(copied[0])); + Expect.isTrue(set1.contains(copied[1])); + Expect.isTrue(copied[0] != copied[1]); + it = take2.iterator; + Expect.isNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.isNotNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.isNotNull(it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + take3 = set1.take(3); + copied = take3.toList(); + Expect.equals(3, copied.length); + Expect.isTrue(set1.contains(copied[0])); + Expect.isTrue(set1.contains(copied[1])); + Expect.isTrue(set1.contains(copied[2])); + Expect.isTrue(copied[0] != copied[1]); + Expect.isTrue(copied[0] != copied[2]); + Expect.isTrue(copied[1] != copied[2]); + it = take3.iterator; + Expect.isNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.isNotNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.isNotNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.isNotNull(it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + take0 = set2.take(0); + it = take0.iterator; + Expect.isNull(it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + take1 = set2.take(1); + it = take1.iterator; + Expect.isNull(it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + Expect.throws(() => list1.skip(-1), (e) => e is RangeError); + Expect.throws(() => list2.skip(-1), (e) => e is RangeError); + Expect.throws(() => list3.skip(-1), (e) => e is RangeError); + Expect.throws(() => set1.skip(-1), (e) => e is RangeError); + Expect.throws(() => set2.skip(-1), (e) => e is RangeError); + Expect.throws(() => list1.map((x) => x).skip(-1), (e) => e is RangeError); + Expect.throws(() => list2.map((x) => x).skip(-1), (e) => e is RangeError); + Expect.throws(() => list3.map((x) => x).skip(-1), (e) => e is RangeError); + Expect.throws(() => set1.map((x) => x).skip(-1), (e) => e is RangeError); + Expect.throws(() => set2.map((x) => x).skip(-1), (e) => e is RangeError); +} diff --git a/tests/corelib/iterable_take_while_test.dart b/tests/corelib/iterable_take_while_test.dart new file mode 100644 index 00000000000..877f749be28 --- /dev/null +++ b/tests/corelib/iterable_take_while_test.dart @@ -0,0 +1,130 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + List list1 = [1, 2, 3]; + List list2 = const [4, 5]; + List list3 = []; + Set set1 = new Set(); + set1..add(11)..add(12)..add(13); + Set set2 = new Set(); + + Iterable takeWhileFalse = list1.takeWhile((x) => false); + Iterator it = takeWhileFalse.iterator; + Expect.isNull(it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + Iterable takeWhileOdd = list1.takeWhile((x) => x.isOdd); + it = takeWhileOdd.iterator; + Expect.isNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(1, it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + Iterable takeWhileLessThan3 = list1.takeWhile((x) => x < 3); + it = takeWhileLessThan3.iterator; + Expect.isNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(1, it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(2, it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + Iterable takeEverything = list1.takeWhile((x) => true); + it = takeEverything.iterator; + Expect.isNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(1, it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(2, it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(3, it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + Iterable takeWhileEven = list1.takeWhile((x) => x.isEven); + it = takeWhileFalse.iterator; + Expect.isNull(it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + takeWhileFalse = list2.takeWhile((x) => false); + it = takeWhileFalse.iterator; + Expect.isNull(it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + takeWhileEven = list2.takeWhile((x) => x.isEven); + it = takeWhileEven.iterator; + Expect.isNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(4, it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + takeEverything = list2.takeWhile((x) => true); + it = takeEverything.iterator; + Expect.isNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(4, it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(5, it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + Iterable takeWhileFalse2 = list3.takeWhile((x) => false); + Iterator it2 = takeWhileFalse2.iterator; + Expect.isNull(it2.current); + Expect.isFalse(it2.moveNext()); + Expect.isNull(it2.current); + + Iterable takeEverything2 = list3.takeWhile((x) => true); + it2 = takeEverything2.iterator; + Expect.isNull(it2.current); + Expect.isFalse(it2.moveNext()); + Expect.isNull(it2.current); + + takeWhileFalse = set1.takeWhile((x) => false); + it = takeWhileFalse.iterator; + Expect.isNull(it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + takeEverything = set1.takeWhile((x) => true); + List copied = takeEverything.toList(); + Expect.equals(3, copied.length); + Expect.isTrue(set1.contains(copied[0])); + Expect.isTrue(set1.contains(copied[1])); + Expect.isTrue(set1.contains(copied[1])); + Expect.isTrue(copied[0] != copied[1]); + Expect.isTrue(copied[0] != copied[2]); + Expect.isTrue(copied[1] != copied[2]); + it = takeEverything.iterator; + Expect.isNull(it.current); + Expect.isTrue(it.moveNext()); + Expect.isTrue(it.current != null); + Expect.isTrue(it.moveNext()); + Expect.isTrue(it.current != null); + Expect.isTrue(it.moveNext()); + Expect.isTrue(it.current != null); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + takeWhileFalse = set2.takeWhile((x) => false); + it = takeWhileFalse.iterator; + Expect.isNull(it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + takeEverything = set2.takeWhile((x) => true); + it = takeEverything.iterator; + Expect.isNull(it.current); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); +} diff --git a/tests/corelib/iterable_test.dart b/tests/corelib/iterable_test.dart new file mode 100644 index 00000000000..e7f6299c0ae --- /dev/null +++ b/tests/corelib/iterable_test.dart @@ -0,0 +1,18 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// Regression test for dart2js where [List.addAll] was not typed +// correctly. + +import "package:expect/expect.dart"; + +import 'dart:collection'; + +class MyIterable extends IterableBase { + get iterator => [].iterator; +} + +main() { + Expect.isTrue(([]..addAll(new MyIterable())).isEmpty); +} diff --git a/tests/corelib/iterable_to_list_test.dart b/tests/corelib/iterable_to_list_test.dart new file mode 100644 index 00000000000..d81297820aa --- /dev/null +++ b/tests/corelib/iterable_to_list_test.dart @@ -0,0 +1,73 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "dart:collection" show Queue; +import "dart:typed_data" show Uint8List, Float32List; +import "package:expect/expect.dart"; + +main() { + // testIterable takes an iterable and a list expected to be equal to + // the iterable's toList result, including the type parameter of the list. + testIterable([], []); + testIterable([], []); + testIterable([], []); + testIterable([1, 2, 3], [1, 2, 3]); + testIterable([1, 2, 3], [1, 2, 3]); + testIterable(const [1, 2], [1, 2]); + testIterable(const [1, 2], [1, 2]); + testIterable({"x": 1, "y": 1}.keys, ["x", "y"]); + testIterable({"x": 1, "y": 1}.keys, ["x", "y"]); + testIterable({"x": 2, "y": 3}.values, [2, 3]); + testIterable({"x": 2, "y": 3}.values, [2, 3]); + testIterable(new Iterable.generate(3), [0, 1, 2]); + testIterable(new Iterable.generate(3), [0, 1, 2]); + testIterable( + new Iterable.generate(3, (x) => "$x"), ["0", "1", "2"]); + testIterable(new Set.from([1, 2, 3]), [1, 2, 3]); + testIterable(new Set.from([1, 2, 3]), [1, 2, 3]); + testIterable(new Queue.from([1, 2, 3]), [1, 2, 3]); + testIterable(new Queue.from([1, 2, 3]), [1, 2, 3]); + testIterable(new Uint8List.fromList([1, 2, 3]), // //# 01: ok + [1, 2, 3]); // //# 01: continued + testIterable(new Float32List.fromList([1.0, 2.0, 3.0]), // //# 01: continued + [1.0, 2.0, 3.0]); // //# 01: continued + testIterable("abc".codeUnits, [97, 98, 99]); // //# 01: continued + testIterable("abc".runes, [97, 98, 99]); +} + +testIterable(Iterable iterable, List expected, [int depth = 0]) { + print(" " * depth + "${iterable.runtimeType} vs ${expected.runtimeType}"); + test(iterable, expected); + test(iterable, expected, growable: true); + test(iterable, expected, growable: false); + if (depth < 2) { + depth++; + testIterable(iterable.map((x) => x), new List.from(expected), depth); + testIterable(iterable.where((x) => true), expected, depth); + testIterable(iterable.expand((x) => [x]), new List.from(expected), depth); + testIterable(iterable.map((x) => x), new List.from(expected), depth); + testIterable(iterable.skipWhile((x) => false), expected, depth); + testIterable(iterable.takeWhile((x) => true), expected, depth); + testIterable(iterable.skip(0), expected, depth); + testIterable(iterable.take(expected.length * 2), expected, depth); + testIterable(iterable.toSet(), expected, depth); + } +} + +test(Iterable iterable, List expected, {bool growable: true}) { + var list = iterable.toList(growable: growable); + Expect.listEquals(expected, list); + Expect.equals(expected is List, list is List, "int"); + Expect.equals(expected is List, list is List, "double"); + Expect.equals(expected is List, list is List, "str"); + if (growable) { + int length = list.length; + list.add(null); + Expect.equals(length + 1, list.length); + } else { + Expect.throws(() { + list.add(null); + }); + } +} diff --git a/tests/corelib/iterable_to_set_test.dart b/tests/corelib/iterable_to_set_test.dart new file mode 100644 index 00000000000..628ddb89b1e --- /dev/null +++ b/tests/corelib/iterable_to_set_test.dart @@ -0,0 +1,53 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + List list1 = [1, 2, 3]; + List list2 = const [4, 4]; + List list3 = []; + Set set1 = new Set(); + set1..add(11)..add(12)..add(13); + Set set2 = new Set(); + set2..add("foo")..add("bar")..add("toto"); + Set set3 = new Set(); + + var setCopy = list1.toSet(); + Expect.equals(3, setCopy.length); + Expect.isTrue(setCopy.contains(1)); + Expect.isTrue(setCopy.contains(2)); + Expect.isTrue(setCopy.contains(3)); + Expect.isTrue(setCopy is Set); + Expect.isFalse(setCopy is Set); + + setCopy = list2.toSet(); + Expect.equals(1, setCopy.length); + Expect.isTrue(setCopy.contains(4)); + Expect.isTrue(setCopy is Set); + Expect.isFalse(setCopy is Set); + + setCopy = list3.toSet(); + Expect.isTrue(setCopy.isEmpty); + Expect.isTrue(setCopy is Set); + Expect.isFalse(setCopy is Set); + + setCopy = set1.toSet(); + Expect.setEquals(set1, setCopy); + Expect.isTrue(setCopy is Set); + Expect.isFalse(setCopy is Set); + Expect.isFalse(identical(setCopy, set1)); + + setCopy = set2.toSet(); + Expect.setEquals(set2, setCopy); + Expect.isTrue(setCopy is Set); + Expect.isFalse(setCopy is Set); + Expect.isFalse(identical(setCopy, set2)); + + setCopy = set3.toSet(); + Expect.setEquals(set3, setCopy); + Expect.isTrue(setCopy is Set); + Expect.isTrue(setCopy is Set); + Expect.isFalse(identical(setCopy, set3)); +} diff --git a/tests/corelib/iterable_tostring_test.dart b/tests/corelib/iterable_tostring_test.dart new file mode 100644 index 00000000000..bb220978412 --- /dev/null +++ b/tests/corelib/iterable_tostring_test.dart @@ -0,0 +1,106 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// Test the IterableBase/IterableMixin toString method. + +import "package:expect/expect.dart"; +import "dart:collection"; + +String mkIt(int len, [func]) { + var list; + if (func == null) { + list = new List.generate(len, (x) => x); + } else { + list = new List.generate(len, func); + } + return new MyIterable(list).toString(); +} + +class MyIterable extends IterableBase { + final Iterable _base; + MyIterable(this._base); + Iterator get iterator => _base.iterator; +} + +void main() { + Expect.equals("()", mkIt(0)); + Expect.equals("(0)", mkIt(1)); + Expect.equals("(0, 1)", mkIt(2)); + Expect.equals("(0, 1, 2, 3, 4, 5, 6, 7, 8)", mkIt(9)); + + // Builds string up to 60 characters, then finishes with last two + // elements. + Expect.equals( + //0123456789012345678901234567890123456789 - 40 characters + "(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1" + "2, 13, 14, 15, 16, 17, 18, ..., 98, 99)", + mkIt(100)); + + Expect.equals( + //0123456789012345678901234567890123456789 + "(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1" + "2, 13, 14, 15, 16, 17, 18)", + mkIt(19)); + + Expect.equals( + //0123456789012345678901234567890123456789 + "(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1" + "2, 13, 14, 15, 16, 17, 18, 19)", + mkIt(20)); + + Expect.equals( + //0123456789012345678901234567890123456789 + "(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1" + "2, 13, 14, 15, 16, 17, 18, 19, 20)", + mkIt(21)); + + // Don't show last two elements if more than 100 elements total + // (can't be 100 elements in 80 characters including commas). + Expect.equals( + //0123456789012345678901234567890123456789 + "(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1" + "2, 13, 14, 15, 16, 17, 18, 19, 20, ...)", + mkIt(101)); + + // If last two elements bring total over 80 characters, drop some of + // the previous ones as well. + + Expect.equals( + //0123456789012345678901234567890123456789 + "(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 1" + "2, 13, ..., 18, xxxxxxxxxxxxxxxxxxxx)", + mkIt(20, (x) => x == 19 ? "xxxxxxxxxxxxxxxxxxxx" : "$x")); + + // Never drop the first three or the last two. + Expect.equals( + //0123456789012345678901234567890123456789 + "(xxxxxxxxxxxxxxxxx, xxxxxxxxxxxxxxxxx, x" + "xxxxxxxxxxxxxxxx, ..., 18, xxxxxxxxxxxxx" + "xxxx)", + mkIt(20, (x) => (x < 3 || x == 19) ? "xxxxxxxxxxxxxxxxx" : "$x")); + + // Never drop the first three or the last two. + Expect.equals( + //0123456789012345678901234567890123456789 + "(xxxxxxxxxxxxxxxxx, xxxxxxxxxxxxxxxxx, x" + "xxxxxxxxxxxxxxxx, ..., xxxxxxxxxxxxxxxxx" + ", 19)", + mkIt(20, (x) => (x < 3 || x == 18) ? "xxxxxxxxxxxxxxxxx" : "$x")); + + // If the first three are very long, always include them anyway. + Expect.equals( + //0123456789012345678901234567890123456789 + "(xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx," + " xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx," + " xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx," + " ..., 98, 99)", + mkIt(100, + (x) => (x < 3) ? "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" : "$x")); + + Expect.equals( + //0123456789012345678901234567890123456789 + "(, , , , , , , , , , , , , , , , , , , ," + " , , , , , , , , , , , , , , , ..., , )", + mkIt(100, (_) => "")); +} diff --git a/tests/corelib/json_map_test.dart b/tests/corelib/json_map_test.dart new file mode 100644 index 00000000000..8524e0088d8 --- /dev/null +++ b/tests/corelib/json_map_test.dart @@ -0,0 +1,334 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +library json_map_test; + +import "package:expect/expect.dart"; +import 'dart:convert' show JSON; +import 'dart:collection' show LinkedHashMap, HashMap; + +bool useReviver = false; +Map jsonify(Map map) { + String encoded = JSON.encode(map); + return useReviver + ? JSON.decode(encoded, reviver: (key, value) => value) + : JSON.decode(encoded); +} + +List listEach(Map map) { + var result = []; + map.forEach((String key, value) { + result.add(key); + result.add(value); + }); + return result; +} + +void main() { + test(false); + test(true); +} + +void test(bool revive) { + useReviver = revive; + testEmpty(jsonify({})); + testAtoB(jsonify({'a': 'b'})); + + Map map = jsonify({}); + map['a'] = 'b'; + testAtoB(map); + + map = jsonify({}); + Expect.equals('b', map.putIfAbsent('a', () => 'b')); + testAtoB(map); + + map = jsonify({}); + map.addAll({'a': 'b'}); + testAtoB(map); + + testOrder(['a', 'b', 'c', 'd', 'e', 'f']); + + testProto(); + testToString(); + testConcurrentModifications(); + testType(); + testClear(); + + testListEntry(); + testMutation(); +} + +void testEmpty(Map map) { + for (int i = 0; i < 2; i++) { + Expect.equals(0, map.length); + Expect.isTrue(map.isEmpty); + Expect.isFalse(map.isNotEmpty); + Expect.listEquals([], map.keys.toList()); + Expect.listEquals([], map.values.toList()); + Expect.isNull(map['a']); + Expect.listEquals([], listEach(map)); + Expect.isFalse(map.containsKey('a')); + Expect.isFalse(map.containsValue('a')); + Expect.isNull(map.remove('a')); + testLookupNonExistingKeys(map); + testLookupNonExistingValues(map); + map.clear(); + } +} + +void testAtoB(Map map) { + Expect.equals(1, map.length); + Expect.isFalse(map.isEmpty); + Expect.isTrue(map.isNotEmpty); + Expect.listEquals(['a'], map.keys.toList()); + Expect.listEquals(['b'], map.values.toList()); + Expect.equals('b', map['a']); + Expect.listEquals(['a', 'b'], listEach(map)); + Expect.isTrue(map.containsKey('a')); + Expect.isFalse(map.containsKey('b')); + Expect.isTrue(map.containsValue('b')); + Expect.isFalse(map.containsValue('a')); + + testLookupNonExistingKeys(map); + testLookupNonExistingValues(map); + Expect.equals('b', map.remove('a')); + Expect.isNull(map.remove('b')); + testLookupNonExistingKeys(map); + testLookupNonExistingValues(map); + + map.clear(); + testEmpty(map); +} + +void testLookupNonExistingKeys(Map map) { + for (String key in ['__proto__', 'null', null]) { + Expect.isNull(map[key]); + Expect.isFalse(map.containsKey(key)); + } +} + +void testLookupNonExistingValues(Map map) { + for (var value in ['__proto__', 'null', null]) { + Expect.isFalse(map.containsValue(value)); + } +} + +void testOrder(List list) { + if (list.isEmpty) + return; + else + testOrder(list.skip(1).toList()); + + Map original = {}; + for (int i = 0; i < list.length; i++) { + original[list[i]] = i; + } + + Map map = jsonify(original); + Expect.equals(list.length, map.length); + Expect.listEquals(list, map.keys.toList()); + + for (int i = 0; i < 10; i++) { + map["$i"] = i; + Expect.equals(list.length + i + 1, map.length); + Expect.listEquals(list, map.keys.take(list.length).toList()); + } +} + +void testProto() { + Map map = jsonify({'__proto__': 0}); + Expect.equals(1, map.length); + Expect.isTrue(map.containsKey('__proto__')); + Expect.listEquals(['__proto__'], map.keys.toList()); + Expect.equals(0, map['__proto__']); + Expect.equals(0, map.remove('__proto__')); + testEmpty(map); + + map = jsonify({'__proto__': null}); + Expect.equals(1, map.length); + Expect.isTrue(map.containsKey('__proto__')); + Expect.listEquals(['__proto__'], map.keys.toList()); + Expect.isNull(map['__proto__']); + Expect.isNull(map.remove('__proto__')); + testEmpty(map); +} + +void testToString() { + Expect.equals("{}", jsonify({}).toString()); + Expect.equals("{a: 0}", jsonify({'a': 0}).toString()); +} + +void testConcurrentModifications() { + void testIterate(Map map, Iterable iterable, Function f) { + Iterator iterator = iterable.iterator; + f(map); + iterator.moveNext(); + } + + void testKeys(Map map, Function f) => testIterate(map, map.keys, f); + void testValues(Map map, Function f) => testIterate(map, map.values, f); + + void testForEach(Map map, Function f) { + map.forEach((key, value) { + f(map); + }); + } + + bool throwsCME(Function f) { + try { + f(); + } on ConcurrentModificationError catch (e) { + return true; + } catch (e) { + return false; + } + return false; + } + + Map map = {}; + Expect.isTrue(throwsCME(() => testKeys(jsonify(map), (map) => map['a'] = 0))); + Expect + .isTrue(throwsCME(() => testValues(jsonify(map), (map) => map['a'] = 0))); + Expect.isFalse( + throwsCME(() => testForEach(jsonify(map), (map) => map['a'] = 0))); + + Expect.isFalse(throwsCME(() => testKeys(jsonify(map), (map) => map.clear()))); + Expect + .isFalse(throwsCME(() => testValues(jsonify(map), (map) => map.clear()))); + Expect.isFalse( + throwsCME(() => testForEach(jsonify(map), (map) => map.clear()))); + + Expect.isFalse( + throwsCME(() => testKeys(jsonify(map), (map) => map.remove('a')))); + Expect.isFalse( + throwsCME(() => testValues(jsonify(map), (map) => map.remove('a')))); + Expect.isFalse( + throwsCME(() => testForEach(jsonify(map), (map) => map.remove('a')))); + + Expect.isTrue(throwsCME( + () => testKeys(jsonify(map), (map) => map.putIfAbsent('a', () => 0)))); + Expect.isTrue(throwsCME( + () => testValues(jsonify(map), (map) => map.putIfAbsent('a', () => 0)))); + Expect.isFalse(throwsCME( + () => testForEach(jsonify(map), (map) => map.putIfAbsent('a', () => 0)))); + + Expect.isFalse( + throwsCME(() => testKeys(jsonify(map), (map) => map.addAll({})))); + Expect.isFalse( + throwsCME(() => testValues(jsonify(map), (map) => map.addAll({})))); + Expect.isFalse( + throwsCME(() => testForEach(jsonify(map), (map) => map.addAll({})))); + + Expect.isTrue( + throwsCME(() => testKeys(jsonify(map), (map) => map.addAll({'a': 0})))); + Expect.isTrue( + throwsCME(() => testValues(jsonify(map), (map) => map.addAll({'a': 0})))); + Expect.isFalse(throwsCME( + () => testForEach(jsonify(map), (map) => map.addAll({'a': 0})))); + + map = {'a': 1}; + Expect + .isFalse(throwsCME(() => testKeys(jsonify(map), (map) => map['a'] = 0))); + Expect.isFalse( + throwsCME(() => testValues(jsonify(map), (map) => map['a'] = 0))); + Expect.isFalse( + throwsCME(() => testForEach(jsonify(map), (map) => map['a'] = 0))); + + Expect.isTrue(throwsCME(() => testKeys(jsonify(map), (map) => map['b'] = 0))); + Expect + .isTrue(throwsCME(() => testValues(jsonify(map), (map) => map['b'] = 0))); + Expect.isTrue( + throwsCME(() => testForEach(jsonify(map), (map) => map['b'] = 0))); + + Expect.isTrue(throwsCME(() => testKeys(jsonify(map), (map) => map.clear()))); + Expect + .isTrue(throwsCME(() => testValues(jsonify(map), (map) => map.clear()))); + Expect + .isTrue(throwsCME(() => testForEach(jsonify(map), (map) => map.clear()))); + + Expect.isTrue( + throwsCME(() => testKeys(jsonify(map), (map) => map.remove('a')))); + Expect.isTrue( + throwsCME(() => testValues(jsonify(map), (map) => map.remove('a')))); + Expect.isTrue( + throwsCME(() => testForEach(jsonify(map), (map) => map.remove('a')))); + + Expect.isFalse( + throwsCME(() => testKeys(jsonify(map), (map) => map.remove('b')))); + Expect.isFalse( + throwsCME(() => testValues(jsonify(map), (map) => map.remove('b')))); + Expect.isFalse( + throwsCME(() => testForEach(jsonify(map), (map) => map.remove('b')))); + + Expect.isFalse(throwsCME( + () => testKeys(jsonify(map), (map) => map.putIfAbsent('a', () => 0)))); + Expect.isFalse(throwsCME( + () => testValues(jsonify(map), (map) => map.putIfAbsent('a', () => 0)))); + Expect.isFalse(throwsCME( + () => testForEach(jsonify(map), (map) => map.putIfAbsent('a', () => 0)))); + + Expect.isTrue(throwsCME( + () => testKeys(jsonify(map), (map) => map.putIfAbsent('b', () => 0)))); + Expect.isTrue(throwsCME( + () => testValues(jsonify(map), (map) => map.putIfAbsent('b', () => 0)))); + Expect.isTrue(throwsCME( + () => testForEach(jsonify(map), (map) => map.putIfAbsent('b', () => 0)))); + + Expect.isFalse( + throwsCME(() => testKeys(jsonify(map), (map) => map.addAll({})))); + Expect.isFalse( + throwsCME(() => testValues(jsonify(map), (map) => map.addAll({})))); + Expect.isFalse( + throwsCME(() => testForEach(jsonify(map), (map) => map.addAll({})))); + + Expect.isFalse( + throwsCME(() => testKeys(jsonify(map), (map) => map.addAll({'a': 0})))); + Expect.isFalse( + throwsCME(() => testValues(jsonify(map), (map) => map.addAll({'a': 0})))); + Expect.isFalse(throwsCME( + () => testForEach(jsonify(map), (map) => map.addAll({'a': 0})))); + + Expect.isTrue( + throwsCME(() => testKeys(jsonify(map), (map) => map.addAll({'b': 0})))); + Expect.isTrue( + throwsCME(() => testValues(jsonify(map), (map) => map.addAll({'b': 0})))); + Expect.isTrue(throwsCME( + () => testForEach(jsonify(map), (map) => map.addAll({'b': 0})))); +} + +void testType() { + Expect.isTrue(jsonify({}) is Map); + Expect.isTrue(jsonify({}) is Map); + Expect.isFalse(jsonify({}) is Map); +} + +void testClear() { + Map map = jsonify({'a': 0}); + map.clear(); + Expect.equals(0, map.length); +} + +void testListEntry() { + Map map = jsonify({ + 'a': [ + 7, + 8, + {'b': 9} + ] + }); + List list = map['a']; + Expect.equals(3, list.length); + Expect.equals(7, list[0]); + Expect.equals(8, list[1]); + Expect.equals(9, list[2]['b']); +} + +void testMutation() { + Map map = jsonify({'a': 0}); + Expect.listEquals(['a', 0], listEach(map)); + map['a'] = 1; + Expect.listEquals(['a', 1], listEach(map)); + map['a']++; + Expect.listEquals(['a', 2], listEach(map)); +} diff --git a/tests/corelib/linked_hash_map_from_iterable_test.dart b/tests/corelib/linked_hash_map_from_iterable_test.dart new file mode 100644 index 00000000000..4b7f6b9f24d --- /dev/null +++ b/tests/corelib/linked_hash_map_from_iterable_test.dart @@ -0,0 +1,117 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; +import 'dart:collection'; + +main() { + defaultFunctionValuesTest(); + defaultKeyFunctionTest(); + defaultValueFunctionTest(); + noDefaultValuesTest(); + emptyIterableTest(); + equalElementsTest(); + genericTypeTest(); +} + +void defaultFunctionValuesTest() { + var map = new LinkedHashMap.fromIterable([1, 2, 3]); + + Expect.isTrue(map is Map); + Expect.isTrue(map is LinkedHashMap); + + Expect.equals(3, map.length); + Expect.equals(3, map.keys.length); + Expect.equals(3, map.values.length); + + Expect.equals(1, map[1]); + Expect.equals(2, map[2]); + Expect.equals(3, map[3]); +} + +void defaultKeyFunctionTest() { + var map = new LinkedHashMap.fromIterable([1, 2, 3], value: (x) => x + 1); + + Expect.isTrue(map is Map); + Expect.isTrue(map is LinkedHashMap); + + Expect.equals(3, map.length); + Expect.equals(3, map.keys.length); + Expect.equals(3, map.values.length); + + Expect.equals(2, map[1]); + Expect.equals(3, map[2]); + Expect.equals(4, map[3]); +} + +void defaultValueFunctionTest() { + var map = new LinkedHashMap.fromIterable([1, 2, 3], key: (x) => x + 1); + + Expect.isTrue(map is Map); + Expect.isTrue(map is LinkedHashMap); + + Expect.equals(3, map.length); + Expect.equals(3, map.keys.length); + Expect.equals(3, map.values.length); + + Expect.equals(1, map[2]); + Expect.equals(2, map[3]); + Expect.equals(3, map[4]); +} + +void noDefaultValuesTest() { + var map = new LinkedHashMap.fromIterable([1, 2, 3], + key: (x) => x + 1, value: (x) => x - 1); + + Expect.isTrue(map is Map); + Expect.isTrue(map is LinkedHashMap); + + Expect.equals(3, map.length); + Expect.equals(3, map.keys.length); + Expect.equals(3, map.values.length); + + Expect.equals(0, map[2]); + Expect.equals(1, map[3]); + Expect.equals(2, map[4]); +} + +void emptyIterableTest() { + var map = new LinkedHashMap.fromIterable([]); + Expect.isTrue(map is Map); + Expect.isTrue(map is LinkedHashMap); + + Expect.equals(0, map.length); + Expect.equals(0, map.keys.length); + Expect.equals(0, map.values.length); +} + +void equalElementsTest() { + var map = new LinkedHashMap.fromIterable([1, 2, 2], key: (x) => x + 1); + + Expect.isTrue(map is Map); + Expect.isTrue(map is LinkedHashMap); + + Expect.equals(2, map.length); + Expect.equals(2, map.keys.length); + Expect.equals(2, map.values.length); + + Expect.equals(1, map[2]); + Expect.equals(2, map[3]); +} + +void genericTypeTest() { + var map = new LinkedHashMap.fromIterable([1, 2, 3], + value: (x) => '$x'); + Expect.isTrue(map is Map); + Expect.isTrue(map is LinkedHashMap); + + map = new LinkedHashMap.fromIterable([1, 2, 3], + key: (x) => '$x', value: (x) => '$x'); + Expect.isTrue(map is Map); + Expect.isTrue(map is LinkedHashMap); + + // Make sure it is not just LinkedHashMap. + Expect.isFalse(map is LinkedHashMap); + Expect.isFalse(map is LinkedHashMap); +} diff --git a/tests/corelib/linked_hash_map_from_iterables_test.dart b/tests/corelib/linked_hash_map_from_iterables_test.dart new file mode 100644 index 00000000000..a63b20608c2 --- /dev/null +++ b/tests/corelib/linked_hash_map_from_iterables_test.dart @@ -0,0 +1,79 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; +import 'dart:collection'; + +main() { + positiveTest(); + emptyMapTest(); + fewerKeysIterableTest(); + fewerValuesIterableTest(); + equalElementsTest(); + genericTypeTest(); +} + +void positiveTest() { + var map = new LinkedHashMap.fromIterables([1, 2, 3], ["one", "two", "three"]); + Expect.isTrue(map is Map); + Expect.isTrue(map is LinkedHashMap); + + Expect.equals(3, map.length); + Expect.equals(3, map.keys.length); + Expect.equals(3, map.values.length); + + Expect.equals("one", map[1]); + Expect.equals("two", map[2]); + Expect.equals("three", map[3]); +} + +void emptyMapTest() { + var map = new LinkedHashMap.fromIterables([], []); + Expect.isTrue(map is Map); + Expect.isTrue(map is LinkedHashMap); + + Expect.equals(0, map.length); + Expect.equals(0, map.keys.length); + Expect.equals(0, map.values.length); +} + +void fewerValuesIterableTest() { + Expect.throws(() => new LinkedHashMap.fromIterables([1, 2], [0])); +} + +void fewerKeysIterableTest() { + Expect.throws(() => new LinkedHashMap.fromIterables([1], [0, 2])); +} + +void equalElementsTest() { + var map = new LinkedHashMap.fromIterables([1, 2, 2], ["one", "two", "three"]); + Expect.isTrue(map is Map); + Expect.isTrue(map is LinkedHashMap); + + Expect.equals(2, map.length); + Expect.equals(2, map.keys.length); + Expect.equals(2, map.values.length); + + Expect.equals("one", map[1]); + Expect.equals("three", map[2]); +} + +void genericTypeTest() { + var map = new LinkedHashMap.fromIterables( + [1, 2, 3], ["one", "two", "three"]); + Expect.isTrue(map is Map); + Expect.isTrue(map is LinkedHashMap); + + // Make sure it is not just LinkedHashMap. + Expect.isFalse(map is LinkedHashMap); + Expect.isFalse(map is LinkedHashMap); + + Expect.equals(3, map.length); + Expect.equals(3, map.keys.length); + Expect.equals(3, map.values.length); + + Expect.equals("one", map[1]); + Expect.equals("two", map[2]); + Expect.equals("three", map[3]); +} diff --git a/tests/corelib/linked_hash_map_test.dart b/tests/corelib/linked_hash_map_test.dart new file mode 100644 index 00000000000..166bc28472c --- /dev/null +++ b/tests/corelib/linked_hash_map_test.dart @@ -0,0 +1,116 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// Dart test for linked hash-maps. +library linkedHashMap.test; + +import "package:expect/expect.dart"; +import 'dart:collection' show LinkedHashMap; + +class LinkedHashMapTest { + static void testMain() { + Map map = new LinkedHashMap(); + map["a"] = 1; + map["b"] = 2; + map["c"] = 3; + map["d"] = 4; + map["e"] = 5; + + List keys = new List(5); + List values = new List(5); + + int index; + + clear() { + index = 0; + for (int i = 0; i < keys.length; i++) { + keys[i] = null; + values[i] = null; + } + } + + verifyKeys(List correctKeys) { + for (int i = 0; i < correctKeys.length; i++) { + Expect.equals(correctKeys[i], keys[i]); + } + } + + verifyValues(List correctValues) { + for (int i = 0; i < correctValues.length; i++) { + Expect.equals(correctValues[i], values[i]); + } + } + + testForEachMap(Object key, Object value) { + Expect.equals(map[key], value); + keys[index] = key; + values[index] = value; + index++; + } + + testForEachValue(Object v) { + values[index++] = v; + } + + testForEachKey(Object v) { + keys[index++] = v; + } + + final keysInOrder = const ["a", "b", "c", "d", "e"]; + final valuesInOrder = const [1, 2, 3, 4, 5]; + + clear(); + map.forEach(testForEachMap); + verifyKeys(keysInOrder); + verifyValues(valuesInOrder); + + clear(); + map.keys.forEach(testForEachKey); + verifyKeys(keysInOrder); + + clear(); + map.values.forEach(testForEachValue); + verifyValues(valuesInOrder); + + // Remove and then insert. + map.remove("b"); + map["b"] = 6; + final keysAfterBMove = const ["a", "c", "d", "e", "b"]; + final valuesAfterBMove = const [1, 3, 4, 5, 6]; + + clear(); + map.forEach(testForEachMap); + verifyKeys(keysAfterBMove); + verifyValues(valuesAfterBMove); + + clear(); + map.keys.forEach(testForEachKey); + verifyKeys(keysAfterBMove); + + clear(); + map.values.forEach(testForEachValue); + verifyValues(valuesAfterBMove); + + // Update. + map["a"] = 0; + final valuesAfterAUpdate = const [0, 3, 4, 5, 6]; + + clear(); + map.forEach(testForEachMap); + verifyKeys(keysAfterBMove); + verifyValues(valuesAfterAUpdate); + + clear(); + map.keys.forEach(testForEachKey); + verifyKeys(keysAfterBMove); + + clear(); + map.values.forEach(testForEachValue); + verifyValues(valuesAfterAUpdate); + } +} + +main() { + LinkedHashMapTest.testMain(); +} diff --git a/tests/corelib/list_as_map_test.dart b/tests/corelib/list_as_map_test.dart new file mode 100644 index 00000000000..43524a205cd --- /dev/null +++ b/tests/corelib/list_as_map_test.dart @@ -0,0 +1,96 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +void testListMapCorrespondence(List list, Map map) { + Expect.equals(list.length, map.length); + for (int i = 0; i < list.length; i++) { + Expect.equals(list[i], map[i]); + } + Expect.isNull(map[list.length]); + Expect.isNull(map[-1]); + + Iterable keys = map.keys; + Iterable values = map.values; + Expect.isFalse(keys is List); + Expect.isFalse(values is List); + Expect.equals(list.length, keys.length); + Expect.equals(list.length, values.length); + for (int i = 0; i < list.length; i++) { + Expect.equals(i, keys.elementAt(i)); + Expect.equals(list[i], values.elementAt(i)); + } + + int forEachCount = 0; + map.forEach((key, value) { + Expect.equals(forEachCount, key); + Expect.equals(list[key], value); + forEachCount++; + }); + + for (int i = 0; i < list.length; i++) { + Expect.isTrue(map.containsKey(i)); + Expect.isTrue(map.containsValue(list[i])); + } + Expect.isFalse(map.containsKey(-1)); + Expect.isFalse(map.containsKey(list.length)); + + Expect.equals(list.length, forEachCount); + + Expect.equals(list.isEmpty, map.isEmpty); +} + +void testConstAsMap(List list) { + Map map = list.asMap(); + + testListMapCorrespondence(list, map); + + Expect.throws(() => map[0] = 499, (e) => e is UnsupportedError); + Expect.throws( + () => map.putIfAbsent(0, () => 499), (e) => e is UnsupportedError); + Expect.throws(() => map.clear(), (e) => e is UnsupportedError); +} + +void testFixedAsMap(List list) { + testConstAsMap(list); + + Map map = list.asMap(); + + if (!list.isEmpty) { + list[0] = 499; + // Check again to make sure the map is backed by the list. + testListMapCorrespondence(list, map); + } +} + +void testAsMap(List list) { + testFixedAsMap(list); + + Map map = list.asMap(); + + Iterable keys = map.keys; + Iterable values = map.values; + + list.add(42); + // Check again to make sure the map is backed by the list and that the + // length is not cached. + testListMapCorrespondence(list, map); + // Also check that the keys and values iterable from the map are backed by + // the list. + Expect.equals(list.length, keys.length); + Expect.equals(values.length, values.length); +} + +main() { + testConstAsMap(const [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); + testAsMap([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); + List list = new List(10); + for (int i = 0; i < 10; i++) list[i] = i + 1; + testFixedAsMap(list); + + testConstAsMap(const []); + testAsMap([]); + testFixedAsMap(new List(0)); +} diff --git a/tests/corelib/list_contains_argument_order_test.dart b/tests/corelib/list_contains_argument_order_test.dart new file mode 100644 index 00000000000..0a3377270da --- /dev/null +++ b/tests/corelib/list_contains_argument_order_test.dart @@ -0,0 +1,40 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +class A { + const A(); + bool operator ==(Object other) { + return false; + } +} + +class B { + bool operator ==(Object other) { + Expect.fail("Bad equality order."); + } +} + +main() { + test(iterable) { + Expect.isFalse(iterable.contains(new B())); + } + + var iterables = [ + [new A()], + new List(1)..[0] = new A(), + new List()..add(new A()), + const [const A()], + new Set()..add(new A()), + (new Map()..[new A()] = 0).keys, + (new Map()..[0] = new A()).values + ]; + + for (var iterable in iterables) { + test(iterable); + test(iterable.map((x) => x)); + test(iterable.take(1)); + } +} diff --git a/tests/corelib/list_fill_range_test.dart b/tests/corelib/list_fill_range_test.dart new file mode 100644 index 00000000000..cff66e9af8f --- /dev/null +++ b/tests/corelib/list_fill_range_test.dart @@ -0,0 +1,80 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; +import "dart:collection"; + +test(List list, int start, int end, [fillValue]) { + List copy = list.toList(); + list.fillRange(start, end, fillValue); + Expect.equals(copy.length, list.length); + for (int i = 0; i < start; i++) { + Expect.equals(copy[i], list[i]); + } + for (int i = start; i < end; i++) { + Expect.equals(fillValue, list[i]); + } + for (int i = end; i < list.length; i++) { + Expect.equals(copy[i], list[i]); + } +} + +class MyList extends ListBase { + List list; + MyList(this.list); + get length => list.length; + set length(value) { + list.length = value; + } + + operator [](index) => list[index]; + operator []=(index, val) { + list[index] = val; + } + + toString() => list.toString(); +} + +main() { + test([1, 2, 3], 0, 1); + test([1, 2, 3], 0, 1, 99); + test([1, 2, 3], 1, 1); + test([1, 2, 3], 1, 1, 499); + test([1, 2, 3], 3, 3); + test([1, 2, 3], 3, 3, 499); + test([1, 2, 3].toList(growable: false), 0, 1); + test([1, 2, 3].toList(growable: false), 0, 1, 99); + test([1, 2, 3].toList(growable: false), 1, 1); + test([1, 2, 3].toList(growable: false), 1, 1, 499); + test([1, 2, 3].toList(growable: false), 3, 3); + test([1, 2, 3].toList(growable: false), 3, 3, 499); + test(new MyList([1, 2, 3]), 0, 1); + test(new MyList([1, 2, 3]), 0, 1, 99); + test(new MyList([1, 2, 3]), 1, 1); + test(new MyList([1, 2, 3]), 1, 1, 499); + test(new MyList([1, 2, 3]), 3, 3); + test(new MyList([1, 2, 3]), 3, 3, 499); + + expectRE(() => test([1, 2, 3], -1, 0)); + expectRE(() => test([1, 2, 3], 2, 1)); + expectRE(() => test([1, 2, 3], 0, -1)); + expectRE(() => test([1, 2, 3], 1, 4)); + expectRE(() => test(new MyList([1, 2, 3]), -1, 0)); + expectRE(() => test(new MyList([1, 2, 3]), 2, 1)); + expectRE(() => test(new MyList([1, 2, 3]), 0, -1)); + expectRE(() => test(new MyList([1, 2, 3]), 1, 4)); + expectUE(() => test(const [1, 2, 3], 2, 3)); + expectUE(() => test(const [1, 2, 3], -1, 0)); + expectUE(() => test(const [1, 2, 3], 2, 1)); + expectUE(() => test(const [1, 2, 3], 0, -1)); + expectUE(() => test(const [1, 2, 3], 1, 4)); +} + +void expectRE(Function f) { + Expect.throws(f, (e) => e is RangeError); +} + +void expectUE(Function f) { + Expect.throws(f, (e) => e is UnsupportedError); +} diff --git a/tests/corelib/list_filled_type_argument_test.dart b/tests/corelib/list_filled_type_argument_test.dart new file mode 100644 index 00000000000..1c3aff49e8d --- /dev/null +++ b/tests/corelib/list_filled_type_argument_test.dart @@ -0,0 +1,15 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + var a = new List.filled(42, 42); + Expect.isTrue(a is List); + Expect.isFalse(a is List); + + a = new List.filled(42, 42, growable: true); + Expect.isTrue(a is List); + Expect.isFalse(a is List); +} diff --git a/tests/corelib/list_first_test.dart b/tests/corelib/list_first_test.dart new file mode 100644 index 00000000000..74be9812878 --- /dev/null +++ b/tests/corelib/list_first_test.dart @@ -0,0 +1,20 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +void test(List list) { + if (list.isEmpty) { + Expect.throws(() => list.first, (e) => e is StateError); + } else { + Expect.equals(list[0], list.first); + } +} + +main() { + test([1, 2, 3]); + test(const ["foo", "bar"]); + test([]); + test(const []); +} diff --git a/tests/corelib/list_fixed_test.dart b/tests/corelib/list_fixed_test.dart new file mode 100644 index 00000000000..5950ec307a0 --- /dev/null +++ b/tests/corelib/list_fixed_test.dart @@ -0,0 +1,29 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + var a; + + a = new List(42); + Expect.equals(42, a.length); + Expect.throws(() => a.add(499), (e) => e is UnsupportedError); + Expect.equals(42, a.length); + for (int i = 0; i < 42; i++) { + Expect.equals(null, a[i]); + } + Expect.throws(() => a.clear(), (e) => e is UnsupportedError); + Expect.equals(42, a.length); + + a = new List.filled(42, -2); + Expect.equals(42, a.length); + Expect.throws(() => a.add(499), (e) => e is UnsupportedError); + Expect.equals(42, a.length); + for (int i = 0; i < 42; i++) { + Expect.equals(-2, a[i]); + } + Expect.throws(() => a.clear(), (e) => e is UnsupportedError); + Expect.equals(42, a.length); +} diff --git a/tests/corelib/list_for_each_test.dart b/tests/corelib/list_for_each_test.dart new file mode 100644 index 00000000000..b59a2d73070 --- /dev/null +++ b/tests/corelib/list_for_each_test.dart @@ -0,0 +1,67 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; +import "dart:collection"; + +class MyList extends ListBase { + List list; + MyList(this.list); + get length => list.length; + set length(value) { + list.length = value; + } + + operator [](index) => list[index]; + operator []=(index, val) { + list[index] = val; + } + + toString() => list.toString(); +} + +void testWithoutModification(List list) { + var seen = []; + list.forEach(seen.add); + + Expect.listEquals(list, seen); +} + +void testWithModification(List list) { + if (list.isEmpty) return; + Expect.throws(() => list.forEach((_) => list.add(0)), + (e) => e is ConcurrentModificationError); +} + +main() { + List fixedLengthList = new List(10); + for (int i = 0; i < 10; i++) fixedLengthList[i] = i + 1; + + List growableList = new List(); + growableList.length = 10; + for (int i = 0; i < 10; i++) growableList[i] = i + 1; + + var growableLists = [ + [], + [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], + new MyList([1, 2, 3, 4, 5]), + growableList, + ]; + var fixedLengthLists = [ + const [], + fixedLengthList, + const [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], + new MyList(const [1, 2]), + ]; + + for (var list in growableLists) { + print(list); + testWithoutModification(list); + testWithModification(list); + } + + for (var list in fixedLengthLists) { + testWithoutModification(list); + } +} diff --git a/tests/corelib/list_get_range_test.dart b/tests/corelib/list_get_range_test.dart new file mode 100644 index 00000000000..5aafd763b7a --- /dev/null +++ b/tests/corelib/list_get_range_test.dart @@ -0,0 +1,82 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +testGetRange(list, start, end, bool isModifiable) { + expectRE(() { + list.getRange(-1, 0); + }); + expectRE(() { + list.getRange(0, -1); + }); + expectRE(() { + list.getRange(1, 0); + }); + expectRE(() { + list.getRange(0, list.length + 1); + }); + expectRE(() { + list.getRange(list.length + 1, list.length + 1); + }); + Iterable iterable = list.getRange(start, end); + Expect.isFalse(iterable is List); + if (start == end) { + Expect.isTrue(iterable.isEmpty); + return; + } + + var iterator = iterable.iterator; + for (int i = start; i < end; i++) { + Expect.isTrue(iterator.moveNext()); + Expect.equals(iterator.current, list[i]); + } + Expect.isFalse(iterator.moveNext()); + + if (isModifiable) { + for (int i = 0; i < list.length; i++) { + list[i]++; + } + + iterator = iterable.iterator; + for (int i = start; i < end; i++) { + Expect.isTrue(iterator.moveNext()); + Expect.equals(iterator.current, list[i]); + } + } +} + +main() { + testGetRange([1, 2], 0, 1, true); + testGetRange([], 0, 0, true); + testGetRange([1, 2, 3], 0, 0, true); + testGetRange([1, 2, 3], 1, 3, true); + testGetRange(const [1, 2], 0, 1, false); + testGetRange(const [], 0, 0, false); + testGetRange(const [1, 2, 3], 0, 0, false); + testGetRange(const [1, 2, 3], 1, 3, false); + testGetRange("abcd".codeUnits, 0, 1, false); + testGetRange("abcd".codeUnits, 0, 0, false); + testGetRange("abcd".codeUnits, 1, 3, false); + + expectRE(() => [1].getRange(-1, 1)); + expectRE(() => [3].getRange(0, -1)); + expectRE(() => [4].getRange(1, 0)); + + var list = [1, 2, 3, 4]; + var iterable = list.getRange(1, 3); + Expect.equals(2, iterable.first); + Expect.equals(3, iterable.last); + list.length = 1; + Expect.isTrue(iterable.isEmpty); + list.add(99); + Expect.equals(99, iterable.single); + list.add(499); + Expect.equals(499, iterable.last); + Expect.equals(2, iterable.length); +} + +void expectRE(Function f) { + Expect.throws(f, (e) => e is RangeError); +} diff --git a/tests/corelib/list_growable_test.dart b/tests/corelib/list_growable_test.dart new file mode 100644 index 00000000000..7ce723e66b6 --- /dev/null +++ b/tests/corelib/list_growable_test.dart @@ -0,0 +1,38 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + var a; + a = new List(); + a.add(499); + Expect.equals(1, a.length); + Expect.equals(499, a[0]); + a.clear(); + Expect.equals(0, a.length); + Expect.throws(() => a[0], (e) => e is RangeError); + + a = new List(42).toList(); + Expect.equals(42, a.length); + a.add(499); + Expect.equals(43, a.length); + Expect.equals(499, a[42]); + Expect.equals(null, a[23]); + a.clear(); + Expect.equals(0, a.length); + Expect.throws(() => a[0], (e) => e is RangeError); + + a = new List(42).toList(); + Expect.equals(42, a.length); + a.add(499); + Expect.equals(43, a.length); + Expect.equals(499, a[42]); + for (int i = 0; i < 42; i++) { + Expect.equals(null, a[i]); + } + a.clear(); + Expect.equals(0, a.length); + Expect.throws(() => a[0], (e) => e is RangeError); +} diff --git a/tests/corelib/list_index_of2_test.dart b/tests/corelib/list_index_of2_test.dart new file mode 100644 index 00000000000..abd89a58a35 --- /dev/null +++ b/tests/corelib/list_index_of2_test.dart @@ -0,0 +1,32 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +class A { + const A(); +} + +class B extends A { + const B(); +} + +void test(List list) { + // Test that the list accepts a different type for indexOf. + // List.indexOf(A) + Expect.equals(-1, list.indexOf(const A())); + Expect.equals(-1, list.lastIndexOf(const A())); +} + +main() { + var list = new List(1); + list[0] = const B(); + test(list); + var list2 = new List(); + list2.add(const B()); + test(list2); + test([const B()]); + test(const []); + test([const B()].toList()); +} diff --git a/tests/corelib/list_index_of_test.dart b/tests/corelib/list_index_of_test.dart new file mode 100644 index 00000000000..ebb2731c0df --- /dev/null +++ b/tests/corelib/list_index_of_test.dart @@ -0,0 +1,35 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + test(new List(5)); + var l = new List(); + l.length = 5; + test(l); +} + +void test(List list) { + list[0] = 1; + list[1] = 2; + list[2] = 3; + list[3] = 4; + list[4] = 1; + + Expect.equals(3, list.indexOf(4, 0)); + Expect.equals(0, list.indexOf(1, 0)); + Expect.equals(4, list.lastIndexOf(1, list.length - 1)); + + Expect.equals(4, list.indexOf(1, 1)); + Expect.equals(-1, list.lastIndexOf(4, 2)); + + Expect.equals(3, list.indexOf(4, 2)); + Expect.equals(3, list.indexOf(4, -5)); + Expect.equals(-1, list.indexOf(4, 50)); + + Expect.equals(-1, list.lastIndexOf(4, 2)); + Expect.equals(-1, list.lastIndexOf(4, -5)); + Expect.equals(3, list.lastIndexOf(4, 50)); +} diff --git a/tests/corelib/list_insert_all_test.dart b/tests/corelib/list_insert_all_test.dart new file mode 100644 index 00000000000..63d38923a75 --- /dev/null +++ b/tests/corelib/list_insert_all_test.dart @@ -0,0 +1,90 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; +import "dart:collection"; + +test(List list, int index, Iterable iterable) { + List copy = list.toList(); + list.insertAll(index, iterable); + List iterableList = iterable.toList(); + Expect.equals(copy.length + iterableList.length, list.length); + for (int i = 0; i < index; i++) { + Expect.equals(copy[i], list[i]); + } + for (int i = 0; i < iterableList.length; i++) { + Expect.equals(iterableList[i], list[i + index]); + } + for (int i = index + iterableList.length; i < copy.length; i++) { + Expect.equals(copy[i], list[i + iterableList.length]); + } +} + +class MyList extends ListBase { + List list; + MyList(this.list); + get length => list.length; + set length(value) { + list.length = value; + } + + operator [](index) => list[index]; + operator []=(index, val) { + list[index] = val; + } + + toString() => list.toString(); +} + +main() { + test([1, 2, 3], 0, [4, 5]); + test([1, 2, 3], 1, [4, 5]); + test([1, 2, 3], 2, [4, 5]); + test([1, 2, 3], 3, [4, 5]); + test([1, 2, 3], 2, [4]); + test([1, 2, 3], 3, []); + test([1, 2, 3], 0, [4, 5].map((x) => x)); + test([1, 2, 3], 1, [4, 5].map((x) => x)); + test([1, 2, 3], 2, [4, 5].map((x) => x)); + test([1, 2, 3], 3, [4, 5].map((x) => x)); + test([1, 2, 3], 2, [4].map((x) => x)); + test([1, 2, 3], 3, [].map((x) => x)); + test([1, 2, 3], 0, const [4, 5]); + test([1, 2, 3], 1, const [4, 5]); + test([1, 2, 3], 2, const [4, 5]); + test([1, 2, 3], 3, const [4, 5]); + test([1, 2, 3], 2, const [4]); + test([1, 2, 3], 3, const []); + test([1, 2, 3], 0, new Iterable.generate(2, (x) => x + 4)); + test([1, 2, 3], 1, new Iterable.generate(2, (x) => x + 4)); + test([1, 2, 3], 2, new Iterable.generate(2, (x) => x + 4)); + test([1, 2, 3], 3, new Iterable.generate(2, (x) => x + 4)); + test([1, 2, 3], 2, new Iterable.generate(1, (x) => x + 4)); + test([1, 2, 3], 3, new Iterable.generate(0, (x) => x + 4)); + test(new MyList([1, 2, 3]), 0, [4, 5]); + test(new MyList([1, 2, 3]), 1, [4, 5]); + test(new MyList([1, 2, 3]), 2, [4]); + test(new MyList([1, 2, 3]), 3, []); + test(new MyList([1, 2, 3]), 2, [4, 5]); + test(new MyList([1, 2, 3]), 3, [4, 5]); + test(new MyList([1, 2, 3]), 0, [4, 5].map((x) => x)); + test(new MyList([1, 2, 3]), 1, [4, 5].map((x) => x)); + test(new MyList([1, 2, 3]), 2, [4, 5].map((x) => x)); + test(new MyList([1, 2, 3]), 3, [4, 5].map((x) => x)); + test(new MyList([1, 2, 3]), 2, [4].map((x) => x)); + test(new MyList([1, 2, 3]), 3, [].map((x) => x)); + + expectRE(() => test([1, 2, 3], -1, [4, 5])); + expectUE(() => test([1, 2, 3].toList(growable: false), -1, [4, 5])); + expectRE(() => test(new MyList([1, 2, 3]), -1, [4, 5])); + expectUE(() => test([1, 2, 3].toList(growable: false), 0, [4, 5])); +} + +void expectRE(Function f) { + Expect.throws(f, (e) => e is RangeError); +} + +void expectUE(Function f) { + Expect.throws(f, (e) => e is UnsupportedError); +} diff --git a/tests/corelib/list_insert_test.dart b/tests/corelib/list_insert_test.dart new file mode 100644 index 00000000000..1efaafb19e9 --- /dev/null +++ b/tests/corelib/list_insert_test.dart @@ -0,0 +1,79 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:expect/expect.dart'; +import 'dart:collection'; + +class MyList extends ListBase { + List list; + MyList(this.list); + + get length => list.length; + set length(val) { + list.length = val; + } + + operator [](index) => list[index]; + operator []=(index, val) => list[index] = val; + + String toString() => "[" + join(", ") + "]"; +} + +// l1 must be a modifiable list with 5 elements from 0 to 4. +void testModifiableList(l1) { + bool checkedMode = false; + assert(checkedMode = true); + + // Index must be integer and in range. + Expect.throws(() { + l1.insert(-1, 5); + }, (e) => e is RangeError, "negative"); + Expect.throws(() { + l1.insert(6, 5); + }, (e) => e is RangeError, "too large"); + Expect.throws(() { + l1.insert(null, 5); + }); + Expect.throws(() { + l1.insert("1", 5); + }); + Expect.throws(() { + l1.insert(1.5, 5); + }); + + l1.insert(5, 5); + Expect.equals(6, l1.length); + Expect.equals(5, l1[5]); + Expect.equals("[0, 1, 2, 3, 4, 5]", l1.toString()); + + l1.insert(0, -1); + Expect.equals(7, l1.length); + Expect.equals(-1, l1[0]); + Expect.equals("[-1, 0, 1, 2, 3, 4, 5]", l1.toString()); +} + +void main() { + // Normal modifiable list. + testModifiableList([0, 1, 2, 3, 4]); + testModifiableList(new MyList([0, 1, 2, 3, 4])); + + // Fixed size list. + var l2 = new List(5); + for (var i = 0; i < 5; i++) l2[i] = i; + Expect.throws(() { + l2.insert(2, 5); + }, (e) => e is UnsupportedError, "fixed-length"); + + // Unmodifiable list. + var l3 = const [0, 1, 2, 3, 4]; + Expect.throws(() { + l3.insert(2, 5); + }, (e) => e is UnsupportedError, "unmodifiable"); + + // Empty list is not special. + var l4 = []; + l4.insert(0, 499); + Expect.equals(1, l4.length); + Expect.equals(499, l4[0]); +} diff --git a/tests/corelib/list_iterators_test.dart b/tests/corelib/list_iterators_test.dart new file mode 100644 index 00000000000..092082e4e16 --- /dev/null +++ b/tests/corelib/list_iterators_test.dart @@ -0,0 +1,50 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +class ListIteratorsTest { + static void checkListIterator(List a) { + Iterator it = a.iterator; + Expect.isNull(it.current); + for (int i = 0; i < a.length; i++) { + Expect.isTrue(it.moveNext()); + var elem = it.current; + Expect.equals(a[i], elem); + } + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + } + + static testMain() { + checkListIterator([]); + checkListIterator([1, 2]); + checkListIterator(new List(0)); + checkListIterator(new List(10)); + checkListIterator(new List()); + List g = new List(); + g.addAll([1, 2, 3]); + checkListIterator(g); + + // This is mostly undefined behavior. + Iterator it = g.iterator; + Expect.isTrue(it.moveNext()); + Expect.equals(1, it.current); + Expect.isTrue(it.moveNext()); + g[1] = 49; + // The iterator keeps the last value. + Expect.equals(2, it.current); + Expect.isTrue(it.moveNext()); + g.removeLast(); + // The iterator keeps the last value. + Expect.equals(3, it.current); + Expect.throws(it.moveNext, (e) => e is ConcurrentModificationError); + // No progress when throwing. + Expect.equals(3, it.current); + } +} + +main() { + ListIteratorsTest.testMain(); +} diff --git a/tests/corelib/list_last_test.dart b/tests/corelib/list_last_test.dart new file mode 100644 index 00000000000..07333356b2e --- /dev/null +++ b/tests/corelib/list_last_test.dart @@ -0,0 +1,20 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +void test(List list) { + if (list.isEmpty) { + Expect.throws(() => list.last, (e) => e is StateError); + } else { + Expect.equals(list[list.length - 1], list.last); + } +} + +main() { + test([1, 2, 3]); + test(const ["foo", "bar"]); + test([]); + test(const []); +} diff --git a/tests/corelib/list_literal_is_growable_test.dart b/tests/corelib/list_literal_is_growable_test.dart new file mode 100644 index 00000000000..061a72d1c0c --- /dev/null +++ b/tests/corelib/list_literal_is_growable_test.dart @@ -0,0 +1,12 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + var l = []; + l.add(1); + Expect.equals(1, l.length); + Expect.equals(1, l[0]); +} diff --git a/tests/corelib/list_literal_test.dart b/tests/corelib/list_literal_test.dart new file mode 100644 index 00000000000..abc38c1bff9 --- /dev/null +++ b/tests/corelib/list_literal_test.dart @@ -0,0 +1,24 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +// Test that a list literal is expandable and modifiable. + +class ListLiteralTest { + static void testMain() { + var list = [1, 2, 3]; + Expect.equals(3, list.length); + list.add(4); + Expect.equals(4, list.length); + list.addAll([5, 6]); + Expect.equals(6, list.length); + list[0] = 0; + Expect.equals(0, list[0]); + } +} + +main() { + ListLiteralTest.testMain(); +} diff --git a/tests/corelib/list_map_test.dart b/tests/corelib/list_map_test.dart new file mode 100644 index 00000000000..c56b25493bd --- /dev/null +++ b/tests/corelib/list_map_test.dart @@ -0,0 +1,164 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + testOperations(); +} + +class ThrowMarker { + const ThrowMarker(); + String toString() => "<>"; +} + +void testOperations() { + // Comparison lists. + List l = const [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; + List r = const [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]; + // Function that reverses l and r lists when used to map. + int rev(x) => 11 - x; + // A base list that starts out like l, but isn't const. + List base = l.map((x) => x).toList(); + + Iterable reversed = l.map(rev); + + Expect.listEquals(r, l.map(rev).toList()); + Expect.listEquals(l, l.map(rev).map(rev).toList()); + for (int i = 0; i < r.length; i++) { + Expect.equals(r[i], reversed.elementAt(i)); + } + Expect.equals(4, base.indexOf(5)); + Expect.equals(5, reversed.toList().indexOf(5)); + + // Reversed followed by combinations of skip and take. + List subr = [8, 7, 6, 5, 4, 3]; + Expect.listEquals(subr, reversed.skip(2).take(6).toList()); + Expect.listEquals(subr, reversed.take(8).skip(2).toList()); + Expect.listEquals(subr, + reversed.toList().reversed.skip(2).take(6).toList().reversed.toList()); + Expect.listEquals(subr, + reversed.toList().reversed.take(8).skip(2).toList().reversed.toList()); + Expect.listEquals(subr, + reversed.take(8).toList().reversed.take(6).toList().reversed.toList()); + Expect.listEquals(subr, + reversed.toList().reversed.take(8).toList().reversed.take(6).toList()); + Expect.listEquals(subr, + reversed.toList().reversed.skip(2).toList().reversed.skip(2).toList()); + Expect.listEquals(subr, + reversed.skip(2).toList().reversed.skip(2).toList().reversed.toList()); + + void testList(List list) { + var throws = const ThrowMarker(); + List mappedList = new List(list.length); + for (int i = 0; i < list.length; i++) { + mappedList[i] = rev(list[i]); + } + Iterable reversed = list.map(rev); + + void testEquals(v1, v2, path) { + if (v1 is Iterable) { + Iterator i1 = v1.iterator; + Iterator i2 = v2.iterator; + int index = 0; + while (i1.moveNext()) { + Expect.isTrue(i2.moveNext(), + "Too few actual values. Expected[$index] == ${i1.current}"); + testEquals(i1.current, i2.current, "$path[$index]"); + index++; + } + if (i2.moveNext()) { + Expect + .fail("Too many actual values. Actual[$index] == ${i2.current}"); + } + } else { + Expect.equals(v1, v2, path); + } + } + + void testOp(operation(Iterable mappedList), name) { + var expect; + try { + expect = operation(mappedList); + } catch (e) { + expect = throws; + } + var actual; + try { + actual = operation(reversed); + } catch (e) { + actual = throws; + } + testEquals(expect, actual, "$name: $list"); + } + + testOp((i) => i.first, "first"); + testOp((i) => i.last, "last"); + testOp((i) => i.single, "single"); + testOp((i) => i.firstWhere((n) => false), "firstWhere i.firstWhere((n) => n < 10), "firstWhere<10"); + testOp((i) => i.firstWhere((n) => n < 5), "firstWhere<5"); + testOp((i) => i.firstWhere((n) => true), "firstWhere i.lastWhere((n) => false), "lastWhere i.lastWhere((n) => n < 5), "lastWhere<5"); + testOp((i) => i.lastWhere((n) => n < 10), "lastWhere<10"); + testOp((i) => i.lastWhere((n) => true), "lastWhere i.singleWhere((n) => false), "singleWhere i.singleWhere((n) => n < 5), "singelWhere<5"); + testOp((i) => i.singleWhere((n) => n < 10), "singelWhere<10"); + testOp((i) => i.singleWhere((n) => true), "singleWhere i.contains(5), "contains(5)"); + testOp((i) => i.contains(10), "contains(10)"); + testOp((i) => i.any((n) => n < 5), "any<5"); + testOp((i) => i.any((n) => n < 10), "any<10"); + testOp((i) => i.every((n) => n < 5), "every<5"); + testOp((i) => i.every((n) => n < 10), "every<10"); + testOp((i) => i.reduce((a, b) => a + b), "reduce-sum"); + testOp((i) => i.fold(0, (a, b) => a + b), "fold-sum"); + testOp((i) => i.join("-"), "join-"); + testOp((i) => i.join(""), "join"); + testOp((i) => i.join(), "join-null"); + testOp((i) => i.map((n) => n * 2), "map*2"); + testOp((i) => i.where((n) => n < 5), "where<5"); + testOp((i) => i.where((n) => n < 10), "where<10"); + testOp((i) => i.expand((n) => []), "expand[]"); + testOp((i) => i.expand((n) => [n]), "expand[n]"); + testOp((i) => i.expand((n) => [n, n]), "expand[n, n]"); + testOp((i) => i.take(0), "take(0)"); + testOp((i) => i.take(5), "take(5)"); + testOp((i) => i.take(10), "take(10)"); + testOp((i) => i.take(15), "take(15)"); + testOp((i) => i.skip(0), "skip(0)"); + testOp((i) => i.skip(5), "skip(5)"); + testOp((i) => i.skip(10), "skip(10)"); + testOp((i) => i.skip(15), "skip(15)"); + testOp((i) => i.takeWhile((n) => false), "takeWhile(t)"); + testOp((i) => i.takeWhile((n) => n < 5), "takeWhile(n<5)"); + testOp((i) => i.takeWhile((n) => n > 5), "takeWhile(n>5)"); + testOp((i) => i.takeWhile((n) => true), "takeWhile(f)"); + testOp((i) => i.skipWhile((n) => false), "skipWhile(t)"); + testOp((i) => i.skipWhile((n) => n < 5), "skipWhile(n<5)"); + testOp((i) => i.skipWhile((n) => n > 5), "skipWhile(n>5)"); + testOp((i) => i.skipWhile((n) => true), "skipWhile(f)"); + } + + // Combinations of lists with 0, 1 and more elements. + testList([]); + testList([0]); + testList([10]); + testList([0, 1]); + testList([0, 10]); + testList([10, 11]); + testList([0, 5, 10]); + testList([10, 5, 0]); + testList([0, 1, 2, 3]); + testList([3, 4, 5, 6]); + testList([10, 11, 12, 13]); + testList(l); + testList(r); + testList(base); + + // Reverse const list. + Expect.listEquals(r, l.map(rev).toList()); +} diff --git a/tests/corelib/list_remove_range_test.dart b/tests/corelib/list_remove_range_test.dart new file mode 100644 index 00000000000..17d138c147a --- /dev/null +++ b/tests/corelib/list_remove_range_test.dart @@ -0,0 +1,80 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + var list = []; + list.removeRange(0, 0); + Expect.equals(0, list.length); + expectIOORE(() { + list.removeRange(0, 1); + }); + + list.add(1); + list.removeRange(0, 0); + Expect.equals(1, list.length); + Expect.equals(1, list[0]); + + expectIOORE(() { + list.removeRange(0, 2); + }); + Expect.equals(1, list.length); + Expect.equals(1, list[0]); + + list.removeRange(0, 1); + Expect.equals(0, list.length); + + list.addAll([3, 4, 5, 6]); + Expect.equals(4, list.length); + list.removeRange(0, 4); + Expect.listEquals([], list); + + list.addAll([3, 4, 5, 6]); + list.removeRange(2, 4); + Expect.listEquals([3, 4], list); + list.addAll([5, 6]); + + expectIOORE(() { + list.removeRange(4, 5); + }); + Expect.listEquals([3, 4, 5, 6], list); + + list.removeRange(1, 3); + Expect.listEquals([3, 6], list); + + testNegativeIndices(); +} + +void expectIOORE(Function f) { + Expect.throws(f, (e) => e is RangeError); +} + +void testNegativeIndices() { + var list = [1, 2]; + expectIOORE(() { + list.removeRange(-1, 1); + }); + Expect.listEquals([1, 2], list); + + // A negative length throws an ArgumentError. + expectIOORE(() { + list.removeRange(0, -1); + }); + Expect.listEquals([1, 2], list); + + expectIOORE(() { + list.removeRange(-1, -1); + }); + Expect.listEquals([1, 2], list); + + expectIOORE(() { + list.removeRange(-1, 0); + }); + + expectIOORE(() { + list.removeRange(4, 4); + }); + Expect.listEquals([1, 2], list); +} diff --git a/tests/corelib/list_removeat_test.dart b/tests/corelib/list_removeat_test.dart new file mode 100644 index 00000000000..43bf2eb3ce3 --- /dev/null +++ b/tests/corelib/list_removeat_test.dart @@ -0,0 +1,81 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; +import 'dart:collection'; + +class MyList extends ListBase { + List list; + MyList(this.list); + + get length => list.length; + set length(val) { + list.length = val; + } + + operator [](index) => list[index]; + operator []=(index, val) => list[index] = val; + + String toString() => "[" + join(", ") + "]"; +} + +// l1 must be a modifiable list with 5 elements from 0 to 4. +void testModifiableList(l1) { + // Index must be integer and in range. + Expect.throws(() { + l1.removeAt(-1); + }, (e) => e is RangeError, "negative"); + Expect.throws(() { + l1.removeAt(5); + }, (e) => e is RangeError, "too large"); + Expect.throws(() { + l1.removeAt(null); + }, (e) => e is ArgumentError, "too large"); + Expect.throws(() { + l1.removeAt("1"); + }, (e) => (typeAssertionsEnabled ? e is TypeError : e is ArgumentError), + "string"); + Expect.throws(() { + l1.removeAt(1.5); + }, (e) => (typeAssertionsEnabled ? e is TypeError : e is ArgumentError), + "double"); + + Expect.equals(2, l1.removeAt(2), "l1-remove2"); + Expect.equals(1, l1[1], "l1-1[1]"); + + Expect.equals(3, l1[2], "l1-1[2]"); + Expect.equals(4, l1[3], "l1-1[3]"); + Expect.equals(4, l1.length, "length-1"); + + Expect.equals(0, l1.removeAt(0), "l1-remove0"); + Expect.equals(1, l1[0], "l1-2[0]"); + Expect.equals(3, l1[1], "l1-2[1]"); + Expect.equals(4, l1[2], "l1-2[2]"); + Expect.equals(3, l1.length, "length-2"); +} + +void main() { + // Normal modifiable list. + testModifiableList([0, 1, 2, 3, 4]); + testModifiableList(new MyList([0, 1, 2, 3, 4])); + + // Fixed size list. + var l2 = new List(5); + for (var i = 0; i < 5; i++) l2[i] = i; + Expect.throws(() { + l2.removeAt(2); + }, (e) => e is UnsupportedError, "fixed-length"); + + // Unmodifiable list. + var l3 = const [0, 1, 2, 3, 4]; + Expect.throws(() { + l3.removeAt(2); + }, (e) => e is UnsupportedError, "unmodifiable"); + + // Empty list is not special. + var l4 = []; + Expect.throws(() { + l4.removeAt(0); + }, (e) => e is RangeError, "empty"); +} diff --git a/tests/corelib/list_replace_range_test.dart b/tests/corelib/list_replace_range_test.dart new file mode 100644 index 00000000000..03008c1c378 --- /dev/null +++ b/tests/corelib/list_replace_range_test.dart @@ -0,0 +1,123 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; +import "dart:collection"; + +test(List list, int start, int end, Iterable iterable) { + List copy = list.toList(); + list.replaceRange(start, end, iterable); + List iterableList = iterable.toList(); + Expect.equals(copy.length + iterableList.length - (end - start), list.length); + for (int i = 0; i < start; i++) { + Expect.equals(copy[i], list[i]); + } + for (int i = 0; i < iterableList.length; i++) { + Expect.equals(iterableList[i], list[i + start]); + } + int removedLength = end - start; + for (int i = end; i < copy.length; i++) { + Expect.equals(copy[i], list[i + iterableList.length - removedLength]); + } +} + +class MyList extends ListBase { + List list; + MyList(this.list); + get length => list.length; + set length(value) { + list.length = value; + } + + operator [](index) => list[index]; + operator []=(index, val) { + list[index] = val; + } + + toString() => list.toString(); +} + +main() { + test([1, 2, 3], 0, 1, [4, 5]); + test([1, 2, 3], 1, 1, [4, 5]); + test([1, 2, 3], 2, 3, [4, 5]); + test([1, 2, 3], 3, 3, [4, 5]); + test([1, 2, 3], 0, 3, [4, 5]); + test([1, 2, 3], 2, 3, [4]); + test([1, 2, 3], 0, 3, []); + test([1, 2, 3], 0, 1, [4, 5].map((x) => x)); + test([1, 2, 3], 1, 1, [4, 5].map((x) => x)); + test([1, 2, 3], 2, 3, [4, 5].map((x) => x)); + test([1, 2, 3], 3, 3, [4, 5].map((x) => x)); + test([1, 2, 3], 0, 3, [4, 5].map((x) => x)); + test([1, 2, 3], 2, 3, [4].map((x) => x)); + test([1, 2, 3], 0, 3, [].map((x) => x)); + test([1, 2, 3], 0, 1, const [4, 5]); + test([1, 2, 3], 1, 1, const [4, 5]); + test([1, 2, 3], 2, 3, const [4, 5]); + test([1, 2, 3], 3, 3, const [4, 5]); + test([1, 2, 3], 0, 3, const [4, 5]); + test([1, 2, 3], 2, 3, const [4]); + test([1, 2, 3], 0, 3, const []); + test([1, 2, 3], 0, 1, new Iterable.generate(2, (x) => x + 4)); + test([1, 2, 3], 1, 1, new Iterable.generate(2, (x) => x + 4)); + test([1, 2, 3], 2, 3, new Iterable.generate(2, (x) => x + 4)); + test([1, 2, 3], 3, 3, new Iterable.generate(2, (x) => x + 4)); + test([1, 2, 3], 0, 3, new Iterable.generate(2, (x) => x + 4)); + test([1, 2, 3], 2, 3, new Iterable.generate(2, (x) => x + 4)); + test(new MyList([1, 2, 3]), 0, 1, [4, 5]); + test(new MyList([1, 2, 3]), 1, 1, [4, 5]); + test(new MyList([1, 2, 3]), 2, 3, [4, 5]); + test(new MyList([1, 2, 3]), 3, 3, [4, 5]); + test(new MyList([1, 2, 3]), 0, 3, [4, 5]); + test(new MyList([1, 2, 3]), 2, 3, [4]); + test(new MyList([1, 2, 3]), 0, 3, []); + test(new MyList([1, 2, 3]), 0, 1, [4, 5].map((x) => x)); + test(new MyList([1, 2, 3]), 1, 1, [4, 5].map((x) => x)); + test(new MyList([1, 2, 3]), 2, 3, [4, 5].map((x) => x)); + test(new MyList([1, 2, 3]), 3, 3, [4, 5].map((x) => x)); + test(new MyList([1, 2, 3]), 0, 3, [4, 5].map((x) => x)); + test(new MyList([1, 2, 3]), 2, 3, [4].map((x) => x)); + test(new MyList([1, 2, 3]), 0, 3, [].map((x) => x)); + test(new MyList([1, 2, 3]), 0, 1, const [4, 5]); + test(new MyList([1, 2, 3]), 1, 1, const [4, 5]); + test(new MyList([1, 2, 3]), 2, 3, const [4, 5]); + test(new MyList([1, 2, 3]), 3, 3, const [4, 5]); + test(new MyList([1, 2, 3]), 0, 3, const [4, 5]); + test(new MyList([1, 2, 3]), 2, 3, const [4]); + test(new MyList([1, 2, 3]), 0, 3, const []); + test(new MyList([1, 2, 3]), 0, 1, new Iterable.generate(2, (x) => x + 4)); + test(new MyList([1, 2, 3]), 1, 1, new Iterable.generate(2, (x) => x + 4)); + test(new MyList([1, 2, 3]), 2, 3, new Iterable.generate(2, (x) => x + 4)); + test(new MyList([1, 2, 3]), 3, 3, new Iterable.generate(2, (x) => x + 4)); + test(new MyList([1, 2, 3]), 0, 3, new Iterable.generate(2, (x) => x + 4)); + test(new MyList([1, 2, 3]), 2, 3, new Iterable.generate(2, (x) => x + 4)); + + expectRE(() => test([1, 2, 3], -1, 0, [])); + expectRE(() => test([1, 2, 3], 2, 1, [])); + expectRE(() => test([1, 2, 3], 0, -1, [])); + expectRE(() => test([1, 2, 3], 1, 4, [])); + expectRE(() => test(new MyList([1, 2, 3]), -1, 0, [])); + expectRE(() => test(new MyList([1, 2, 3]), 2, 1, [])); + expectRE(() => test(new MyList([1, 2, 3]), 0, -1, [])); + expectRE(() => test(new MyList([1, 2, 3]), 1, 4, [])); + expectUE(() => test([1, 2, 3].toList(growable: false), 2, 3, [])); + expectUE(() => test([1, 2, 3].toList(growable: false), -1, 0, [])); + expectUE(() => test([1, 2, 3].toList(growable: false), 2, 1, [])); + expectUE(() => test([1, 2, 3].toList(growable: false), 0, -1, [])); + expectUE(() => test([1, 2, 3].toList(growable: false), 1, 4, [])); + expectUE(() => test(const [1, 2, 3], 2, 3, [])); + expectUE(() => test(const [1, 2, 3], -1, 0, [])); + expectUE(() => test(const [1, 2, 3], 2, 1, [])); + expectUE(() => test(const [1, 2, 3], 0, -1, [])); + expectUE(() => test(const [1, 2, 3], 1, 4, [])); +} + +void expectRE(Function f) { + Expect.throws(f, (e) => e is RangeError); +} + +void expectUE(Function f) { + Expect.throws(f, (e) => e is UnsupportedError); +} diff --git a/tests/corelib/list_reversed_test.dart b/tests/corelib/list_reversed_test.dart new file mode 100644 index 00000000000..382d7feffa5 --- /dev/null +++ b/tests/corelib/list_reversed_test.dart @@ -0,0 +1,136 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + testOperations(); +} + +class ThrowMarker { + const ThrowMarker(); + String toString() => "<>"; +} + +void testOperations() { + // Comparison lists. + List l = const [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; + List r = const [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]; + // A base list that starts out like l. + List base = l.toList(); + // A lazy reverse of base. + Iterable reversed = base.reversed; + + Expect.listEquals(r, reversed.toList()); + Expect.listEquals(l, reversed.toList().reversed.toList()); + for (int i = 0; i < r.length; i++) { + Expect.equals(r[i], reversed.elementAt(i)); + } + Expect.equals(4, base.indexOf(5)); + Expect.equals(5, reversed.toList().indexOf(5)); + + // Reversed followed by combinations of skip and take. + List subr = [8, 7, 6, 5, 4, 3]; + Expect.listEquals(subr, reversed.skip(2).take(6).toList()); + Expect.listEquals(subr, reversed.take(8).skip(2).toList()); + Expect.listEquals(subr, + reversed.toList().reversed.skip(2).take(6).toList().reversed.toList()); + Expect.listEquals(subr, + reversed.toList().reversed.take(8).skip(2).toList().reversed.toList()); + Expect.listEquals(subr, + reversed.take(8).toList().reversed.take(6).toList().reversed.toList()); + Expect.listEquals(subr, + reversed.toList().reversed.take(8).toList().reversed.take(6).toList()); + Expect.listEquals(subr, + reversed.toList().reversed.skip(2).toList().reversed.skip(2).toList()); + Expect.listEquals(subr, + reversed.skip(2).toList().reversed.skip(2).toList().reversed.toList()); + + void testList(List list) { + var throws = const ThrowMarker(); + void testEquals(v1, v2, path) { + if (v1 is Iterable) { + Iterator i1 = v1.iterator; + Iterator i2 = v2.iterator; + int index = 0; + while (i1.moveNext()) { + Expect.isTrue(i2.moveNext(), + "Too few actual values. Expected[$index] == ${i1.current}"); + testEquals(i1.current, i2.current, "$path[$index]"); + index++; + } + if (i2.moveNext()) { + Expect + .fail("Too many actual values. Actual[$index] == ${i2.current}"); + } + } else { + Expect.equals(v1, v2, path); + } + } + + void testOp(operation(Iterable reversedList), name) { + List reversedList = new List(list.length); + for (int i = 0; i < list.length; i++) { + reversedList[i] = list[list.length - 1 - i]; + } + Iterable reversed = list.reversed; + var expect; + try { + expect = operation(reversedList); + } catch (e) { + expect = throws; + } + var actual; + try { + actual = operation(reversed); + } catch (e) { + actual = throws; + } + testEquals(expect, actual, "$name: $list"); + } + + testOp((i) => i.first, "first"); + testOp((i) => i.last, "last"); + testOp((i) => i.single, "single"); + testOp((i) => i.firstWhere((n) => n < 5), "firstWhere<5"); + testOp((i) => i.firstWhere((n) => n < 10), "firstWhere<10"); + testOp((i) => i.lastWhere((n) => n < 5), "lastWhere<5"); + testOp((i) => i.lastWhere((n) => n < 10), "lastWhere<10"); + testOp((i) => i.singleWhere((n) => n < 5), "singelWhere<5"); + testOp((i) => i.singleWhere((n) => n < 10), "singelWhere<10"); + testOp((i) => i.contains(5), "contains(5)"); + testOp((i) => i.contains(10), "contains(10)"); + testOp((i) => i.any((n) => n < 5), "any<5"); + testOp((i) => i.any((n) => n < 10), "any<10"); + testOp((i) => i.every((n) => n < 5), "every<5"); + testOp((i) => i.every((n) => n < 10), "every<10"); + testOp((i) => i.reduce((a, b) => a + b), "reduce-sum"); + testOp((i) => i.fold(0, (a, b) => a + b), "fold-sum"); + testOp((i) => i.join("-"), "join-"); + testOp((i) => i.join(""), "join"); + testOp((i) => i.join(), "join-null"); + testOp((i) => i.map((n) => n * 2), "map*2"); + testOp((i) => i.where((n) => n < 5), "where<5"); + testOp((i) => i.where((n) => n < 10), "where<10"); + testOp((i) => i.expand((n) => []), "expand[]"); + testOp((i) => i.expand((n) => [n]), "expand[n]"); + testOp((i) => i.expand((n) => [n, n]), "expand[n, n]"); + } + + // Combinations of lists with 0, 1 and more elements. + testList([]); + testList([0]); + testList([10]); + testList([0, 1]); + testList([0, 10]); + testList([10, 11]); + testList([0, 5, 10]); + testList([10, 5, 0]); + testList([0, 1, 2, 3]); + testList([3, 4, 5, 6]); + testList([10, 11, 12, 13]); + + // Reverse const list. + Expect.listEquals(r, l.reversed.toList()); +} diff --git a/tests/corelib/list_set_all_test.dart b/tests/corelib/list_set_all_test.dart new file mode 100644 index 00000000000..cfe5a809b81 --- /dev/null +++ b/tests/corelib/list_set_all_test.dart @@ -0,0 +1,103 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; +import "dart:collection"; + +test(List list, int index, Iterable iterable) { + List copy = list.toList(); + list.setAll(index, iterable); + Expect.equals(copy.length, list.length); + for (int i = 0; i < index; i++) { + Expect.equals(copy[i], list[i]); + } + List iterableList = iterable.toList(); + for (int i = 0; i < iterableList.length; i++) { + Expect.equals(iterableList[i], list[i + index]); + } + for (int i = index + iterableList.length; i < copy.length; i++) { + Expect.equals(copy[i], list[i]); + } +} + +class MyList extends ListBase { + List list; + MyList(this.list); + get length => list.length; + set length(value) { + list.length = value; + } + + operator [](index) => list[index]; + operator []=(index, val) { + list[index] = val; + } + + toString() => list.toString(); +} + +main() { + test([1, 2, 3], 0, [4, 5]); + test([1, 2, 3], 1, [4, 5]); + test([1, 2, 3], 2, [4]); + test([1, 2, 3], 3, []); + test([1, 2, 3], 0, [4, 5].map((x) => x)); + test([1, 2, 3], 1, [4, 5].map((x) => x)); + test([1, 2, 3], 2, [4].map((x) => x)); + test([1, 2, 3], 3, [].map((x) => x)); + test([1, 2, 3], 0, const [4, 5]); + test([1, 2, 3], 1, const [4, 5]); + test([1, 2, 3], 2, const [4]); + test([1, 2, 3], 3, const []); + test([1, 2, 3], 0, new Iterable.generate(2, (x) => x + 4)); + test([1, 2, 3], 1, new Iterable.generate(2, (x) => x + 4)); + test([1, 2, 3], 2, new Iterable.generate(1, (x) => x + 4)); + test([1, 2, 3], 3, new Iterable.generate(0, (x) => x + 4)); + test([1, 2, 3].toList(growable: false), 0, [4, 5]); + test([1, 2, 3].toList(growable: false), 1, [4, 5]); + test([1, 2, 3].toList(growable: false), 2, [4]); + test([1, 2, 3].toList(growable: false), 3, []); + test([1, 2, 3].toList(growable: false), 0, [4, 5].map((x) => x)); + test([1, 2, 3].toList(growable: false), 1, [4, 5].map((x) => x)); + test([1, 2, 3].toList(growable: false), 2, [4].map((x) => x)); + test([1, 2, 3].toList(growable: false), 3, [].map((x) => x)); + test([1, 2, 3].toList(growable: false), 0, const [4, 5]); + test([1, 2, 3].toList(growable: false), 1, const [4, 5]); + test([1, 2, 3].toList(growable: false), 2, const [4]); + test([1, 2, 3].toList(growable: false), 3, const []); + test([1, 2, 3].toList(growable: false), 0, + new Iterable.generate(2, (x) => x + 4)); + test([1, 2, 3].toList(growable: false), 1, + new Iterable.generate(2, (x) => x + 4)); + test([1, 2, 3].toList(growable: false), 2, + new Iterable.generate(1, (x) => x + 4)); + test([1, 2, 3].toList(growable: false), 3, + new Iterable.generate(0, (x) => x + 4)); + test(new MyList([1, 2, 3]), 0, [4, 5]); + test(new MyList([1, 2, 3]), 1, [4, 5]); + test(new MyList([1, 2, 3]), 2, [4]); + test(new MyList([1, 2, 3]), 3, []); + test(new MyList([1, 2, 3]), 0, [4, 5].map((x) => x)); + test(new MyList([1, 2, 3]), 1, [4, 5].map((x) => x)); + test(new MyList([1, 2, 3]), 2, [4].map((x) => x)); + test(new MyList([1, 2, 3]), 3, [].map((x) => x)); + + expectRE(() => test([1, 2, 3], -1, [4, 5])); + expectRE(() => test([1, 2, 3].toList(growable: false), -1, [4, 5])); + expectRE(() => test([1, 2, 3], 1, [4, 5, 6])); + expectRE(() => test([1, 2, 3].toList(growable: false), 1, [4, 5, 6])); + expectRE(() => test(new MyList([1, 2, 3]), -1, [4, 5])); + expectRE(() => test(new MyList([1, 2, 3]), 1, [4, 5, 6])); + expectUE(() => test(const [1, 2, 3], 0, [4, 5])); + expectUE(() => test(const [1, 2, 3], -1, [4, 5])); + expectUE(() => test(const [1, 2, 3], 1, [4, 5, 6])); +} + +void expectRE(Function f) { + Expect.throws(f, (e) => e is RangeError); +} + +void expectUE(Function f) { + Expect.throws(f, (e) => e is UnsupportedError); +} diff --git a/tests/corelib/list_set_range_test.dart b/tests/corelib/list_set_range_test.dart new file mode 100644 index 00000000000..4b79ba3f5c2 --- /dev/null +++ b/tests/corelib/list_set_range_test.dart @@ -0,0 +1,120 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + var list = []; + list.setRange(0, 0, const []); + list.setRange(0, 0, []); + list.setRange(0, 0, const [], 1); + list.setRange(0, 0, [], 1); + Expect.equals(0, list.length); + expectIOORE(() { + list.setRange(0, 1, []); + }); + expectIOORE(() { + list.setRange(0, 1, [], 1); + }); + expectIOORE(() { + list.setRange(0, 1, [1], 0); + }); + + list.add(1); + list.setRange(0, 0, [], 0); + Expect.equals(1, list.length); + Expect.equals(1, list[0]); + list.setRange(0, 0, const [], 0); + Expect.equals(1, list.length); + Expect.equals(1, list[0]); + + expectIOORE(() { + list.setRange(0, 2, [1, 2]); + }); + Expect.equals(1, list.length); + Expect.equals(1, list[0]); + + expectSE(() { + list.setRange(0, 1, [1, 2], 2); + }); + Expect.equals(1, list.length); + Expect.equals(1, list[0]); + + list.setRange(0, 1, [2], 0); + Expect.equals(1, list.length); + Expect.equals(2, list[0]); + + list.setRange(0, 1, const [3], 0); + Expect.equals(1, list.length); + Expect.equals(3, list[0]); + + list.addAll([4, 5, 6]); + Expect.equals(4, list.length); + list.setRange(0, 4, [1, 2, 3, 4]); + Expect.listEquals([1, 2, 3, 4], list); + + list.setRange(2, 4, [5, 6, 7, 8]); + Expect.listEquals([1, 2, 5, 6], list); + + expectIOORE(() { + list.setRange(4, 5, [5, 6, 7, 8]); + }); + Expect.listEquals([1, 2, 5, 6], list); + + list.setRange(1, 3, [9, 10, 11, 12]); + Expect.listEquals([1, 9, 10, 6], list); + + testNegativeIndices(); + + testNonExtendableList(); +} + +void expectIOORE(Function f) { + Expect.throws(f, (e) => e is RangeError); +} + +void expectSE(Function f) { + Expect.throws(f, (e) => e is StateError); +} + +void expectAE(Function f) { + Expect.throws(f, (e) => e is ArgumentError); +} + +void testNegativeIndices() { + var list = [1, 2]; + expectIOORE(() { + list.setRange(-1, 1, [1]); + }); + expectAE(() { + list.setRange(0, 1, [1], -1); + }); + + // A negative length throws an ArgumentError. + expectIOORE(() { + list.setRange(2, 1, [1]); + }); + + expectAE(() { + list.setRange(-1, -2, [1], -1); + }); + Expect.listEquals([1, 2], list); + + expectIOORE(() { + list.setRange(-1, -1, [1]); + }); + Expect.listEquals([1, 2], list); + + // The skipCount is only used if the length is not 0. + list.setRange(0, 0, [1], -1); + Expect.listEquals([1, 2], list); +} + +void testNonExtendableList() { + var list = new List(6); + Expect.listEquals([null, null, null, null, null, null], list); + list.setRange(0, 3, [1, 2, 3, 4]); + list.setRange(3, 6, [1, 2, 3, 4]); + Expect.listEquals([1, 2, 3, 1, 2, 3], list); +} diff --git a/tests/corelib/list_sort_test.dart b/tests/corelib/list_sort_test.dart new file mode 100644 index 00000000000..7e896cd2212 --- /dev/null +++ b/tests/corelib/list_sort_test.dart @@ -0,0 +1,24 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +library list_sort_test; + +import 'sort_helper.dart'; + +class ListSortTest { + static void testMain() { + var compare = Comparable.compare; + var sort = (list) => list.sort(compare); + new SortHelper(sort, compare).run(); + + new SortHelper((list) => list.sort(), compare).run(); + + compare = (a, b) => -a.compareTo(b); + new SortHelper(sort, compare).run(); + } +} + +main() { + ListSortTest.testMain(); +} diff --git a/tests/corelib/list_sublist_test.dart b/tests/corelib/list_sublist_test.dart new file mode 100644 index 00000000000..7aada328cc8 --- /dev/null +++ b/tests/corelib/list_sublist_test.dart @@ -0,0 +1,57 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + Expect.listEquals([], [].sublist(0, 0)); + Expect.listEquals([], const [].sublist(0, 0)); + + Expect.listEquals([1, 2], [1, 2].sublist(0, 2)); + Expect.listEquals([1, 2], const [1, 2].sublist(0, 2)); + + Expect.listEquals([1], [1, 2].sublist(0, 1)); + Expect.listEquals([1], const [1, 2].sublist(0, 1)); + + Expect.listEquals([2], [1, 2].sublist(1, 2)); + Expect.listEquals([2], const [1, 2].sublist(1, 2)); + + Expect.listEquals([], [1, 2].sublist(0, 0)); + Expect.listEquals([], const [1, 2].sublist(0, 0)); + + Expect.listEquals([2, 3], [1, 2, 3, 4].sublist(1, 3)); + Expect.listEquals([2, 3], const [1, 2, 3, 4].sublist(1, 3)); + + Expect.listEquals([2, 3], [1, 2, 3, 4].sublist(1, 3)); + Expect.listEquals([2, 3], const [1, 2, 3, 4].sublist(1, 3)); + + expectAE(() => [].sublist(-1, null)); + expectAE(() => const [].sublist(-1, null)); + expectAE(() => [].sublist(-1, 0)); + expectAE(() => const [].sublist(-1, 0)); + expectAE(() => [].sublist(-1, -1)); + expectAE(() => const [].sublist(-1, -1)); + expectAE(() => [].sublist(-1, 1)); + expectAE(() => const [].sublist(-1, 1)); + expectAE(() => [].sublist(0, -1)); + expectAE(() => const [].sublist(0, -1)); + expectAE(() => [].sublist(0, 1)); + expectAE(() => const [].sublist(0, 1)); + expectAE(() => [].sublist(1, null)); + expectAE(() => const [].sublist(1, null)); + expectAE(() => [].sublist(1, 0)); + expectAE(() => const [].sublist(1, 0)); + expectAE(() => [].sublist(1, -1)); + expectAE(() => const [].sublist(1, -1)); + expectAE(() => [].sublist(1, 1)); + expectAE(() => const [].sublist(1, 1)); + + expectAE(() => [1].sublist(0, 2)); + expectAE(() => [1].sublist(1, 2)); + expectAE(() => [1].sublist(1, 0)); +} + +void expectAE(Function f) { + Expect.throws(f, (e) => e is ArgumentError); +} diff --git a/tests/corelib/list_test.dart b/tests/corelib/list_test.dart new file mode 100644 index 00000000000..0323c1de89d --- /dev/null +++ b/tests/corelib/list_test.dart @@ -0,0 +1,633 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "dart:collection"; +import "dart:typed_data"; +import "package:expect/expect.dart"; + +void main() { + // Typed lists - fixed length and can only contain integers. + testTypedList(new Uint8List(4)); + testTypedList(new Int8List(4)); + testTypedList(new Uint16List(4)); + testTypedList(new Int16List(4)); + testTypedList(new Uint32List(4)); + testTypedList(new Int32List(4)); + testTypedList(new Uint8List(4).toList(growable: false)); + testTypedList(new Int8List(4).toList(growable: false)); + testTypedList(new Uint16List(4).toList(growable: false)); + testTypedList(new Int16List(4).toList(growable: false)); + testTypedList(new Uint32List(4).toList(growable: false)); + testTypedList(new Int32List(4).toList(growable: false)); + + // Fixed length lists, length 4. + testFixedLengthList(new List(4)); + testFixedLengthList(new List(4).toList(growable: false)); + testFixedLengthList((new List()..length = 4).toList(growable: false)); + // ListBase implementation of List. + testFixedLengthList(new MyFixedList(new List(4))); + testFixedLengthList(new MyFixedList(new List(4)).toList(growable: false)); + + // Growable lists. Initial length 0. + testGrowableList(new List()); + testGrowableList(new List().toList()); + testGrowableList(new List(0).toList()); + testGrowableList(new List.filled(0, null, growable: true)); + testGrowableList([]); + testGrowableList((const []).toList()); + testGrowableList(new MyList([])); + testGrowableList(new MyList([]).toList()); + + testTypedGrowableList(new Uint8List(0).toList()); + testTypedGrowableList(new Int8List(0).toList()); + testTypedGrowableList(new Uint16List(0).toList()); + testTypedGrowableList(new Int16List(0).toList()); + testTypedGrowableList(new Uint32List(0).toList()); + testTypedGrowableList(new Int32List(0).toList()); + + testListConstructor(); + + testErrors(); +} + +void testErrors() { + // Regression for issue http://dartbug.com/24295 + testIndexError(list, index, name) { + try { + list[list.length]; + } catch (err, s) { + Expect.isTrue(err is RangeError, "$name[$index]"); + Expect.equals(list.length, err.invalidValue, "$name[$index] value"); + Expect.equals(list.length - 1, err.end, "$name[$index] end"); + Expect.equals(0, err.start, "$name[$index] start"); + } + } + + testIndex(list, name) { + testIndexError(list, list.length, name); // Just too big. + testIndexError(list, -1, name); // Negative. + testIndexError(list, 0x123456789, name); // > 2^32. + testIndexError(list, -0x123456789, name); // < -2^32. + } + + // Slices. + testSliceError(list, start, end, name) { + name = "$name[$start:$end]"; + var realError; + try { + RangeError.checkValidRange(start, end, list.length); + } catch (e) { + realError = e; + } + var result; + try { + result = list.sublist(start, end); + } catch (actualError) { + Expect.isNotNull(realError, "$name should not fail"); + Expect.isTrue(actualError is RangeError, "$name is-error: $actualError"); + Expect.equals(realError.name, actualError.name, "$name name"); + Expect.equals(realError.invalidValue, actualError.invalidValue, + "$name[0:l+1] value"); + Expect.equals(realError.start, actualError.start, "$name[0:l+1] start"); + Expect.equals(realError.end, actualError.end, "$name[0:l+1] end"); + return; + } + // Didn't throw. + Expect.isNull(realError, "$name should fail"); + Expect.equals(end - start, result.length, "$name result length"); + } + + testSlice(list, name) { + testSliceError(list, 0, list.length, name); // Should not fail. + testSliceError(list, 0, list.length + 1, name); + testSliceError(list, 0, 0x123456789, name); + testSliceError(list, -1, list.length, name); + testSliceError(list, -0x123456789, list.length, name); + testSliceError(list, list.length + 1, list.length + 1, name); + testSliceError(list, -1, null, name); + if (list.length > 0) { + testSliceError(list, list.length, list.length - 1, name); + } + } + + testRangeErrors(list, name) { + testIndex(list, "$name#${list.length} index"); + testSlice(list, "$name#${list.length} slice"); + } + + // Empty lists. + testRangeErrors([], "list"); + testRangeErrors(new List(0), "fixed-list"); + testRangeErrors(const [], "const-list"); + testRangeErrors(new List.unmodifiable([]), "unmodifiable"); + testRangeErrors(new Uint8List(0), "typed-list"); + testRangeErrors(new Uint8List.view(new Uint8List(0).buffer), "typed-list"); + testRangeErrors([1, 2, 3].sublist(1, 1), "sub-list"); + // Non-empty lists. + testRangeErrors([1, 2, 3], "list"); + testRangeErrors(new List(3), "fixed-list"); + testRangeErrors(const [1, 2, 3], "const-list"); + testRangeErrors(new List.unmodifiable([1, 2, 3]), "unmodifiable"); + testRangeErrors(new Uint8List(3), "typed-list"); + testRangeErrors(new Uint8List.view(new Uint8List(3).buffer), "typed-list"); + testRangeErrors([1, 2, 3, 4, 5].sublist(1, 3), "sub-list"); +} + +void testLength(int length, List list) { + Expect.equals(length, list.length); + (length == 0 ? Expect.isTrue : Expect.isFalse)(list.isEmpty); + (length != 0 ? Expect.isTrue : Expect.isFalse)(list.isNotEmpty); +} + +void testTypedLengthInvariantOperations(List list) { + // length + Expect.equals(list.length, 4); + // operators [], []=. + for (int i = 0; i < 4; i++) list[i] = 0; + list[0] = 4; + Expect.listEquals([4, 0, 0, 0], list); + list[1] = 7; + Expect.listEquals([4, 7, 0, 0], list); + list[3] = 2; + Expect.listEquals([4, 7, 0, 2], list); + + for (int i = 0; i < list.length; i++) { + list[i] = i; + } + + // indexOf, lastIndexOf + for (int i = 0; i < 4; i++) { + Expect.equals(i, list[i]); + Expect.equals(i, list.indexOf(i)); + Expect.equals(i, list.lastIndexOf(i)); + } + + // setRange. + list.setRange(0, 4, [3, 2, 1, 0]); + Expect.listEquals([3, 2, 1, 0], list); + + list.setRange(1, 4, list); + Expect.listEquals([3, 3, 2, 1], list); + + list.setRange(0, 3, list, 1); + Expect.listEquals([3, 2, 1, 1], list); + list.setRange(0, 3, list, 1); + Expect.listEquals([2, 1, 1, 1], list); + + list.setRange(2, 4, list, 0); + Expect.listEquals([2, 1, 2, 1], list); + + // setAll. + list.setAll(0, [3, 2, 0, 1]); + Expect.listEquals([3, 2, 0, 1], list); + list.setAll(1, [0, 1]); + Expect.listEquals([3, 0, 1, 1], list); + + // fillRange. + list.fillRange(1, 3, 7); + Expect.listEquals([3, 7, 7, 1], list); + list.fillRange(0, 0, 9); + Expect.listEquals([3, 7, 7, 1], list); + list.fillRange(4, 4, 9); + Expect.listEquals([3, 7, 7, 1], list); + list.fillRange(0, 4, 9); + Expect.listEquals([9, 9, 9, 9], list); + + // sort. + list.setRange(0, 4, [3, 2, 1, 0]); + list.sort(); + Expect.listEquals([0, 1, 2, 3], list); + list.setRange(0, 4, [1, 2, 3, 0]); + list.sort(); + Expect.listEquals([0, 1, 2, 3], list); + list.setRange(0, 4, [1, 3, 0, 2]); + list.sort((a, b) => b - a); // reverse compare. + Expect.listEquals([3, 2, 1, 0], list); + list.setRange(0, 4, [1, 2, 3, 0]); + list.sort((a, b) => b - a); + Expect.listEquals([3, 2, 1, 0], list); + + // Some Iterable methods. + + list.setRange(0, 4, [0, 1, 2, 3]); + // map. + testMap(val) { + return val * 2 + 10; + } + + List mapped = list.map(testMap).toList(); + Expect.equals(mapped.length, list.length); + for (var i = 0; i < list.length; i++) { + Expect.equals(mapped[i], list[i] * 2 + 10); + } + + matchAll(val) => true; + matchSome(val) { + return (val == 1 || val == 2); + } + + matchSomeFirst(val) { + return val == 0; + } + + matchSomeLast(val) { + return val == 3; + } + + matchNone(val) => false; + + // where. + Iterable filtered = list.where(matchSome); + Expect.equals(filtered.length, 2); + + // every + Expect.isTrue(list.every(matchAll)); + Expect.isFalse(list.every(matchSome)); + Expect.isFalse(list.every(matchNone)); + + // any + Expect.isTrue(list.any(matchAll)); + Expect.isTrue(list.any(matchSome)); + Expect.isTrue(list.any(matchSomeFirst)); + Expect.isTrue(list.any(matchSomeLast)); + Expect.isFalse(list.any(matchNone)); + + // Argument checking isn't implemented for typed arrays in browsers, + // so it's moved to the method below for now. +} + +void testLengthInvariantOperations(List list) { + testTypedLengthInvariantOperations(list); + // Tests that need untyped lists. + list.setAll(0, [0, 1, 2, 3]); + Expect.equals(-1, list.indexOf(100)); + Expect.equals(-1, list.lastIndexOf(100)); + list[2] = new Yes(); + Expect.equals(2, list.indexOf(100)); + Expect.equals(2, list.lastIndexOf(100)); + list[3] = new Yes(); + Expect.equals(2, list.indexOf(100)); + Expect.equals(3, list.lastIndexOf(100)); + list[2] = 2; + Expect.equals(3, list.indexOf(100)); + Expect.equals(3, list.lastIndexOf(100)); + list[3] = 3; + Expect.equals(-1, list.indexOf(100)); + Expect.equals(-1, list.lastIndexOf(100)); + + // Argument errors on bad indices. List is still [0, 1, 2, 3]. + testArgumentError(action()) { + Expect.throws(action, (e) => e is ArgumentError); + } + + // Direct indices (0 <= index < length). + testArgumentError(() => list[-1]); + testArgumentError(() => list[4]); + testArgumentError(() => list[-1] = 99); + testArgumentError(() => list[4] = 99); + testArgumentError(() => list.elementAt(-1)); + testArgumentError(() => list.elementAt(4)); + // Ranges (0 <= start <= end <= length). + testArgumentError(() => list.sublist(-1, 2)); + testArgumentError(() => list.sublist(-1, 5)); + testArgumentError(() => list.sublist(2, 5)); + testArgumentError(() => list.sublist(4, 2)); + testArgumentError(() => list.getRange(-1, 2)); + testArgumentError(() => list.getRange(-1, 5)); + testArgumentError(() => list.getRange(2, 5)); + testArgumentError(() => list.getRange(4, 2)); + testArgumentError(() => list.setRange(-1, 2, [1, 2, 3])); + testArgumentError(() => list.setRange(-1, 5, [1, 2, 3, 4, 5, 6])); + testArgumentError(() => list.setRange(2, 5, [1, 2, 3])); + testArgumentError(() => list.setRange(4, 2, [1, 2])); + // for setAll, end is implicitly start + values.length. + testArgumentError(() => list.setAll(-1, [])); + testArgumentError(() => list.setAll(5, [])); + testArgumentError(() => list.setAll(2, [1, 2, 3])); + testArgumentError(() => list.fillRange(-1, 2)); + testArgumentError(() => list.fillRange(-1, 5)); + testArgumentError(() => list.fillRange(2, 5)); + testArgumentError(() => list.fillRange(4, 2)); +} + +void testTypedList(List list) { + testTypedLengthInvariantOperations(list); + testCannotChangeLength(list); +} + +void testFixedLengthList(List list) { + testLengthInvariantOperations(list); + testCannotChangeLength(list); +} + +void testCannotChangeLength(List list) { + isUnsupported(action()) { + Expect.throws(action, (e) => e is UnsupportedError); + } + + isUnsupported(() => list.add(0)); + isUnsupported(() => list.addAll([0])); + isUnsupported(() => list.removeLast()); + isUnsupported(() => list.insert(0, 1)); + isUnsupported(() => list.insertAll(0, [1])); + isUnsupported(() => list.clear()); + isUnsupported(() => list.remove(1)); + isUnsupported(() => list.removeAt(1)); + isUnsupported(() => list.removeRange(0, 1)); + isUnsupported(() => list.replaceRange(0, 1, [])); +} + +void testTypedGrowableList(List list) { + testLength(0, list); + // set length. + list.length = 4; + testLength(4, list); + + testTypedLengthInvariantOperations(list); + + testGrowableListOperations(list); +} + +void testGrowableList(List list) { + testLength(0, list); + // set length. + list.length = 4; + testLength(4, list); + + testLengthInvariantOperations(list); + + testGrowableListOperations(list); +} + +void testGrowableListOperations(List list) { + // add, removeLast. + list.clear(); + testLength(0, list); + list.add(4); + testLength(1, list); + Expect.equals(4, list.removeLast()); + testLength(0, list); + + for (int i = 0; i < 100; i++) { + list.add(i); + } + + Expect.equals(list.length, 100); + for (int i = 0; i < 100; i++) { + Expect.equals(i, list[i]); + } + + Expect.equals(17, list.indexOf(17)); + Expect.equals(17, list.lastIndexOf(17)); + Expect.equals(-1, list.indexOf(999)); + Expect.equals(-1, list.lastIndexOf(999)); + + Expect.equals(99, list.removeLast()); + testLength(99, list); + + // remove. + Expect.isTrue(list.remove(4)); + testLength(98, list); + Expect.isFalse(list.remove(4)); + testLength(98, list); + list.clear(); + testLength(0, list); + + list.add(4); + list.add(4); + testLength(2, list); + Expect.isTrue(list.remove(4)); + testLength(1, list); + Expect.isTrue(list.remove(4)); + testLength(0, list); + Expect.isFalse(list.remove(4)); + testLength(0, list); + + // removeWhere, retainWhere + for (int i = 0; i < 100; i++) { + list.add(i); + } + testLength(100, list); + list.removeWhere((int x) => x.isOdd); + testLength(50, list); + for (int i = 0; i < list.length; i++) { + Expect.isTrue(list[i].isEven); + } + list.retainWhere((int x) => (x % 3) == 0); + testLength(17, list); + for (int i = 0; i < list.length; i++) { + Expect.isTrue((list[i] % 6) == 0); + } + + // insert, remove, removeAt + list.clear(); + testLength(0, list); + + list.insert(0, 0); + Expect.listEquals([0], list); + + list.insert(0, 1); + Expect.listEquals([1, 0], list); + + list.insert(0, 2); + Expect.listEquals([2, 1, 0], list); + + Expect.isTrue(list.remove(1)); + Expect.listEquals([2, 0], list); + + list.insert(1, 1); + Expect.listEquals([2, 1, 0], list); + + list.removeAt(1); + Expect.listEquals([2, 0], list); + + list.removeAt(1); + Expect.listEquals([2], list); + + // insertAll + list.insertAll(0, [1, 2, 3]); + Expect.listEquals([1, 2, 3, 2], list); + + list.insertAll(2, []); + Expect.listEquals([1, 2, 3, 2], list); + + list.insertAll(4, [7, 9]); + Expect.listEquals([1, 2, 3, 2, 7, 9], list); + + // addAll + list.addAll(list.reversed.toList()); + Expect.listEquals([1, 2, 3, 2, 7, 9, 9, 7, 2, 3, 2, 1], list); + + list.addAll([]); + Expect.listEquals([1, 2, 3, 2, 7, 9, 9, 7, 2, 3, 2, 1], list); + + // replaceRange + list.replaceRange(3, 7, [0, 0]); + Expect.listEquals([1, 2, 3, 0, 0, 7, 2, 3, 2, 1], list); + + list.replaceRange(2, 3, [5, 5, 5]); + Expect.listEquals([1, 2, 5, 5, 5, 0, 0, 7, 2, 3, 2, 1], list); + + list.replaceRange(2, 4, [6, 6]); + Expect.listEquals([1, 2, 6, 6, 5, 0, 0, 7, 2, 3, 2, 1], list); + + list.replaceRange(6, 8, []); + Expect.listEquals([1, 2, 6, 6, 5, 0, 2, 3, 2, 1], list); + + // Operations that change the length cause ConcurrentModificationError. + void testConcurrentModification(action()) { + testIterator(int when) { + list.length = 4; + list.setAll(0, [0, 1, 2, 3]); + Expect.throws(() { + for (var element in list) { + if (element == when) action(); + } + }, (e) => e is ConcurrentModificationError); + } + + testForEach(int when) { + list.length = 4; + list.setAll(0, [0, 1, 2, 3]); + Expect.throws(() { + list.forEach((var element) { + if (element == when) action(); + }); + }, (e) => e is ConcurrentModificationError); + } + + // Test the change at different points of the iteration. + testIterator(0); + testIterator(1); + testIterator(3); + testForEach(0); + testForEach(1); + testForEach(3); + } + + testConcurrentModification(() => list.add(5)); + testConcurrentModification(() => list.addAll([5, 6])); + testConcurrentModification(() => list.removeLast()); + for (int i = 0; i < 4; i++) { + testConcurrentModification(() => list.remove(i)); + testConcurrentModification(() => list.removeAt(i)); + testConcurrentModification(() => list.removeWhere((x) => x == i)); + testConcurrentModification(() => list.retainWhere((x) => x != i)); + testConcurrentModification(() => list.insert(i, 5)); + testConcurrentModification(() => list.insertAll(i, [5, 6])); + testConcurrentModification(() => list.removeRange(i, i + 1)); + testConcurrentModification(() => list.replaceRange(i, i + 1, [5, 6])); + } + + // Any operation that doesn't change the length should be safe for iteration. + testSafeConcurrentModification(action()) { + list.length = 4; + list.setAll(0, [0, 1, 2, 3]); + for (var i in list) { + action(); + } + list.forEach((e) => action()); + } + + testSafeConcurrentModification(() { + list.add(5); + list.removeLast(); + }); + testSafeConcurrentModification(() { + list.add(list[0]); + list.removeAt(0); + }); + testSafeConcurrentModification(() { + list.insert(0, list.removeLast()); + }); + testSafeConcurrentModification(() { + list.replaceRange(1, 3, list.sublist(1, 3).reversed); + }); + + // Argument errors on bad indices for methods that are only allowed + // on growable lists. + list.length = 4; + list.setAll(0, [0, 1, 2, 3]); + testArgumentError(action()) { + Expect.throws(action, (e) => e is ArgumentError); + } + + // Direct indices (0 <= index < length). + testArgumentError(() => list.removeAt(-1)); + testArgumentError(() => list.removeAt(4)); + // Direct indices including end (0 <= index <= length). + testArgumentError(() => list.insert(-1, 0)); + testArgumentError(() => list.insert(5, 0)); + testArgumentError(() => list.insertAll(-1, [0])); + testArgumentError(() => list.insertAll(5, [0])); + testArgumentError(() => list.insertAll(-1, [0])); + testArgumentError(() => list.insertAll(5, [0])); + // Ranges (0 <= start <= end <= length). + testArgumentError(() => list.removeRange(-1, 2)); + testArgumentError(() => list.removeRange(2, 5)); + testArgumentError(() => list.removeRange(-1, 5)); + testArgumentError(() => list.removeRange(4, 2)); + testArgumentError(() => list.replaceRange(-1, 2, [9])); + testArgumentError(() => list.replaceRange(2, 5, [9])); + testArgumentError(() => list.replaceRange(-1, 5, [9])); + testArgumentError(() => list.replaceRange(4, 2, [9])); +} + +class Yes { + operator ==(var other) => true; + int get hashCode => 0; +} + +class MyList extends ListBase { + List _source; + MyList(this._source); + int get length => _source.length; + void set length(int length) { + _source.length = length; + } + + E operator [](int index) => _source[index]; + void operator []=(int index, E value) { + _source[index] = value; + } +} + +class MyFixedList extends ListBase { + List _source; + MyFixedList(this._source); + int get length => _source.length; + void set length(int length) { + throw new UnsupportedError("Fixed length!"); + } + + E operator [](int index) => _source[index]; + void operator []=(int index, E value) { + _source[index] = value; + } +} + +void testListConstructor() { + // Is fixed-length. + Expect.throws(() { + new List(0).add(4); + }); + Expect.throws(() { new List(-2); }); // Not negative. //# 01: ok + // Not null. + Expect.throws(() { + new List(null); + }); + Expect.listEquals([4], new List()..add(4)); + // Is fixed-length. + Expect.throws(() { + new List.filled(0, 42).add(4); + }); + // Not negative. + Expect.throws(() { + new List.filled(-2, 42); + }); + // Not null. + Expect.throws(() { + new List.filled(null, 42); + }); +} diff --git a/tests/corelib/list_to_string2_test.dart b/tests/corelib/list_to_string2_test.dart new file mode 100644 index 00000000000..d46e9d542dd --- /dev/null +++ b/tests/corelib/list_to_string2_test.dart @@ -0,0 +1,32 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + List list = [1, 2]; + list.add(list); + + List list2 = new List(4); + list2[0] = 1; + list2[1] = 2; + list2[2] = list2; + list2[3] = list; + + Expect.equals("[1, 2, [...]]", list.toString()); + Expect.equals("[1, 2, [...], [1, 2, [...]]]", list2.toString()); + + // Throwing in the middle of a toString does not leave the + // list as being visited. + List list3 = [1, 2, new ThrowOnToString(), 4]; + Expect.throws(list3.toString, (e) => e == "Bad!"); + list3[2] = 3; + Expect.equals("[1, 2, 3, 4]", list3.toString()); +} + +class ThrowOnToString { + String toString() { + throw "Bad!"; + } +} diff --git a/tests/corelib/list_to_string_test.dart b/tests/corelib/list_to_string_test.dart new file mode 100644 index 00000000000..fed5277fe18 --- /dev/null +++ b/tests/corelib/list_to_string_test.dart @@ -0,0 +1,31 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; +import 'dart:collection'; + +class MyList extends ListBase { + final list; + MyList(this.list); + + get length => list.length; + set length(val) { + list.length = val; + } + + operator [](index) => list[index]; + operator []=(index, val) => list[index] = val; +} + +main() { + Expect.equals("[]", [].toString()); + Expect.equals("[1]", [1].toString()); + Expect.equals("[1, 2]", [1, 2].toString()); + Expect.equals("[]", const [].toString()); + Expect.equals("[1]", const [1].toString()); + Expect.equals("[1, 2]", const [1, 2].toString()); + Expect.equals("[]", new MyList([]).toString()); + Expect.equals("[1]", new MyList([1]).toString()); + Expect.equals("[1, 2]", new MyList([1, 2]).toString()); +} diff --git a/tests/corelib/list_unmodifiable_test.dart b/tests/corelib/list_unmodifiable_test.dart new file mode 100644 index 00000000000..1a29c0030bc --- /dev/null +++ b/tests/corelib/list_unmodifiable_test.dart @@ -0,0 +1,304 @@ +// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; +import "dart:collection"; +import "dart:typed_data"; + +main() { + var intTest = new Test(); + intTest.run("ConstList", createConstList); + intTest.run("FixedList", createFixedList); + intTest.run("GrowableList", createGrowableList); + intTest.run("ConstMapKeys", createConstMapKeys); + intTest.run("ConstMapValues", createConstMapValues); + intTest.run("MapKeys", createMapKeys); + intTest.run("MapValues", createMapValues); + intTest.run("SplayMapKeys", createSplayMapKeys); + intTest.run("SplayMapValues", createSplayMapValues); + intTest.run("Set", createSet); + intTest.run("SplaySet", createSplaySet); + intTest.run("Queue", createQueue); + intTest.run("ListMapKeys", createListMapKeys); + intTest.run("ListMapValues", createListMapValues); + intTest.run("CodeUnits", createCodeUnits); + intTest.run("TypedList", createTypedList); + + new Test().test("strings", ["a", "b", "c"]); + + new Test().test("superclass", [1, 2, 3]); + new Test().test("subclass", [1, 2, 3]); +} + +class Test { + run(name, Iterable create(int size)) { + test(name, create(0)); + test(name, create(1)); + test(name, create(3)); + } + + test(name, iterable) { + testSingle(name, iterable); + testSingle("$name-where", iterable.where((x) => true)); + testSingle("$name-map", iterable.map((x) => x)); + testSingle("$name-expand", iterable.expand((x) => [x, x])); + testSingle("$name-skip", iterable.skip(1)); + testSingle("$name-take", iterable.take(2)); + testSingle("$name-skipWhile", iterable.skipWhile((x) => false)); + testSingle("$name-takeWhile", iterable.takeWhile((x) => true)); + } + + testSingle(name, iterable) { + var elements = iterable.toList(); + int length = elements.length; + + var list = new List.unmodifiable(iterable); + + Expect.isTrue(list is List, "$name-type-$E"); + Expect.isTrue(list is! List, "$name-!type-!$E"); + + checkElements() { + Expect.equals(length, list.length); + for (int i = 0; i < length; i++) { + Expect.identical(elements[i], list[i], "$name-identical-$i"); + } + } + + checkElements(); + + throws(funcName, func) { + try { + func(); + } catch (e, s) { + Expect.isTrue(e is UnsupportedError, "$name: $funcName threw $e"); + return; + } + checkElements(); + Expect.fail("$name: $funcName didn't throw"); + } + + throws("[]=", () { + list[0] = null; + }); + throws("length=", () { + list.length = length + 1; + }); + throws("length=", () { + list.length = length - 1; + }); + throws("setAll", () { + list.setAll(0, []); + }); + throws("add", () { + list.add(null); + }); + throws("insert", () { + list.insert(0, null); + }); + throws("insertAll", () { + list.insertAll(0, []); + }); + throws("addAll", () { + list.addAll([]); + }); + throws("remove", () { + list.remove(null); + }); + throws("removeWhere", () { + list.removeWhere((x) => true); + }); + throws("retainWhere", () { + list.retainWhere((x) => false); + }); + throws("sort", () { + list.sort(); + }); + throws("shuffle", () { + list.shuffle(); + }); + throws("clear", () { + list.clear(); + }); + throws("removeAt", () { + list.removeAt(0); + }); + throws("removeLast", () { + list.removeLast(); + }); + throws("setRange", () { + list.setRange(0, 1, []); + }); + throws("removeRange", () { + list.removeRange(0, 1); + }); + throws("replaceRange", () { + list.replaceRange(0, 1, []); + }); + throws("fillRange", () { + list.fillRange(0, 1, null); + }); + + success(opName, op(list)) { + var expect; + try { + expect = op(elements); + } catch (e) { + try { + op(list); + } catch (e2) { + Expect.equals( + e.runtimeType, + e2.runtimeType, + "$name :: $opName threw different exceptions: " + "${e.runtimeType} vs ${e2.runtimeType}"); + return; + } + Expect.fail("$name-$opName didn't throw, expected: $e"); + } + var actual = op(list); + checkElements(); + if (expect is List) { + Expect.listEquals(expect, actual, "$name-$opName"); + } else if (expect is Iterable) { + Expect.isTrue(actual is Iterable); + Expect.listEquals(expect.toList(), actual.toList(), "$name-$opName"); + } else { + Expect.equals(expect, actual, "$name-$opName"); + } + } + + success("indexOf", (l) => l.indexOf(null)); + success("lastIndexOf", (l) => l.lastIndexOf(null)); + success("contains", (l) => l.contains(2)); + success("elementAt", (l) => l.elementAt[1]); + success("reversed", (l) => l.reversed); + success("sublist0-1", (l) => l.sublist(0, 1)); + success("getRange0-1", (l) => l.getRange(0, 1)); + success("asMap-keys", (l) => l.asMap().keys); + success("asMap-values", (l) => l.asMap().values); + success("where", (l) => l.where((x) => true)); + success("map", (l) => l.map((x) => x)); + success("expand", (l) => l.expand((x) => [x, x])); + success("skip", (l) => l.skip(1)); + success("take", (l) => l.take(1)); + success("skipWhile", (l) => l.skipWhile((x) => false)); + success("takeWhile", (l) => l.takeWhile((x) => true)); + success("first", (l) => l.first); + success("last", (l) => l.last); + success("single", (l) => l.single); + success("firstWhere", (l) => l.firstWhere((x) => true)); + success("lastWhere", (l) => l.lastWhere((x) => true)); + success("singleWhere", (l) => l.singleWhere((x) => true)); + success("isEmpty", (l) => l.isEmpty); + success("isNotEmpty", (l) => l.isNotEmpty); + success("join", (l) => l.join("/")); + success("fold", (l) => l.fold("--", (a, b) => "$a/$b")); + success("reduce", (l) => l.reduce((a, b) => a + b)); + success("every", (l) => l.every((x) => x == 0)); + success("any", (l) => l.any((x) => x == 2)); + success("toList", (l) => l.toList()); + success("toSet", (l) => l.toSet()); + success("toString", (l) => l.toString()); + + var it = elements.iterator; + list.forEach((v) { + Expect.isTrue(it.moveNext()); + Expect.equals(it.current, v); + }); + Expect.isFalse(it.moveNext()); + + if (elements is List && list is List) { + success("String.fromCharCodes", (l) => new String.fromCharCodes(l)); + } + } +} + +createConstList(n) { + if (n == 0) return const []; + return const [1, 2, 3]; +} + +createFixedList(n) { + var result = new List(n); + for (int i = 0; i < n; i++) result[i] = n; + return result; +} + +createGrowableList(n) { + var result = new List()..length = n; + for (int i = 0; i < n; i++) result[i] = n; + return result; +} + +createIterable(n) => new Iterable.generate(n); +createConstMapKeys(n) { + if (n == 0) return const {}.keys; + return const {0: 0, 1: 1, 2: 2}.keys; +} + +createConstMapValues(n) { + if (n == 0) return const {}.values; + return const {0: 0, 1: 1, 2: 2}.values; +} + +createMapKeys(n) { + var map = {}; + for (int i = 0; i < n; i++) map[i] = i; + return map.keys; +} + +createMapValues(n) { + var map = {}; + for (int i = 0; i < n; i++) map[i] = i; + return map.values; +} + +createSplayMapKeys(n) { + var map = new SplayTreeMap(); + for (int i = 0; i < n; i++) map[i] = i; + return map.keys; +} + +createSplayMapValues(n) { + var map = new SplayTreeMap(); + for (int i = 0; i < n; i++) map[i] = i; + return map.values; +} + +createSet(n) { + var set = new Set(); + for (int i = 0; i < n; i++) set.add(i); + return set; +} + +createSplaySet(n) { + var set = new SplayTreeSet(); + for (int i = 0; i < n; i++) set.add(i); + return set; +} + +createQueue(n) { + var queue = new Queue(); + for (int i = 0; i < n; i++) queue.add(i); + return queue; +} + +createListMapKeys(n) { + return createGrowableList(n).asMap().keys; +} + +createListMapValues(n) { + return createGrowableList(n).asMap().values; +} + +createCodeUnits(n) { + var string = new String.fromCharCodes(new Iterable.generate(n)); + return string.codeUnits; +} + +createTypedList(n) { + var tl = new Uint8List(n); + for (int i = 0; i < n; i++) tl[i] = i; + return tl; +} diff --git a/tests/corelib/main_test.dart b/tests/corelib/main_test.dart new file mode 100644 index 00000000000..024e91fab46 --- /dev/null +++ b/tests/corelib/main_test.dart @@ -0,0 +1,11 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +library main_test; + +import "package:expect/expect.dart"; + +main(List args) { + Expect.equals(0, args.length); +} diff --git a/tests/corelib/map_contains_key_test.dart b/tests/corelib/map_contains_key_test.dart new file mode 100644 index 00000000000..d597a991672 --- /dev/null +++ b/tests/corelib/map_contains_key_test.dart @@ -0,0 +1,27 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +class A { + const A(); +} + +class B extends A { + const B(); +} + +main() { + var map1 = new Map(); + map1[const B()] = const B(); + var map2 = new Map(); + var list = [const B()]; + + var maps = [map1, map2]; + for (var map in maps) { + // Test that the map accepts a key is not of the same type: + // Map.containsValue(A) + Expect.isFalse(map.containsKey(new A())); + } +} diff --git a/tests/corelib/map_contains_value_test.dart b/tests/corelib/map_contains_value_test.dart new file mode 100644 index 00000000000..7837417e3fd --- /dev/null +++ b/tests/corelib/map_contains_value_test.dart @@ -0,0 +1,28 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +class A { + const A(); +} + +class B extends A { + const B(); +} + +main() { + var map1 = new Map(); + map1[const B()] = const B(); + var map2 = new Map(); + var list = [const B()]; + Map map3 = list.asMap(); + + var maps = [map1, map2, map3]; + for (var map in maps) { + // Test that the map accepts a value is not of the same type: + // Map.containsValue(A) + Expect.isFalse(map.containsValue(new A())); + } +} diff --git a/tests/corelib/map_from_iterable_test.dart b/tests/corelib/map_from_iterable_test.dart new file mode 100644 index 00000000000..b4e7571ec5d --- /dev/null +++ b/tests/corelib/map_from_iterable_test.dart @@ -0,0 +1,111 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; +import 'dart:collection'; + +main() { + defaultFunctionValuesTest(); + defaultKeyFunctionTest(); + defaultValueFunctionTest(); + noDefaultValuesTest(); + emptyIterableTest(); + equalElementsTest(); + genericTypeTest(); +} + +void defaultFunctionValuesTest() { + var map = new HashMap.fromIterable([1, 2, 3]); + + Expect.isTrue(map is Map); + Expect.isTrue(map is HashMap); + + Expect.equals(3, map.length); + Expect.equals(3, map.keys.length); + Expect.equals(3, map.values.length); + + Expect.equals(1, map[1]); + Expect.equals(2, map[2]); + Expect.equals(3, map[3]); +} + +void defaultKeyFunctionTest() { + var map = new HashMap.fromIterable([1, 2, 3], value: (x) => x + 1); + + Expect.isTrue(map is Map); + Expect.isTrue(map is HashMap); + + Expect.equals(3, map.length); + Expect.equals(3, map.keys.length); + Expect.equals(3, map.values.length); + + Expect.equals(2, map[1]); + Expect.equals(3, map[2]); + Expect.equals(4, map[3]); +} + +void defaultValueFunctionTest() { + var map = new HashMap.fromIterable([1, 2, 3], key: (x) => x + 1); + + Expect.isTrue(map is Map); + Expect.isTrue(map is HashMap); + + Expect.equals(3, map.length); + Expect.equals(3, map.keys.length); + Expect.equals(3, map.values.length); + + Expect.equals(1, map[2]); + Expect.equals(2, map[3]); + Expect.equals(3, map[4]); +} + +void noDefaultValuesTest() { + var map = new HashMap.fromIterable([1, 2, 3], + key: (x) => x + 1, value: (x) => x - 1); + + Expect.isTrue(map is Map); + Expect.isTrue(map is HashMap); + + Expect.equals(3, map.length); + Expect.equals(3, map.keys.length); + Expect.equals(3, map.values.length); + + Expect.equals(0, map[2]); + Expect.equals(1, map[3]); + Expect.equals(2, map[4]); +} + +void emptyIterableTest() { + var map = new HashMap.fromIterable([]); + Expect.isTrue(map is Map); + Expect.isTrue(map is HashMap); + + Expect.equals(0, map.length); + Expect.equals(0, map.keys.length); + Expect.equals(0, map.values.length); +} + +void equalElementsTest() { + var map = new HashMap.fromIterable([1, 2, 2], key: (x) => x + 1); + + Expect.isTrue(map is Map); + Expect.isTrue(map is HashMap); + + Expect.equals(2, map.length); + Expect.equals(2, map.keys.length); + Expect.equals(2, map.values.length); + + Expect.equals(1, map[2]); + Expect.equals(2, map[3]); +} + +void genericTypeTest() { + var map = new HashMap.fromIterable([1, 2, 3], + key: (x) => '$x', value: (x) => '$x'); + Expect.isTrue(map is Map); + + // Make sure it is not just Map. + Expect.isFalse(map is Map); + Expect.isFalse(map is Map); +} diff --git a/tests/corelib/map_from_iterables_test.dart b/tests/corelib/map_from_iterables_test.dart new file mode 100644 index 00000000000..73958c5f4b1 --- /dev/null +++ b/tests/corelib/map_from_iterables_test.dart @@ -0,0 +1,78 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; +import 'dart:collection'; + +main() { + positiveTest(); + emptyMapTest(); + fewerKeysIterableTest(); + fewerValuesIterableTest(); + equalElementsTest(); + genericTypeTest(); +} + +void positiveTest() { + var map = new Map.fromIterables([1, 2, 3], ["one", "two", "three"]); + Expect.isTrue(map is Map); + Expect.isTrue(map is LinkedHashMap); + + Expect.equals(3, map.length); + Expect.equals(3, map.keys.length); + Expect.equals(3, map.values.length); + + Expect.equals("one", map[1]); + Expect.equals("two", map[2]); + Expect.equals("three", map[3]); +} + +void emptyMapTest() { + var map = new Map.fromIterables([], []); + Expect.isTrue(map is Map); + Expect.isTrue(map is LinkedHashMap); + + Expect.equals(0, map.length); + Expect.equals(0, map.keys.length); + Expect.equals(0, map.values.length); +} + +void fewerValuesIterableTest() { + Expect.throws(() => new Map.fromIterables([1, 2], [0])); +} + +void fewerKeysIterableTest() { + Expect.throws(() => new Map.fromIterables([1], [0, 2])); +} + +void equalElementsTest() { + var map = new Map.fromIterables([1, 2, 2], ["one", "two", "three"]); + Expect.isTrue(map is Map); + Expect.isTrue(map is LinkedHashMap); + + Expect.equals(2, map.length); + Expect.equals(2, map.keys.length); + Expect.equals(2, map.values.length); + + Expect.equals("one", map[1]); + Expect.equals("three", map[2]); +} + +void genericTypeTest() { + var map = + new Map.fromIterables([1, 2, 3], ["one", "two", "three"]); + Expect.isTrue(map is Map); + + // Make sure it is not just Map. + Expect.isFalse(map is Map); + Expect.isFalse(map is Map); + + Expect.equals(3, map.length); + Expect.equals(3, map.keys.length); + Expect.equals(3, map.values.length); + + Expect.equals("one", map[1]); + Expect.equals("two", map[2]); + Expect.equals("three", map[3]); +} diff --git a/tests/corelib/map_from_test.dart b/tests/corelib/map_from_test.dart new file mode 100644 index 00000000000..49913099b31 --- /dev/null +++ b/tests/corelib/map_from_test.dart @@ -0,0 +1,101 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +library map.from.test; + +import "package:expect/expect.dart"; +import 'dart:collection'; + +main() { + testWithConstMap(); + testWithNonConstMap(); + testWithHashMap(); + testWithLinkedMap(); +} + +testWithConstMap() { + var map = const {'b': 42, 'a': 43}; + var otherMap = new Map.from(map); + Expect.isTrue(otherMap is Map); + Expect.isTrue(otherMap is HashMap); + Expect.isTrue(otherMap is LinkedHashMap); + + Expect.equals(2, otherMap.length); + Expect.equals(2, otherMap.keys.length); + Expect.equals(2, otherMap.values.length); + + var count = (map) { + int cnt = 0; + map.forEach((a, b) { + cnt += b; + }); + return cnt; + }; + + Expect.equals(42 + 43, count(map)); + Expect.equals(count(map), count(otherMap)); +} + +testWithNonConstMap() { + var map = {'b': 42, 'a': 43}; + var otherMap = new Map.from(map); + Expect.isTrue(otherMap is Map); + Expect.isTrue(otherMap is HashMap); + Expect.isTrue(otherMap is LinkedHashMap); + + Expect.equals(2, otherMap.length); + Expect.equals(2, otherMap.keys.length); + Expect.equals(2, otherMap.values.length); + + int count(map) { + int count = 0; + map.forEach((a, b) { + count += b; + }); + return count; + } + + ; + + Expect.equals(42 + 43, count(map)); + Expect.equals(count(map), count(otherMap)); + + // Test that adding to the original map does not change otherMap. + map['c'] = 44; + Expect.equals(3, map.length); + Expect.equals(2, otherMap.length); + Expect.equals(2, otherMap.keys.length); + Expect.equals(2, otherMap.values.length); + + // Test that adding to otherMap does not change the original map. + otherMap['c'] = 44; + Expect.equals(3, map.length); + Expect.equals(3, otherMap.length); + Expect.equals(3, otherMap.keys.length); + Expect.equals(3, otherMap.values.length); +} + +testWithHashMap() { + var map = const {'b': 1, 'a': 2, 'c': 3}; + var otherMap = new HashMap.from(map); + Expect.isTrue(otherMap is Map); + Expect.isTrue(otherMap is HashMap); + Expect.isTrue(otherMap is! LinkedHashMap); + var i = 1; + for (var val in map.values) { + Expect.equals(i++, val); + } +} + +testWithLinkedMap() { + var map = const {'b': 1, 'a': 2, 'c': 3}; + var otherMap = new LinkedHashMap.from(map); + Expect.isTrue(otherMap is Map); + Expect.isTrue(otherMap is HashMap); + Expect.isTrue(otherMap is LinkedHashMap); + var i = 1; + for (var val in map.values) { + Expect.equals(i++, val); + } +} diff --git a/tests/corelib/map_index_test.dart b/tests/corelib/map_index_test.dart new file mode 100644 index 00000000000..05387a4a923 --- /dev/null +++ b/tests/corelib/map_index_test.dart @@ -0,0 +1,27 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +class A { + const A(); +} + +class B extends A { + const B(); +} + +main() { + var map1 = new Map(); + map1[const B()] = const B(); + var map2 = new Map(); + var list = [const B()]; + + var maps = [map1, map2]; + for (var map in maps) { + // Test that the map accepts a key is not of the same type: + // Map[A] + Expect.isNull(map[new A()]); + } +} diff --git a/tests/corelib/map_keys2_test.dart b/tests/corelib/map_keys2_test.dart new file mode 100644 index 00000000000..88ba49155fb --- /dev/null +++ b/tests/corelib/map_keys2_test.dart @@ -0,0 +1,34 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + var map1 = {"foo": 42, "bar": 499}; + var map2 = {}; + var map3 = const {"foo": 42, "bar": 499}; + var map4 = const {}; + var map5 = new Map(); + map5["foo"] = 43; + map5["bar"] = 500; + var map6 = new Map(); + + Expect.isTrue(map1.keys is Iterable); + Expect.isTrue(map1.keys is Iterable); + + Expect.isTrue(map2.keys is Iterable); + Expect.isTrue(map2.keys is Iterable); + + Expect.isTrue(map3.keys is Iterable); + Expect.isTrue(map3.keys is Iterable); + + Expect.isTrue(map4.keys is Iterable); + Expect.isTrue(map4.keys is Iterable); + + Expect.isTrue(map5.keys is Iterable); + Expect.isFalse(map5.keys is Iterable); + + Expect.isTrue(map6.keys is Iterable); + Expect.isFalse(map6.keys is Iterable); +} diff --git a/tests/corelib/map_keys_test.dart b/tests/corelib/map_keys_test.dart new file mode 100644 index 00000000000..d3eaeda66eb --- /dev/null +++ b/tests/corelib/map_keys_test.dart @@ -0,0 +1,47 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + var map1 = {"foo": 42, "bar": 499}; + var map2 = {}; + var map3 = const {"foo": 42, "bar": 499}; + var map4 = const {}; + var map5 = new Map(); + map5["foo"] = 43; + map5["bar"] = 500; + var map6 = new Map(); + + Expect.isTrue(map1.keys is Iterable); + Expect.isFalse(map1.keys is List); + Expect.equals(2, map1.keys.length); + Expect.equals("foo", map1.keys.first); + Expect.equals("bar", map1.keys.last); + + Expect.isTrue(map2.keys is Iterable); + Expect.isFalse(map2.keys is List); + Expect.equals(0, map2.keys.length); + + Expect.isTrue(map3.keys is Iterable); + Expect.isFalse(map3.keys is List); + Expect.equals(2, map3.keys.length); + Expect.equals("foo", map3.keys.first); + Expect.equals("bar", map3.keys.last); + + Expect.isTrue(map4.keys is Iterable); + Expect.isFalse(map4.keys is List); + Expect.equals(0, map4.keys.length); + + Expect.isTrue(map5.keys is Iterable); + Expect.isFalse(map5.keys is List); + Expect.equals(2, map5.keys.length); + Expect.isTrue(map5.keys.first == "foo" || map5.keys.first == "bar"); + Expect.isTrue(map5.keys.last == "foo" || map5.keys.last == "bar"); + Expect.notEquals(map5.keys.first, map5.keys.last); + + Expect.isTrue(map6.keys is Iterable); + Expect.isFalse(map6.keys is List); + Expect.equals(0, map6.keys.length); +} diff --git a/tests/corelib/map_remove_test.dart b/tests/corelib/map_remove_test.dart new file mode 100644 index 00000000000..cb252348aff --- /dev/null +++ b/tests/corelib/map_remove_test.dart @@ -0,0 +1,27 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +class A { + const A(); +} + +class B extends A { + const B(); +} + +main() { + var map1 = new Map(); + map1[const B()] = const B(); + var map2 = new Map(); + var list = [const B()]; + + var maps = [map1, map2]; + for (var map in maps) { + // Test that the map accepts a key is not of the same type: + // Map.remove(A) + Expect.isNull(map.remove(new A())); + } +} diff --git a/tests/corelib/map_test.dart b/tests/corelib/map_test.dart new file mode 100644 index 00000000000..9881be945b0 --- /dev/null +++ b/tests/corelib/map_test.dart @@ -0,0 +1,974 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +library map_test; + +import "package:expect/expect.dart"; +import 'dart:collection'; +import 'dart:convert' show JSON; + +Map newJsonMap() => JSON.decode('{}'); +Map newJsonMapCustomReviver() => + JSON.decode('{}', reviver: (key, value) => value); + +void main() { + test(new HashMap()); + test(new LinkedHashMap()); + test(new SplayTreeMap()); + test(new SplayTreeMap(Comparable.compare)); + test(new MapView(new HashMap())); + test(new MapView(new SplayTreeMap())); + test(new MapBaseMap()); + test(new MapMixinMap()); + testLinkedHashMap(); + testMapLiteral(); + testNullValue(); + testTypes(); + + testWeirdStringKeys(new Map()); + testWeirdStringKeys(new Map()); + testWeirdStringKeys(new HashMap()); + testWeirdStringKeys(new HashMap()); + testWeirdStringKeys(new LinkedHashMap()); + testWeirdStringKeys(new LinkedHashMap()); + testWeirdStringKeys(new SplayTreeMap()); + testWeirdStringKeys(new SplayTreeMap()); + testWeirdStringKeys(new MapBaseMap()); + testWeirdStringKeys(new MapMixinMap()); + testWeirdStringKeys(newJsonMap()); + testWeirdStringKeys(newJsonMapCustomReviver()); + + testNumericKeys(new Map()); + testNumericKeys(new Map()); + testNumericKeys(new HashMap()); + testNumericKeys(new HashMap()); + testNumericKeys(new HashMap.identity()); + testNumericKeys(new HashMap.identity()); + testNumericKeys(new LinkedHashMap()); + testNumericKeys(new LinkedHashMap()); + testNumericKeys(new LinkedHashMap.identity()); + testNumericKeys(new LinkedHashMap.identity()); + testNumericKeys(new MapBaseMap()); + testNumericKeys(new MapMixinMap()); + + testNaNKeys(new Map()); + testNaNKeys(new Map()); + testNaNKeys(new HashMap()); + testNaNKeys(new HashMap()); + testNaNKeys(new LinkedHashMap()); + testNaNKeys(new LinkedHashMap()); + testNaNKeys(new MapBaseMap()); + testNaNKeys(new MapMixinMap()); + // Identity maps fail the NaN-keys tests because the test assumes that + // NaN is not equal to NaN. + + testIdentityMap(new Map.identity()); + testIdentityMap(new HashMap.identity()); + testIdentityMap(new LinkedHashMap.identity()); + testIdentityMap(new HashMap(equals: identical, hashCode: identityHashCode)); + testIdentityMap( + new LinkedHashMap(equals: identical, hashCode: identityHashCode)); + testIdentityMap(new HashMap( + equals: (x, y) => identical(x, y), hashCode: (x) => identityHashCode(x))); + testIdentityMap(new LinkedHashMap( + equals: (x, y) => identical(x, y), hashCode: (x) => identityHashCode(x))); + + testCustomMap(new HashMap( + equals: myEquals, + hashCode: myHashCode, + isValidKey: (v) => v is Customer)); + testCustomMap(new LinkedHashMap( + equals: myEquals, + hashCode: myHashCode, + isValidKey: (v) => v is Customer)); + testCustomMap( + new HashMap(equals: myEquals, hashCode: myHashCode)); + + testCustomMap(new LinkedHashMap( + equals: myEquals, hashCode: myHashCode)); + + testIterationOrder(new LinkedHashMap()); + testIterationOrder(new LinkedHashMap.identity()); + + testOtherKeys(new SplayTreeMap()); + testOtherKeys( + new SplayTreeMap((int a, int b) => a - b, (v) => v is int)); + testOtherKeys(new SplayTreeMap((int a, int b) => a - b, (v) => v is int)); + testOtherKeys(new HashMap()); + testOtherKeys(new HashMap.identity()); + testOtherKeys(new HashMap( + hashCode: (v) => v.hashCode, isValidKey: (v) => v is int)); + testOtherKeys(new HashMap( + equals: (int x, int y) => x == y, + hashCode: (int v) => v.hashCode, + isValidKey: (v) => v is int)); + testOtherKeys(new LinkedHashMap()); + testOtherKeys(new LinkedHashMap.identity()); + testOtherKeys(new LinkedHashMap( + hashCode: (v) => v.hashCode, isValidKey: (v) => v is int)); + testOtherKeys(new LinkedHashMap( + equals: (int x, int y) => x == y, + hashCode: (int v) => v.hashCode, + isValidKey: (v) => v is int)); + testOtherKeys(new MapBaseMap()); + testOtherKeys(new MapMixinMap()); + + testUnmodifiableMap(const {1: 37}); + testUnmodifiableMap(new UnmodifiableMapView({1: 37})); + testUnmodifiableMap(new UnmodifiableMapBaseMap([1, 37])); + + testFrom(); +} + +void test(Map map) { + testDeletedElement(map); + testMap(map, 1, 2, 3, 4, 5, 6, 7, 8); + map.clear(); + testMap(map, "value1", "value2", "value3", "value4", "value5", "value6", + "value7", "value8"); +} + +void testLinkedHashMap() { + LinkedHashMap map = new LinkedHashMap(); + Expect.equals(false, map.containsKey(1)); + map[1] = 1; + map[1] = 2; + testLength(1, map); +} + +void testMap(Map map, key1, key2, key3, key4, key5, key6, key7, key8) { + int value1 = 10; + int value2 = 20; + int value3 = 30; + int value4 = 40; + int value5 = 50; + int value6 = 60; + int value7 = 70; + int value8 = 80; + + testLength(0, map); + + map[key1] = value1; + Expect.equals(value1, map[key1]); + map[key1] = value2; + Expect.equals(false, map.containsKey(key2)); + testLength(1, map); + + map[key1] = value1; + Expect.equals(value1, map[key1]); + // Add enough entries to make sure the table grows. + map[key2] = value2; + Expect.equals(value2, map[key2]); + testLength(2, map); + map[key3] = value3; + Expect.equals(value2, map[key2]); + Expect.equals(value3, map[key3]); + map[key4] = value4; + Expect.equals(value3, map[key3]); + Expect.equals(value4, map[key4]); + map[key5] = value5; + Expect.equals(value4, map[key4]); + Expect.equals(value5, map[key5]); + map[key6] = value6; + Expect.equals(value5, map[key5]); + Expect.equals(value6, map[key6]); + map[key7] = value7; + Expect.equals(value6, map[key6]); + Expect.equals(value7, map[key7]); + map[key8] = value8; + Expect.equals(value1, map[key1]); + Expect.equals(value2, map[key2]); + Expect.equals(value3, map[key3]); + Expect.equals(value4, map[key4]); + Expect.equals(value5, map[key5]); + Expect.equals(value6, map[key6]); + Expect.equals(value7, map[key7]); + Expect.equals(value8, map[key8]); + testLength(8, map); + + map.remove(key4); + Expect.equals(false, map.containsKey(key4)); + testLength(7, map); + + // Test clearing the table. + map.clear(); + testLength(0, map); + Expect.equals(false, map.containsKey(key1)); + Expect.equals(false, map.containsKey(key2)); + Expect.equals(false, map.containsKey(key3)); + Expect.equals(false, map.containsKey(key4)); + Expect.equals(false, map.containsKey(key5)); + Expect.equals(false, map.containsKey(key6)); + Expect.equals(false, map.containsKey(key7)); + Expect.equals(false, map.containsKey(key8)); + + // Test adding and removing again. + map[key1] = value1; + Expect.equals(value1, map[key1]); + testLength(1, map); + map[key2] = value2; + Expect.equals(value2, map[key2]); + testLength(2, map); + map[key3] = value3; + Expect.equals(value3, map[key3]); + map.remove(key3); + testLength(2, map); + map[key4] = value4; + Expect.equals(value4, map[key4]); + map.remove(key4); + testLength(2, map); + map[key5] = value5; + Expect.equals(value5, map[key5]); + map.remove(key5); + testLength(2, map); + map[key6] = value6; + Expect.equals(value6, map[key6]); + map.remove(key6); + testLength(2, map); + map[key7] = value7; + Expect.equals(value7, map[key7]); + map.remove(key7); + testLength(2, map); + map[key8] = value8; + Expect.equals(value8, map[key8]); + map.remove(key8); + testLength(2, map); + + Expect.equals(true, map.containsKey(key1)); + Expect.equals(true, map.containsValue(value1)); + + // Test Map.forEach. + Map otherMap = new Map(); + void testForEachMap(key, value) { + otherMap[key] = value; + } + + map.forEach(testForEachMap); + Expect.equals(true, otherMap.containsKey(key1)); + Expect.equals(true, otherMap.containsKey(key2)); + Expect.equals(true, otherMap.containsValue(value1)); + Expect.equals(true, otherMap.containsValue(value2)); + Expect.equals(2, otherMap.length); + + otherMap.clear(); + Expect.equals(0, otherMap.length); + + // Test Collection.keys. + void testForEachCollection(value) { + otherMap[value] = value; + } + + Iterable keys = map.keys; + keys.forEach(testForEachCollection); + Expect.equals(true, otherMap.containsKey(key1)); + Expect.equals(true, otherMap.containsKey(key2)); + Expect.equals(true, otherMap.containsValue(key1)); + Expect.equals(true, otherMap.containsValue(key2)); + Expect.equals(true, !otherMap.containsKey(value1)); + Expect.equals(true, !otherMap.containsKey(value2)); + Expect.equals(true, !otherMap.containsValue(value1)); + Expect.equals(true, !otherMap.containsValue(value2)); + Expect.equals(2, otherMap.length); + otherMap.clear(); + Expect.equals(0, otherMap.length); + + // Test Collection.values. + Iterable values = map.values; + values.forEach(testForEachCollection); + Expect.equals(true, !otherMap.containsKey(key1)); + Expect.equals(true, !otherMap.containsKey(key2)); + Expect.equals(true, !otherMap.containsValue(key1)); + Expect.equals(true, !otherMap.containsValue(key2)); + Expect.equals(true, otherMap.containsKey(value1)); + Expect.equals(true, otherMap.containsKey(value2)); + Expect.equals(true, otherMap.containsValue(value1)); + Expect.equals(true, otherMap.containsValue(value2)); + Expect.equals(2, otherMap.length); + otherMap.clear(); + Expect.equals(0, otherMap.length); + + // Test Map.putIfAbsent. + map.clear(); + Expect.equals(false, map.containsKey(key1)); + map.putIfAbsent(key1, () => 10); + Expect.equals(true, map.containsKey(key1)); + Expect.equals(10, map[key1]); + Expect.equals(10, map.putIfAbsent(key1, () => 11)); + + // Test Map.addAll. + map.clear(); + otherMap.clear(); + otherMap[99] = 1; + otherMap[50] = 50; + otherMap[1] = 99; + map.addAll(otherMap); + Expect.equals(3, map.length); + Expect.equals(1, map[99]); + Expect.equals(50, map[50]); + Expect.equals(99, map[1]); + otherMap[50] = 42; + map.addAll(new HashMap.from(otherMap)); + Expect.equals(3, map.length); + Expect.equals(1, map[99]); + Expect.equals(42, map[50]); + Expect.equals(99, map[1]); + otherMap[99] = 7; + map.addAll(new SplayTreeMap.from(otherMap)); + Expect.equals(3, map.length); + Expect.equals(7, map[99]); + Expect.equals(42, map[50]); + Expect.equals(99, map[1]); + otherMap.remove(99); + map[99] = 0; + map.addAll(otherMap); + Expect.equals(3, map.length); + Expect.equals(0, map[99]); + Expect.equals(42, map[50]); + Expect.equals(99, map[1]); + map.clear(); + otherMap.clear(); + map.addAll(otherMap); + Expect.equals(0, map.length); +} + +void testDeletedElement(Map map) { + map.clear(); + for (int i = 0; i < 100; i++) { + map[1] = 2; + testLength(1, map); + map.remove(1); + testLength(0, map); + } + testLength(0, map); +} + +void testMapLiteral() { + Map m = {"a": 1, "b": 2, "c": 3}; + Expect.equals(3, m.length); + int sum = 0; + m.forEach((a, b) { + sum += b; + }); + Expect.equals(6, sum); + + List values = m.keys.toList(); + Expect.equals(3, values.length); + String first = values[0]; + String second = values[1]; + String third = values[2]; + String all = "${first}${second}${third}"; + Expect.equals(3, all.length); + Expect.equals(true, all.contains("a", 0)); + Expect.equals(true, all.contains("b", 0)); + Expect.equals(true, all.contains("c", 0)); +} + +void testNullValue() { + Map m = {"a": 1, "b": null, "c": 3}; + + Expect.equals(null, m["b"]); + Expect.equals(true, m.containsKey("b")); + Expect.equals(3, m.length); + + m["a"] = null; + m["c"] = null; + Expect.equals(null, m["a"]); + Expect.equals(true, m.containsKey("a")); + Expect.equals(null, m["c"]); + Expect.equals(true, m.containsKey("c")); + Expect.equals(3, m.length); + + m.remove("a"); + Expect.equals(2, m.length); + Expect.equals(null, m["a"]); + Expect.equals(false, m.containsKey("a")); +} + +void testTypes() { + testMap(Map map) { + Expect.isTrue(map is Map); + Expect.isTrue(map is! Map); + Expect.isTrue(map is! Map); + + // Use with properly typed keys and values. + map[42] = "text1"; + map[43] = "text2"; + map[42] = "text3"; + Expect.equals("text3", map.remove(42)); + Expect.equals(null, map[42]); + map[42] = "text4"; + + // Ensure that "containsKey", "containsValue" and "remove" + // accepts any object. + for (var object in [true, null, new Object()]) { + Expect.isFalse(map.containsKey(object)); + Expect.isFalse(map.containsValue(object)); + Expect.isNull(map.remove(object)); + Expect.isNull(map[object]); + } + } + + testMap(new HashMap()); + testMap(new LinkedHashMap()); + testMap(new SplayTreeMap()); + testMap(new SplayTreeMap(Comparable.compare)); + testMap(new SplayTreeMap((int a, int b) => a.compareTo(b))); + testMap(new HashMap()); + testMap(new LinkedHashMap()); + testMap(new SplayTreeMap()); + testMap(new SplayTreeMap(Comparable.compare)); + testMap(new SplayTreeMap((num a, num b) => a.compareTo(b))); +} + +void testWeirdStringKeys(Map map) { + // Test weird keys. + var weirdKeys = const [ + 'hasOwnProperty', + 'constructor', + 'toLocaleString', + 'propertyIsEnumerable', + '__defineGetter__', + '__defineSetter__', + '__lookupGetter__', + '__lookupSetter__', + 'isPrototypeOf', + 'toString', + 'valueOf', + '__proto__', + '__count__', + '__parent__', + '' + ]; + Expect.isTrue(map.isEmpty); + for (var key in weirdKeys) { + Expect.isFalse(map.containsKey(key)); + Expect.equals(null, map[key]); + var value = 'value:$key'; + map[key] = value; + Expect.isTrue(map.containsKey(key)); + Expect.equals(value, map[key]); + Expect.equals(value, map.remove(key)); + Expect.isFalse(map.containsKey(key)); + Expect.equals(null, map[key]); + } + Expect.isTrue(map.isEmpty); +} + +void testNumericKeys(Map map) { + var numericKeys = const [ + double.INFINITY, + double.NEGATIVE_INFINITY, + 0, + 0.0, + -0.0 + ]; + + Expect.isTrue(map.isEmpty); + for (var key in numericKeys) { + Expect.isFalse(map.containsKey(key)); + Expect.equals(null, map[key]); + var value = 'value:$key'; + map[key] = value; + Expect.isTrue(map.containsKey(key)); + Expect.equals(value, map[key]); + Expect.equals(value, map.remove(key)); + Expect.isFalse(map.containsKey(key)); + Expect.equals(null, map[key]); + } + Expect.isTrue(map.isEmpty); +} + +void testNaNKeys(Map map) { + Expect.isTrue(map.isEmpty); + // Test NaN. + var nan = double.NAN; + Expect.isFalse(map.containsKey(nan)); + Expect.equals(null, map[nan]); + + map[nan] = 'value:0'; + Expect.isFalse(map.containsKey(nan)); + Expect.equals(null, map[nan]); + testLength(1, map); + + map[nan] = 'value:1'; + Expect.isFalse(map.containsKey(nan)); + Expect.equals(null, map[nan]); + testLength(2, map); + + Expect.equals(null, map.remove(nan)); + testLength(2, map); + + var count = 0; + map.forEach((key, value) { + if (key.isNaN) count++; + }); + Expect.equals(2, count); + + map.clear(); + Expect.isTrue(map.isEmpty); +} + +void testLength(int length, Map map) { + Expect.equals(length, map.length); + Expect.equals(length, map.keys.length); + Expect.equals(length, map.values.length); + // Check being-empty. + var ifEmpty = (length == 0) ? Expect.isTrue : Expect.isFalse; + var ifNotEmpty = (length != 0) ? Expect.isTrue : Expect.isFalse; + ifEmpty(map.isEmpty); + ifNotEmpty(map.isNotEmpty); + ifEmpty(map.keys.isEmpty); + ifNotEmpty(map.keys.isNotEmpty); + ifEmpty(map.values.isEmpty); + ifNotEmpty(map.values.isNotEmpty); + // Test key/value iterators match their isEmpty/isNotEmpty. + ifNotEmpty(map.keys.iterator.moveNext()); + ifNotEmpty(map.values.iterator.moveNext()); + if (length == 0) { + for (var k in map.keys) Expect.fail("contains key when iterating: $k"); + for (var v in map.values) Expect.fail("contains values when iterating: $v"); + } +} + +testIdentityMap(Map map) { + Expect.isTrue(map.isEmpty); + + var nan = double.NAN; + // TODO(11551): Remove guard when dart2js makes identical(NaN, NaN) true. + if (identical(nan, nan)) { + map[nan] = 42; + testLength(1, map); + Expect.isTrue(map.containsKey(nan)); + Expect.equals(42, map[nan]); + map[nan] = 37; + testLength(1, map); + Expect.equals(37, map[nan]); + Expect.equals(37, map.remove(nan)); + testLength(0, map); + } + + Vampire v1 = const Vampire(1); + Vampire v2 = const Vampire(2); + Expect.isFalse(v1 == v1); + Expect.isFalse(v2 == v2); + Expect.isTrue(v2 == v1); // Snob! + + map[v1] = 1; + map[v2] = 2; + testLength(2, map); + + Expect.isTrue(map.containsKey(v1)); + Expect.isTrue(map.containsKey(v2)); + + Expect.equals(1, map[v1]); + Expect.equals(2, map[v2]); + + Expect.equals(1, map.remove(v1)); + testLength(1, map); + Expect.isFalse(map.containsKey(v1)); + Expect.isTrue(map.containsKey(v2)); + + Expect.isNull(map.remove(v1)); + Expect.equals(2, map.remove(v2)); + testLength(0, map); + + var eq01 = new Equalizer(0); + var eq02 = new Equalizer(0); + var eq11 = new Equalizer(1); + var eq12 = new Equalizer(1); + // Sanity. + Expect.equals(eq01, eq02); + Expect.equals(eq02, eq01); + Expect.equals(eq11, eq12); + Expect.equals(eq12, eq11); + Expect.notEquals(eq01, eq11); + Expect.notEquals(eq01, eq12); + Expect.notEquals(eq02, eq11); + Expect.notEquals(eq02, eq12); + Expect.notEquals(eq11, eq01); + Expect.notEquals(eq11, eq02); + Expect.notEquals(eq12, eq01); + Expect.notEquals(eq12, eq02); + + map[eq01] = 0; + map[eq02] = 1; + map[eq11] = 2; + map[eq12] = 3; + testLength(4, map); + + Expect.equals(0, map[eq01]); + Expect.equals(1, map[eq02]); + Expect.equals(2, map[eq11]); + Expect.equals(3, map[eq12]); + + Expect.isTrue(map.containsKey(eq01)); + Expect.isTrue(map.containsKey(eq02)); + Expect.isTrue(map.containsKey(eq11)); + Expect.isTrue(map.containsKey(eq12)); + + Expect.equals(1, map.remove(eq02)); + Expect.equals(3, map.remove(eq12)); + testLength(2, map); + Expect.isTrue(map.containsKey(eq01)); + Expect.isFalse(map.containsKey(eq02)); + Expect.isTrue(map.containsKey(eq11)); + Expect.isFalse(map.containsKey(eq12)); + + Expect.equals(0, map[eq01]); + Expect.equals(null, map[eq02]); + Expect.equals(2, map[eq11]); + Expect.equals(null, map[eq12]); + + Expect.equals(0, map.remove(eq01)); + Expect.equals(2, map.remove(eq11)); + testLength(0, map); + + map[eq01] = 0; + map[eq02] = 1; + map[eq11] = 2; + map[eq12] = 3; + testLength(4, map); + + // Transfer to equality-based map will collapse elements. + Map eqMap = new HashMap(); + eqMap.addAll(map); + testLength(2, eqMap); + Expect.isTrue(eqMap.containsKey(eq01)); + Expect.isTrue(eqMap.containsKey(eq02)); + Expect.isTrue(eqMap.containsKey(eq11)); + Expect.isTrue(eqMap.containsKey(eq12)); + + // Changing objects will not affect identity map. + map.clear(); + var m1 = new Mutable(1); + var m2 = new Mutable(2); + var m3 = new Mutable(3); + map[m1] = 1; + map[m2] = 2; + map[m3] = 3; + Expect.equals(3, map.length); + Expect.isTrue(map.containsKey(m1)); + Expect.isTrue(map.containsKey(m2)); + Expect.isTrue(map.containsKey(m3)); + Expect.notEquals(m1, m3); + m3.id = 1; + Expect.equals(m1, m3); + // Even if keys are equal, they are still not identical. + // Even if hashcode of m3 changed, it can still be found. + Expect.equals(1, map[m1]); + Expect.equals(3, map[m3]); +} + +/** Class of objects that are equal if they hold the same id. */ +class Equalizer { + int id; + Equalizer(this.id); + int get hashCode => id; + bool operator ==(Object other) => + other is Equalizer && id == (other as Equalizer).id; +} + +/** + * Objects that are not reflexive. + * + * They think they are better than their equals. + */ +class Vampire { + final int generation; + const Vampire(this.generation); + + int get hashCode => generation; + + // The double-fang operator falsely claims that a vampire is equal to + // any of its sire's generation. + bool operator ==(Object other) => + other is Vampire && generation - 1 == (other as Vampire).generation; +} + +void testCustomMap(Map map) { + testLength(0, map); + var c11 = const Customer(1, 1); + var c12 = const Customer(1, 2); + var c21 = const Customer(2, 1); + var c22 = const Customer(2, 2); + // Sanity. + Expect.equals(c11, c12); + Expect.notEquals(c11, c21); + Expect.notEquals(c11, c22); + Expect.equals(c21, c22); + Expect.notEquals(c21, c11); + Expect.notEquals(c21, c12); + + Expect.isTrue(myEquals(c11, c21)); + Expect.isFalse(myEquals(c11, c12)); + Expect.isFalse(myEquals(c11, c22)); + Expect.isTrue(myEquals(c12, c22)); + Expect.isFalse(myEquals(c12, c11)); + Expect.isFalse(myEquals(c12, c21)); + + map[c11] = 42; + testLength(1, map); + Expect.isTrue(map.containsKey(c11)); + Expect.isTrue(map.containsKey(c21)); + Expect.isFalse(map.containsKey(c12)); + Expect.isFalse(map.containsKey(c22)); + Expect.equals(42, map[c11]); + Expect.equals(42, map[c21]); + + map[c21] = 37; + testLength(1, map); + Expect.isTrue(map.containsKey(c11)); + Expect.isTrue(map.containsKey(c21)); + Expect.isFalse(map.containsKey(c12)); + Expect.isFalse(map.containsKey(c22)); + Expect.equals(37, map[c11]); + Expect.equals(37, map[c21]); + + map[c22] = 42; + testLength(2, map); + Expect.isTrue(map.containsKey(c11)); + Expect.isTrue(map.containsKey(c21)); + Expect.isTrue(map.containsKey(c12)); + Expect.isTrue(map.containsKey(c22)); + Expect.equals(37, map[c11]); + Expect.equals(37, map[c21]); + Expect.equals(42, map[c12]); + Expect.equals(42, map[c22]); + + Expect.equals(42, map.remove(c12)); + testLength(1, map); + Expect.isTrue(map.containsKey(c11)); + Expect.isTrue(map.containsKey(c21)); + Expect.isFalse(map.containsKey(c12)); + Expect.isFalse(map.containsKey(c22)); + Expect.equals(37, map[c11]); + Expect.equals(37, map[c21]); + + Expect.equals(37, map.remove(c11)); + testLength(0, map); +} + +void testUnmodifiableMap(Map map) { + Expect.isTrue(map.containsKey(1)); + testLength(1, map); + Expect.equals(1, map.keys.first); + Expect.equals(37, map.values.first); + + Expect.throws(map.clear); + Expect.throws(() { + map.remove(1); + }); + Expect.throws(() { + map[2] = 42; + }); + Expect.throws(() { + map.addAll({2: 42}); + }); +} + +class Customer { + final int id; + final int secondId; + const Customer(this.id, this.secondId); + int get hashCode => id; + bool operator ==(Object other) { + if (other is! Customer) return false; + Customer otherCustomer = other; + return id == otherCustomer.id; + } +} + +int myHashCode(Customer c) => c.secondId; +bool myEquals(Customer a, Customer b) => a.secondId == b.secondId; + +void testIterationOrder(Map map) { + var order = [0, 6, 4, 2, 7, 9, 7, 1, 2, 5, 3]; + for (int i = 0; i < order.length; i++) map[order[i]] = i; + Expect.listEquals(map.keys.toList(), [0, 6, 4, 2, 7, 9, 1, 5, 3]); + Expect.listEquals(map.values.toList(), [0, 1, 2, 8, 6, 5, 7, 9, 10]); +} + +void testOtherKeys(Map map) { + // Test that non-int keys are allowed in containsKey/remove/lookup. + // Custom hash sets and tree sets must be constructed so they don't + // use the equality/comparator on incompatible objects. + + // This should not throw in either checked or unchecked mode. + map[0] = 0; + map[1] = 1; + map[2] = 2; + Expect.isFalse(map.containsKey("not an int")); + Expect.isFalse(map.containsKey(1.5)); + Expect.isNull(map.remove("not an int")); + Expect.isNull(map.remove(1.5)); + Expect.isNull(map["not an int"]); + Expect.isNull(map[1.5]); +} + +class Mutable { + int id; + Mutable(this.id); + int get hashCode => id; + bool operator ==(other) => other is Mutable && other.id == id; +} + +// Slow implementation of Map based on MapBase. +abstract class MapBaseOperations { + final List _keys = []; + final List _values = []; + int _modCount = 0; + + V operator [](Object key) { + int index = _keys.indexOf(key); + if (index < 0) return null; + return _values[index]; + } + + Iterable get keys => new TestKeyIterable(this); + + void operator []=(K key, V value) { + int index = _keys.indexOf(key); + if (index >= 0) { + _values[index] = value; + } else { + _modCount++; + _keys.add(key); + _values.add(value); + } + } + + V remove(Object key) { + int index = _keys.indexOf(key); + if (index >= 0) { + var result = _values[index]; + key = _keys.removeLast(); + var value = _values.removeLast(); + if (index != _keys.length) { + _keys[index] = key; + _values[index] = value; + } + _modCount++; + return result; + } + return null; + } + + void clear() { + // Clear cannot be based on remove, since remove won't remove keys that + // are not equal to themselves. It will fail the testNaNKeys test. + _keys.clear(); + _values.clear(); + _modCount++; + } +} + +class MapBaseMap = MapBase with MapBaseOperations; +class MapMixinMap = MapBaseOperations with MapMixin; + +class TestKeyIterable extends IterableBase { + final _map; + TestKeyIterable(this._map); + int get length => _map._keys.length; + Iterator get iterator => new TestKeyIterator(_map); +} + +class TestKeyIterator implements Iterator { + final _map; + final int _modCount; + int _index = 0; + var _current; + TestKeyIterator(map) + : _map = map, + _modCount = map._modCount; + bool moveNext() { + if (_modCount != _map._modCount) { + throw new ConcurrentModificationError(_map); + } + if (_index == _map._keys.length) { + _current = null; + return false; + } + _current = _map._keys[_index++]; + return true; + } + + K get current => _current; +} + +// Slow implementation of Map based on MapBase. +class UnmodifiableMapBaseMap extends UnmodifiableMapBase { + final List _keys = []; + final List _values = []; + UnmodifiableMapBaseMap(List pairs) { + for (int i = 0; i < pairs.length; i += 2) { + _keys.add(pairs[i]); + _values.add(pairs[i + 1]); + } + } + + int get _modCount => 0; + + V operator [](K key) { + int index = _keys.indexOf(key); + if (index < 0) return null; + return _values[index]; + } + + Iterable get keys => _keys.skip(0); +} + +abstract class Super implements Comparable {} + +abstract class Interface implements Comparable {} + +class Sub extends Super implements Interface, Comparable { + int compareTo(Sub other) => 0; + int get hashCode => 0; + bool operator ==(other) => other is Sub; +} + +expectMap(Map expect, Map actual) { + Expect.equals(expect.length, actual.length, "length"); + for (var key in expect.keys) { + Expect.isTrue(actual.containsKey(key), "containsKey $key"); + Expect.equals(expect[key], actual[key]); + } +} + +void testFrom() { + // Check contents. + for (var map in [ + {}, + {1: 1}, + {1: 2, 3: 4, 5: 6, 7: 8} + ]) { + expectMap(map, new Map.from(map)); + expectMap(map, new HashMap.from(map)); + expectMap(map, new LinkedHashMap.from(map)); + expectMap(map, new SplayTreeMap.from(map)); + } + // Test type combinations allowed. + Map intMap = {1: 2, 3: 4}; + Map numMap = {1: 2, 3: 4}; + expectMap(intMap, new Map.from(numMap)); + expectMap(intMap, new Map.from(intMap)); + expectMap(intMap, new HashMap.from(numMap)); + expectMap(intMap, new HashMap.from(intMap)); + expectMap(intMap, new LinkedHashMap.from(numMap)); + expectMap(intMap, new LinkedHashMap.from(intMap)); + expectMap(intMap, new SplayTreeMap.from(numMap)); + expectMap(intMap, new SplayTreeMap.from(intMap)); + + var sub = new Sub(); + Map superMap = {sub: sub}; + Map interfaceMap = {sub: sub}; + expectMap(superMap, new Map.from(interfaceMap)); + expectMap(superMap, new Map.from(superMap)); + expectMap(superMap, new HashMap.from(interfaceMap)); + expectMap(superMap, new HashMap.from(superMap)); + expectMap(superMap, new LinkedHashMap.from(interfaceMap)); + expectMap(superMap, new LinkedHashMap.from(superMap)); + expectMap(superMap, new SplayTreeMap.from(interfaceMap)); + expectMap(superMap, new SplayTreeMap.from(superMap)); +} diff --git a/tests/corelib/map_to_string_test.dart b/tests/corelib/map_to_string_test.dart new file mode 100644 index 00000000000..8a50bf61358 --- /dev/null +++ b/tests/corelib/map_to_string_test.dart @@ -0,0 +1,32 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +void main() { + Map m = new Map(); + + m[0] = 0; + m[1] = 1; + m[2] = m; + + Expect.equals('{0: 0, 1: 1, 2: {...}}', m.toString()); + + // Throwing in the middle of a toString does not leave the + // map as being visited + ThrowOnToString err = new ThrowOnToString(); + m[1] = err; + Expect.throws(m.toString, (e) => e == "Bad!"); + m[1] = 1; + Expect.equals('{0: 0, 1: 1, 2: {...}}', m.toString()); + m[err] = 1; + Expect.throws(m.toString, (e) => e == "Bad!"); + m.remove(err); +} + +class ThrowOnToString { + String toString() { + throw "Bad!"; + } +} diff --git a/tests/corelib/map_values2_test.dart b/tests/corelib/map_values2_test.dart new file mode 100644 index 00000000000..5fc754e62ca --- /dev/null +++ b/tests/corelib/map_values2_test.dart @@ -0,0 +1,53 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + var map1 = {"foo": 42, "bar": 499}; + var map2 = {}; + var map3 = const {"foo": 42, "bar": 499}; + var map4 = const {}; + var map5 = new Map(); + map5["foo"] = 43; + map5["bar"] = 500; + var map6 = new Map(); + + Expect.isTrue(map1.values is Iterable); + Expect.isFalse(map1.values is Iterable); + Expect.isFalse(map1.values is List); + Expect.equals(2, map1.values.length); + Expect.equals(42, map1.values.first); + Expect.equals(499, map1.values.last); + + Expect.isTrue(map2.values is Iterable); + Expect.isFalse(map2.values is Iterable); + Expect.isFalse(map2.values is List); + Expect.equals(0, map2.values.length); + + Expect.isTrue(map3.values is Iterable); + Expect.isFalse(map3.values is Iterable); + Expect.isFalse(map3.values is List); + Expect.equals(2, map3.values.length); + Expect.equals(42, map3.values.first); + Expect.equals(499, map3.values.last); + + Expect.isTrue(map4.values is Iterable); + Expect.isFalse(map4.values is Iterable); + Expect.isFalse(map4.values is List); + Expect.equals(0, map4.values.length); + + Expect.isTrue(map5.values is Iterable); + Expect.isFalse(map5.values is Iterable); + Expect.isFalse(map5.values is List); + Expect.equals(2, map5.values.length); + // new Map gives a LinkedHashMap, so we know the order. + Expect.isTrue(map5.values.first == 43); + Expect.isTrue(map5.values.last == 500); + + Expect.isTrue(map6.values is Iterable); + Expect.isFalse(map6.values is Iterable); + Expect.isFalse(map6.values is List); + Expect.equals(0, map6.values.length); +} diff --git a/tests/corelib/map_values3_test.dart b/tests/corelib/map_values3_test.dart new file mode 100644 index 00000000000..44c356ce67e --- /dev/null +++ b/tests/corelib/map_values3_test.dart @@ -0,0 +1,53 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + var map1 = {1: "42", 2: "499"}; + var map2 = {}; + var map3 = const {3: "42", 4: "499"}; + var map4 = const {}; + var map5 = new Map(); + map5[5] = "43"; + map5[6] = "500"; + var map6 = new Map(); + + Expect.isTrue(map1.values is Iterable); + Expect.isFalse(map1.values is Iterable); + Expect.isFalse(map1.values is List); + Expect.equals(2, map1.values.length); + Expect.equals("42", map1.values.first); + Expect.equals("499", map1.values.last); + + Expect.isTrue(map2.values is Iterable); + Expect.isFalse(map2.values is Iterable); + Expect.isFalse(map2.values is List); + Expect.equals(0, map2.values.length); + + Expect.isTrue(map3.values is Iterable); + Expect.isFalse(map3.values is Iterable); + Expect.isFalse(map3.values is List); + Expect.equals(2, map3.values.length); + Expect.equals("42", map3.values.first); + Expect.equals("499", map3.values.last); + + Expect.isTrue(map4.values is Iterable); + Expect.isFalse(map4.values is Iterable); + Expect.isFalse(map4.values is List); + Expect.equals(0, map4.values.length); + + Expect.isTrue(map5.values is Iterable); + Expect.isFalse(map5.values is Iterable); + Expect.isFalse(map5.values is List); + Expect.equals(2, map5.values.length); + // new Map gives a LinkedHashMap, so we know the order. + Expect.isTrue(map5.values.first == "43"); + Expect.isTrue(map5.values.last == "500"); + + Expect.isTrue(map6.values is Iterable); + Expect.isFalse(map6.values is Iterable); + Expect.isFalse(map6.values is List); + Expect.equals(0, map6.values.length); +} diff --git a/tests/corelib/map_values4_test.dart b/tests/corelib/map_values4_test.dart new file mode 100644 index 00000000000..4f99056128d --- /dev/null +++ b/tests/corelib/map_values4_test.dart @@ -0,0 +1,15 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +// Dart2js had a bug where the type information was not set correctly if the +// generic type of the map was not directly used (but only indirectly through +// map.values). + +main() { + var map1 = {1: "42", 2: "499"}; + Expect.isTrue(map1.values is Iterable); + Expect.isFalse(map1.values is Iterable); +} diff --git a/tests/corelib/map_values_test.dart b/tests/corelib/map_values_test.dart new file mode 100644 index 00000000000..e5c367080e0 --- /dev/null +++ b/tests/corelib/map_values_test.dart @@ -0,0 +1,47 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + var map1 = {"foo": 42, "bar": 499}; + var map2 = {}; + var map3 = const {"foo": 42, "bar": 499}; + var map4 = const {}; + var map5 = new Map(); + map5["foo"] = 43; + map5["bar"] = 500; + var map6 = new Map(); + + Expect.isTrue(map1.values is Iterable); + Expect.isFalse(map1.values is List); + Expect.equals(2, map1.values.length); + Expect.equals(42, map1.values.first); + Expect.equals(499, map1.values.last); + + Expect.isTrue(map2.values is Iterable); + Expect.isFalse(map2.values is List); + Expect.equals(0, map2.values.length); + + Expect.isTrue(map3.values is Iterable); + Expect.isFalse(map3.values is List); + Expect.equals(2, map3.values.length); + Expect.equals(42, map3.values.first); + Expect.equals(499, map3.values.last); + + Expect.isTrue(map4.values is Iterable); + Expect.isFalse(map4.values is List); + Expect.equals(0, map4.values.length); + + Expect.isTrue(map5.values is Iterable); + Expect.isFalse(map5.values is List); + Expect.equals(2, map5.values.length); + Expect.isTrue(map5.values.first == 43 || map5.values.first == 500); + Expect.isTrue(map5.values.last == 43 || map5.values.last == 500); + Expect.notEquals(map5.values.first, map5.values.last); + + Expect.isTrue(map6.values is Iterable); + Expect.isFalse(map6.values is List); + Expect.equals(0, map6.values.length); +} diff --git a/tests/corelib/maps_test.dart b/tests/corelib/maps_test.dart new file mode 100644 index 00000000000..9183c236bdc --- /dev/null +++ b/tests/corelib/maps_test.dart @@ -0,0 +1,138 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +library maps_test; + +import "package:expect/expect.dart"; +import 'dart:collection'; + +main() { + final key1 = "key1"; + final key2 = "key2"; + final key3 = "key3"; + final key4 = "key4"; + final key5 = "key5"; + final key6 = "key6"; + final key7 = "key7"; + final key8 = "key8"; + + final value1 = 10; + final value2 = 20; + final value3 = 30; + final value4 = 40; + final value5 = 50; + final value6 = 60; + final value7 = 70; + final value8 = 80; + + Map map = new Map(); + + map[key1] = value1; + map[key1] = value2; + Expect.equals(false, Maps.containsKey(map, key2)); + Expect.equals(1, Maps.length(map)); + + map[key1] = value1; + // Add enough entries to make sure the table grows. + map[key2] = value2; + Expect.equals(2, Maps.length(map)); + map[key3] = value3; + map[key4] = value4; + map[key5] = value5; + map[key6] = value6; + map[key7] = value7; + map[key8] = value8; + Expect.equals(8, Maps.length(map)); + + map.remove(key4); + Expect.equals(false, Maps.containsKey(map, key4)); + Expect.equals(7, Maps.length(map)); + + // Test clearing the table. + Maps.clear(map); + Expect.equals(0, Maps.length(map)); + Expect.equals(false, Maps.containsKey(map, key1)); + Expect.equals(false, map.containsKey(key1)); + Expect.equals(false, Maps.containsKey(map, key2)); + Expect.equals(false, map.containsKey(key2)); + Expect.equals(false, Maps.containsKey(map, key3)); + Expect.equals(false, map.containsKey(key3)); + Expect.equals(false, Maps.containsKey(map, key4)); + Expect.equals(false, map.containsKey(key4)); + Expect.equals(false, Maps.containsKey(map, key5)); + Expect.equals(false, map.containsKey(key5)); + Expect.equals(false, Maps.containsKey(map, key6)); + Expect.equals(false, map.containsKey(key6)); + Expect.equals(false, Maps.containsKey(map, key7)); + Expect.equals(false, map.containsKey(key7)); + Expect.equals(false, Maps.containsKey(map, key8)); + Expect.equals(false, map.containsKey(key8)); + + // Test adding and removing again. + map[key1] = value1; + Expect.equals(1, Maps.length(map)); + map[key2] = value2; + Expect.equals(2, Maps.length(map)); + map[key3] = value3; + map.remove(key3); + Expect.equals(2, Maps.length(map)); + map[key4] = value4; + map.remove(key4); + Expect.equals(2, Maps.length(map)); + map[key5] = value5; + map.remove(key5); + Expect.equals(2, Maps.length(map)); + map[key6] = value6; + map.remove(key6); + Expect.equals(2, Maps.length(map)); + map[key7] = value7; + map.remove(key7); + Expect.equals(2, Maps.length(map)); + map[key8] = value8; + map.remove(key8); + Expect.equals(2, Maps.length(map)); + + Expect.equals(true, Maps.containsKey(map, key1)); + Expect.equals(true, Maps.containsValue(map, value1)); + + // Test Map.forEach. + Map other_map = new Map(); + void testForEachMap(key, value) { + other_map[key] = value; + } + + Maps.forEach(map, testForEachMap); + Expect.equals(true, other_map.containsKey(key1)); + Expect.equals(true, other_map.containsKey(key2)); + Expect.equals(true, other_map.containsValue(value1)); + Expect.equals(true, other_map.containsValue(value2)); + Expect.equals(2, Maps.length(other_map)); + + // Test Collection.values. + void testForEachCollection(value) { + other_map[value] = value; + } + + Iterable values = Maps.getValues(map); + other_map = new Map(); + values.forEach(testForEachCollection); + Expect.equals(true, !other_map.containsKey(key1)); + Expect.equals(true, !other_map.containsKey(key2)); + Expect.equals(true, !other_map.containsValue(key1)); + Expect.equals(true, !other_map.containsValue(key2)); + Expect.equals(true, other_map.containsKey(value1)); + Expect.equals(true, other_map.containsKey(value2)); + Expect.equals(true, other_map.containsValue(value1)); + Expect.equals(true, other_map.containsValue(value2)); + Expect.equals(2, other_map.length); + other_map.clear(); + + // Test Map.putIfAbsent. + map.clear(); + Expect.equals(false, Maps.containsKey(map, key1)); + Maps.putIfAbsent(map, key1, () => 10); + Expect.equals(true, map.containsKey(key1)); + Expect.equals(10, map[key1]); + Expect.equals(10, Maps.putIfAbsent(map, key1, () => 11)); +} diff --git a/tests/corelib/nan_infinity_test.dart b/tests/corelib/nan_infinity_test.dart new file mode 100644 index 00000000000..bb8b1a7bb25 --- /dev/null +++ b/tests/corelib/nan_infinity_test.dart @@ -0,0 +1,90 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +// Dart test program for testing NaN and Infinity. + +void main() { + // Sanity tests. + Expect.isFalse(1.5.isNaN); + Expect.isFalse(1.5.isInfinite); + Expect.isTrue(1.5.isFinite); + Expect.isFalse(1.5.isNegative); + Expect.isTrue((-1.5).isNegative); + Expect.isFalse(0.0.isNegative); + Expect.isTrue((-0.0).isNegative); + Expect.isTrue((-0.0).isFinite); + + Expect.isFalse(1.isNaN); + Expect.isFalse(1.isInfinite); + Expect.isTrue(1.isFinite); + Expect.isFalse(1.isNegative); + Expect.isTrue((-1).isNegative); + + // Test that predicates give the correct result. + Expect.isTrue(double.NAN.isNaN); + Expect.isFalse(double.NAN.isInfinite); + Expect.isFalse(double.NAN.isFinite); + Expect.isFalse(double.NAN.isNegative); + Expect.isFalse((-double.NAN).isNegative); + + Expect.isFalse(double.INFINITY.isNaN); + Expect.isTrue(double.INFINITY.isInfinite); + Expect.isFalse(double.INFINITY.isFinite); + Expect.isFalse(double.INFINITY.isNegative); + Expect.isTrue((-double.INFINITY).isNegative); + + Expect.isFalse(double.NEGATIVE_INFINITY.isNaN); + Expect.isTrue(double.NEGATIVE_INFINITY.isInfinite); + Expect.isFalse(double.NEGATIVE_INFINITY.isFinite); + Expect.isTrue(double.NEGATIVE_INFINITY.isNegative); + Expect.isFalse((-double.NEGATIVE_INFINITY).isNegative); + + // Test toString. + Expect.equals("NaN", double.NAN.toString()); + Expect.equals("Infinity", double.INFINITY.toString()); + Expect.equals("-Infinity", double.NEGATIVE_INFINITY.toString()); + + // Test identities. + Expect.isTrue(identical(double.NAN, double.NAN)); // //# 01: ok + Expect.isTrue(identical(double.INFINITY, double.INFINITY)); + Expect.isTrue(identical(double.NEGATIVE_INFINITY, double.NEGATIVE_INFINITY)); + Expect.isFalse(identical(double.NAN, double.INFINITY)); + Expect.isFalse(identical(double.NAN, double.NEGATIVE_INFINITY)); + Expect.isFalse(identical(double.INFINITY, double.NEGATIVE_INFINITY)); + Expect.isFalse(identical(double.NAN, -double.NAN)); + Expect.isTrue(identical(double.INFINITY, -double.NEGATIVE_INFINITY)); + Expect.isTrue(identical(double.NEGATIVE_INFINITY, -double.INFINITY)); + + // Test equalities + Expect.isTrue(double.INFINITY == double.INFINITY); + Expect.isTrue(double.NEGATIVE_INFINITY == double.NEGATIVE_INFINITY); + Expect.isFalse(double.INFINITY == double.NEGATIVE_INFINITY); + Expect.isFalse(double.NEGATIVE_INFINITY == double.INFINITY); + Expect.isFalse(double.NAN == double.NAN); + Expect.isFalse(double.NAN == double.INFINITY); + Expect.isFalse(double.NAN == double.NEGATIVE_INFINITY); + Expect.isFalse(double.INFINITY == double.NAN); + Expect.isFalse(double.NEGATIVE_INFINITY == double.NAN); + + // Test relational order. + Expect.isFalse(double.NAN < double.NAN); + Expect.isFalse(double.NAN < double.INFINITY); + Expect.isFalse(double.NAN < double.NEGATIVE_INFINITY); + Expect.isFalse(double.NAN > double.NAN); + Expect.isFalse(double.NAN > double.INFINITY); + Expect.isFalse(double.NAN > double.NEGATIVE_INFINITY); + Expect.isFalse(double.INFINITY < double.NAN); + Expect.isFalse(double.NEGATIVE_INFINITY < double.NAN); + Expect.isFalse(double.INFINITY > double.NAN); + Expect.isFalse(double.NEGATIVE_INFINITY > double.NAN); + Expect.isTrue(double.INFINITY > double.NEGATIVE_INFINITY); + Expect.isFalse(double.INFINITY < double.NEGATIVE_INFINITY); + + // NaN is contagious. + Expect.isTrue((3.0 * double.NAN).isNaN); + Expect.isTrue((3.0 + double.NAN).isNaN); + Expect.isTrue((-double.NAN).isNaN); +} diff --git a/tests/corelib/null_nosuchmethod_test.dart b/tests/corelib/null_nosuchmethod_test.dart new file mode 100644 index 00000000000..ec3c2f2b142 --- /dev/null +++ b/tests/corelib/null_nosuchmethod_test.dart @@ -0,0 +1,21 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +// Test that Null's noSuchMethod can be closurized and called directly. + +main() { + var x; + // Non-existing method calls noSuchMethod. + Expect.throws(() => x.foo(), (e) => e is NoSuchMethodError); + + // Calling noSuchMethod directly. + Expect.throws(() => x.noSuchMethod("foo", []), (e) => e is NoSuchMethodError); + + // Closurizing noSuchMethod and calling it. + var nsm = x.noSuchMethod; + Expect.notEquals(null, nsm); + Expect.throws(() => nsm("foo", []), (e) => e is NoSuchMethodError); +} diff --git a/tests/corelib/null_test.dart b/tests/corelib/null_test.dart new file mode 100644 index 00000000000..994ca40d39e --- /dev/null +++ b/tests/corelib/null_test.dart @@ -0,0 +1,32 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +// Test that Null inherits properties from Object. + +main() { + var x; + + Expect.isTrue(x is Object); + Expect.isTrue(x is dynamic); + Expect.isTrue(x is! String); + Expect.isTrue(x is! int); + + // These shouldn't throw. + x.runtimeType; + x.toString(); + x.hashCode; + + // operator== is inherited from Object. It's the same as identical. + // It's not really testable. + Expect.isTrue(identical(x, null)); + Expect.isTrue(x == null); + + // Methods can be closurized and yields the same result. + var ts = x.toString; + Expect.equals(null.toString(), ts()); + + // noSuchMethod is tested in null_nosuchmethod_test.dart. +} diff --git a/tests/corelib/num_clamp_test.dart b/tests/corelib/num_clamp_test.dart new file mode 100644 index 00000000000..b8731ab3c17 --- /dev/null +++ b/tests/corelib/num_clamp_test.dart @@ -0,0 +1,80 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. +// Test num.clamp. + +import "package:expect/expect.dart"; + +testIntClamp() { + Expect.equals(2, 2.clamp(1, 3)); + Expect.equals(1, 0.clamp(1, 3)); + Expect.equals(3, 4.clamp(1, 3)); + Expect.equals(-2, (-2).clamp(-3, -1)); + Expect.equals(-1, 0.clamp(-3, -1)); + Expect.equals(-3, (-4).clamp(-3, -1)); + Expect.equals(0, 1.clamp(0, 0)); + Expect.equals(0, (-1).clamp(0, 0)); + Expect.equals(0, 0.clamp(0, 0)); + Expect.throws(() => 0.clamp(0, -1), (e) => e is ArgumentError); + Expect.throws( + () => 0.clamp("str", -1), (e) => e is ArgumentError || e is TypeError); + Expect.throws( + () => 0.clamp(0, "2"), (e) => e is ArgumentError || e is TypeError); +} + +testDoubleClamp() { + Expect.equals(2.0, 2.clamp(1.0, 3.0)); + Expect.equals(1.0, 0.clamp(1.0, 3.0)); + Expect.equals(3.0, 4.clamp(1.0, 3.0)); + Expect.equals(-2.0, (-2.0).clamp(-3.0, -1.0)); + Expect.equals(-1.0, 0.0.clamp(-3.0, -1.0)); + Expect.equals(-3.0, (-4.0).clamp(-3.0, -1.0)); + Expect.equals(0.0, 1.0.clamp(0.0, 0.0)); + Expect.equals(0.0, (-1.0).clamp(0.0, 0.0)); + Expect.equals(0.0, 0.0.clamp(0.0, 0.0)); + Expect.throws(() => 0.0.clamp(0.0, -1.0), (e) => e is ArgumentError); + Expect.throws(() => 0.0.clamp("str", -1.0), + (e) => e is ArgumentError || e is TypeError); + Expect.throws( + () => 0.0.clamp(0.0, "2"), (e) => e is ArgumentError || e is TypeError); +} + +testDoubleClampInt() { + Expect.equals(2.0, 2.0.clamp(1, 3)); + Expect.equals(1, 0.0.clamp(1, 3)); + Expect.isTrue(0.0.clamp(1, 3) is int); + Expect.equals(3, 4.0.clamp(1, 3)); + Expect.isTrue(4.0.clamp(1, 3) is int); + Expect.equals(-2.0, (-2.0).clamp(-3, -1)); + Expect.equals(-1, 0.0.clamp(-3, -1)); + Expect.isTrue(0.0.clamp(-3, -1) is int); + Expect.equals(-3, (-4.0).clamp(-3, -1)); + Expect.isTrue((-4.0).clamp(-3, -1) is int); + Expect.equals(0, 1.0.clamp(0, 0)); + Expect.isTrue(1.0.clamp(0, 0) is int); + Expect.equals(0, (-1.0).clamp(0, 0)); + Expect.isTrue((-1.0).clamp(0, 0) is int); + Expect.equals(0.0, 0.0.clamp(0, 0)); + Expect.isTrue(0.0.clamp(0, 0) is double); + Expect.throws(() => 0.0.clamp(0, -1), (e) => e is ArgumentError); + Expect.throws( + () => 0.0.clamp("str", -1), (e) => e is ArgumentError || e is TypeError); + Expect.throws( + () => 0.0.clamp(0, "2"), (e) => e is ArgumentError || e is TypeError); +} + +testDoubleClampExtremes() { + Expect.equals(2.0, 2.0.clamp(-double.INFINITY, double.INFINITY)); + Expect.equals(2.0, 2.0.clamp(-double.INFINITY, double.NAN)); + Expect.equals(double.INFINITY, 2.0.clamp(double.INFINITY, double.NAN)); + Expect.isTrue(2.0.clamp(double.NAN, double.NAN).isNaN); + Expect.throws( + () => 0.0.clamp(double.NAN, double.INFINITY), (e) => e is ArgumentError); +} + +main() { + testIntClamp(); + testDoubleClamp(); + testDoubleClampInt(); + testDoubleClampExtremes(); +} diff --git a/tests/corelib/num_parse_test.dart b/tests/corelib/num_parse_test.dart new file mode 100644 index 00000000000..33f1d8ac0c3 --- /dev/null +++ b/tests/corelib/num_parse_test.dart @@ -0,0 +1,234 @@ +// Copyright (c) 2013 the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +const whiteSpace = const [ + "", + "\x09", + "\x0a", + "\x0b", + "\x0c", + "\x0d", + "\x85", + "\xa0", + "\u1680", + "\u2000", + "\u2001", + "\u2002", + "\u2003", + "\u2004", + "\u2005", + "\u2006", + "\u2007", + "\u2008", + "\u2009", + "\u200a", + "\u2028", + "\u2029", + "\u202f", + "\u205f", + "\u3000", + "\uFEFF" +]; + +void expectNumEquals(num expect, num actual, String message) { + if (expect is double && expect.isNaN) { + Expect.isTrue(actual is double && actual.isNaN, "isNaN: $message"); + } else { + Expect.identical(expect, actual, message); + } +} + +// Test source surrounded by any combination of whitespace. +void testParseAllWhitespace(String source, num result) { + for (String ws1 in whiteSpace) { + for (String ws2 in whiteSpace) { + String padded = "$ws1$source$ws2"; + // Use Expect.identical because it also handles NaN and 0.0/-0.0. + // Except on dart2js: http://dartbug.com/11551 + expectNumEquals(result, num.parse(padded), "parse '$padded'"); + padded = "$ws1$ws2$source"; + expectNumEquals(result, num.parse(padded), "parse '$padded'"); + padded = "$source$ws1$ws2"; + expectNumEquals(result, num.parse(padded), "parse '$padded'"); + } + } +} + +// Test source and -source surrounded by any combination of whitespace. +void testParseWhitespace(String source, num result) { + assert(result >= 0); + testParseAllWhitespace(source, result); + testParseAllWhitespace("-$source", -result); +} + +// Test parsing source, optionally preceeded and/or followed by whitespace. +void testParse(String source, num result) { + expectNumEquals(result, num.parse(source), "parse '$source'"); + expectNumEquals(result, num.parse(" $source"), "parse ' $source'"); + expectNumEquals(result, num.parse("$source "), "parse '$source '"); + expectNumEquals(result, num.parse(" $source "), "parse ' $source '"); +} + +// Test parsing an integer in decimal or hex format, with or without signs. +void testInt(int value) { + testParse("$value", value); + testParse("+$value", value); + testParse("-$value", -value); + var hex = "0x${value.toRadixString(16)}"; + var lchex = hex.toLowerCase(); + testParse(lchex, value); + testParse("+$lchex", value); + testParse("-$lchex", -value); + var uchex = hex.toUpperCase(); + testParse(uchex, value); + testParse("+$uchex", value); + testParse("-$uchex", -value); +} + +// Test parsing an integer, and the integers just around it. +void testIntAround(int value) { + testInt(value - 1); + testInt(value); + testInt(value + 1); +} + +void testDouble(double value) { + testParse("$value", value); + testParse("+$value", value); + testParse("-$value", -value); + if (value.isFinite) { + String exp = value.toStringAsExponential(); + String lcexp = exp.toLowerCase(); + testParse(lcexp, value); + testParse("+$lcexp", value); + testParse("-$lcexp", -value); + String ucexp = exp.toUpperCase(); + testParse(ucexp, value); + testParse("+$ucexp", value); + testParse("-$ucexp", -value); + } +} + +void testFail(String source) { + var object = new Object(); + Expect.throws(() { + num.parse(source, (s) { + Expect.equals(source, s); + throw object; + }); + }, (e) => identical(object, e), "Fail: '$source'"); +} + +void main() { + testInt(0); + testInt(1); + testInt(9); + testInt(10); + testInt(99); + testInt(100); + testIntAround(256); + testIntAround(0x80000000); // 2^31 + testIntAround(0x100000000); // 2^32 + testIntAround(0x10000000000000); // 2^52 + testIntAround(0x20000000000000); // 2^53 + testIntAround(0x40000000000000); // 2^54 + testIntAround(0x8000000000000000); // 2^63 + testIntAround(0x10000000000000000); // 2^64 + testIntAround(0x100000000000000000000); // 2^80 + + testDouble(0.0); + testDouble(5e-324); + testDouble(2.225073858507201e-308); + testDouble(2.2250738585072014e-308); + testDouble(0.49999999999999994); + testDouble(0.5); + testDouble(0.50000000000000006); + testDouble(0.9999999999999999); + testDouble(1.0); + testDouble(1.0000000000000002); + testDouble(4294967295.0); + testDouble(4294967296.0); + testDouble(4503599627370495.5); + testDouble(4503599627370497.0); + testDouble(9007199254740991.0); + testDouble(9007199254740992.0); + testDouble(1.7976931348623157e+308); + testDouble(double.INFINITY); + testDouble(double.NAN); // //# 01: ok + + // Strings that cannot occur from toString of a number. + testParse("000000000000", 0); + testParse("000000000001", 1); + testParse("000000000000.0000000000000", 0.0); + testParse("000000000001.0000000000000", 1.0); + testParse("0x0000000000", 0); + testParse("0e0", 0.0); + testParse("0e+0", 0.0); + testParse("0e-0", 0.0); + testParse("-0e0", -0.0); + testParse("-0e+0", -0.0); + testParse("-0e-0", -0.0); + testParse("1e0", 1.0); + testParse("1e+0", 1.0); + testParse("1e-0", 1.0); + testParse("-1e0", -1.0); + testParse("-1e+0", -1.0); + testParse("-1e-0", -1.0); + testParse("1.", 1.0); + testParse(".1", 0.1); + testParse("1.e1", 10.0); + testParse(".1e1", 1.0); + + testParseWhitespace("0x1", 1); + testParseWhitespace("1", 1); + testParseWhitespace("1.0", 1.0); + testParseWhitespace("1e1", 10.0); + testParseWhitespace(".1e1", 1.0); + testParseWhitespace("1.e1", 10.0); + testParseWhitespace("1e+1", 10.0); + testParseWhitespace("1e-1", 0.1); + + // Negative tests - things not to allow. + + // Spaces inside the numeral. + testFail("- 1"); + testFail("+ 1"); + testFail("2 2"); + testFail("0x 42"); + testFail("1 ."); + testFail(". 1"); + testFail("1e 2"); + testFail("1 e2"); + // Invalid characters. + testFail("0x1H"); + testFail("12H"); + testFail("1x2"); + testFail("00x2"); + testFail("0x2.2"); + // Empty hex number. + testFail("0x"); + testFail("-0x"); + testFail("+0x"); + // Double exponent without value. + testFail(".e1"); + testFail("e1"); + testFail("e+1"); + testFail("e-1"); + testFail("-e1"); + testFail("-e+1"); + testFail("-e-1"); + // Incorrect ways to write NaN/Infinity. + testFail("infinity"); + testFail("INFINITY"); + testFail("1.#INF"); + testFail("inf"); + testFail("nan"); + testFail("NAN"); + testFail("1.#IND"); + testFail("indef"); + testFail("qnan"); + testFail("snan"); +} diff --git a/tests/corelib/num_sign_test.dart b/tests/corelib/num_sign_test.dart new file mode 100644 index 00000000000..5f409b41148 --- /dev/null +++ b/tests/corelib/num_sign_test.dart @@ -0,0 +1,109 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. +// Test num.clamp. +// VMOptions=--no-use-field-guards +// VMOptions= + +import "package:expect/expect.dart"; + +// Pedestrian implementation of sign, following its specification directly. +num sign(num value) { + if (value is int) { + if (value < 0) return -1; + if (value > 0) return 1; + return 0; + } + if (value.isNaN) return value; + if (value == 0.0) return value; + if (value > 0.0) return 1.0; + return -1.0; +} + +var numbers = [ + // Integers + 0, + 1, + 2, + 0x7f, // ~7 bits + 0x80, + 0xff, // ~8 bits + 0x100, + 0xffff, // ~16 bits + 0x10000, + 0x3fffffff, // ~30 bits (max positive 32-bit tagged smi) + 0x40000000, + 0x40000001, + 0x7fffffff, // ~31 bits + 0x80000000, + 0x80000001, + 0xfffffffff, // ~32 bits + 0x100000000, + 0x100000001, + 0x10000000000000, // ~53 bits + 0x10000000000001, + 0x1fffffffffffff, + 0x20000000000000, + 0x20000000000001, // first integer not representable as double. + 0x20000000000002, + 0x7fffffffffffffff, // ~63 bits + 0x8000000000000000, + 0x8000000000000001, + 0xffffffffffffffff, // ~64 bits + 0x10000000000000000, + 0x10000000000000001, + // Integers around the max-double range (2^1024, ~1025 bits). + 0xfffffffffffff800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, + 0xfffffffffffffc00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, + 0x10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000, + // Doubles. + 0.0, + 5e-324, // min positive + 2.225073858507201e-308, // max denormal + 2.2250738585072014e-308, // min normal + 0.49999999999999994, // ~0.5 + 0.5, + 0.5000000000000001, + 0.9999999999999999, // ~1.0 + 1.0, + 1.0000000000000002, + 4294967295.0, // ~32 bits + 4294967296.0, + 4503599627370495.5, // max fractional + 4503599627370497.0, + 9007199254740991.0, + 9007199254740992.0, // max exact (+1 is not a double) + 1.7976931348623157e+308, // max finite double + 1.0 / 0.0, // Infinity + 0.0 / 0.0, // NaN +]; + +main() { + for (num number in numbers) { + test(number); + test(-number); + } +} + +void test(number) { + num expectSign = sign(number); + num actualSign = number.sign; + if (expectSign.isNaN) { + Expect.isTrue(actualSign.isNaN, "$number: $actualSign != NaN"); + } else { + if (number is int) { + Expect.isTrue(actualSign is int, "$number.sign is int"); + } else { + Expect.isTrue(actualSign is double, "$number.sign is double"); + } + Expect.equals(expectSign, actualSign, "$number"); + Expect.equals(number.isNegative, actualSign.isNegative, "$number:negative"); + var renumber = actualSign * number.abs(); + Expect.equals(number, renumber, "$number (sign*abs)"); + if (number is int) { + Expect.isTrue(renumber is int, "$number (sign*abs) is int"); + } else { + Expect.isTrue(renumber is double, "$number (sign*abs) is double"); + } + } +} diff --git a/tests/corelib/print_test.dart b/tests/corelib/print_test.dart new file mode 100644 index 00000000000..2cbe731e963 --- /dev/null +++ b/tests/corelib/print_test.dart @@ -0,0 +1,21 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:expect/expect.dart'; + +class A { + toString() { + if (false + || true // //# 01: runtime error + ) { + return 499; + } else { + return "ok"; + } + } +} + +main() { + print(new A()); +} diff --git a/tests/corelib/queue_first_test.dart b/tests/corelib/queue_first_test.dart new file mode 100644 index 00000000000..13ace6831a8 --- /dev/null +++ b/tests/corelib/queue_first_test.dart @@ -0,0 +1,17 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +library queue.first.test; + +import "package:expect/expect.dart"; +import 'dart:collection' show Queue; + +main() { + Queue queue1 = new Queue(); + queue1..add(11)..add(12)..add(13); + Queue queue2 = new Queue(); + + Expect.equals(11, queue1.first); + Expect.throws(() => queue2.first, (e) => e is StateError); +} diff --git a/tests/corelib/queue_iterator_test.dart b/tests/corelib/queue_iterator_test.dart new file mode 100644 index 00000000000..af0458b73dc --- /dev/null +++ b/tests/corelib/queue_iterator_test.dart @@ -0,0 +1,61 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +library queue.iterator.test; + +import "package:expect/expect.dart"; +import 'dart:collection' show Queue; + +class QueueIteratorTest { + static testMain() { + testSmallQueue(); + testLargeQueue(); + testEmptyQueue(); + } + + static int sum(int expected, Iterator it) { + int count = 0; + while (it.moveNext()) { + count += it.current; + } + Expect.equals(expected, count); + } + + static void testSmallQueue() { + Queue queue = new Queue(); + queue.addLast(1); + queue.addLast(2); + queue.addLast(3); + + Iterator it = queue.iterator; + sum(6, it); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + } + + static void testLargeQueue() { + Queue queue = new Queue(); + int count = 0; + for (int i = 0; i < 100; i++) { + count += i; + queue.addLast(i); + } + Iterator it = queue.iterator; + sum(count, it); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + } + + static void testEmptyQueue() { + Queue queue = new Queue(); + Iterator it = queue.iterator; + sum(0, it); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + } +} + +main() { + QueueIteratorTest.testMain(); +} diff --git a/tests/corelib/queue_last_test.dart b/tests/corelib/queue_last_test.dart new file mode 100644 index 00000000000..3dbccd2918c --- /dev/null +++ b/tests/corelib/queue_last_test.dart @@ -0,0 +1,17 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +library queue.last.test; + +import "package:expect/expect.dart"; +import 'dart:collection' show Queue; + +main() { + Queue queue1 = new Queue(); + queue1..add(11)..add(12)..add(13); + Queue queue2 = new Queue(); + + Expect.equals(13, queue1.last); + Expect.throws(() => queue2.last, (e) => e is StateError); +} diff --git a/tests/corelib/queue_single_test.dart b/tests/corelib/queue_single_test.dart new file mode 100644 index 00000000000..53893958efc --- /dev/null +++ b/tests/corelib/queue_single_test.dart @@ -0,0 +1,20 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +library queue.single.test; + +import "package:expect/expect.dart"; +import 'dart:collection' show Queue; + +main() { + Queue queue1 = new Queue(); + queue1.add(42); + Queue queue2 = new Queue(); + queue2..add(11)..add(12)..add(13); + Queue queue3 = new Queue(); + + Expect.equals(42, queue1.single); + Expect.throws(() => queue2.single, (e) => e is StateError); + Expect.throws(() => queue3.single, (e) => e is StateError); +} diff --git a/tests/corelib/queue_test.dart b/tests/corelib/queue_test.dart new file mode 100644 index 00000000000..b169bcf36a4 --- /dev/null +++ b/tests/corelib/queue_test.dart @@ -0,0 +1,488 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +library queue.test; + +import "package:expect/expect.dart"; +import 'dart:collection'; + +abstract class QueueTest { + Queue newQueue(); + Queue newQueueFrom(Iterable iterable); + + void testMain() { + Queue queue = newQueue(); + checkQueue(queue, 0, 0); + + queue.addFirst(1); + checkQueue(queue, 1, 1); + + queue.addLast(10); + checkQueue(queue, 2, 11); + + Expect.equals(10, queue.removeLast()); + checkQueue(queue, 1, 1); + + queue.addLast(10); + Expect.equals(1, queue.removeFirst()); + checkQueue(queue, 1, 10); + + queue.addFirst(1); + queue.addLast(100); + queue.addLast(1000); + Expect.equals(1000, queue.removeLast()); + queue.addLast(1000); + checkQueue(queue, 4, 1111); + + queue.removeFirst(); + checkQueue(queue, 3, 1110); + + int mapTest(int value) { + return value ~/ 10; + } + + bool is10(int value) { + return (value == 10); + } + + Queue mapped = newQueueFrom(queue.map(mapTest)); + checkQueue(mapped, 3, 111); + checkQueue(queue, 3, 1110); + Expect.equals(1, mapped.removeFirst()); + Expect.equals(100, mapped.removeLast()); + Expect.equals(10, mapped.removeFirst()); + + Queue other = newQueueFrom(queue.where(is10)); + checkQueue(other, 1, 10); + + Expect.equals(true, queue.any(is10)); + + bool isInstanceOfInt(int value) { + return (value is int); + } + + Expect.equals(true, queue.every(isInstanceOfInt)); + + Expect.equals(false, queue.every(is10)); + + bool is1(int value) { + return (value == 1); + } + + Expect.equals(false, queue.any(is1)); + + queue.clear(); + Expect.equals(0, queue.length); + + var exception = null; + try { + queue.removeFirst(); + } on StateError catch (e) { + exception = e; + } + Expect.equals(true, exception != null); + Expect.equals(0, queue.length); + + exception = null; + try { + queue.removeLast(); + } on StateError catch (e) { + exception = e; + } + Expect.equals(true, exception != null); + Expect.equals(0, queue.length); + + queue.addFirst(1); + queue.addFirst(2); + Expect.equals(2, queue.first); + Expect.equals(1, queue.last); + + queue.addLast(3); + Expect.equals(3, queue.last); + bool isGreaterThanOne(int value) { + return (value > 1); + } + + other = newQueueFrom(queue.where(isGreaterThanOne)); + checkQueue(other, 2, 5); + + // Cycle through values without ever having large element count. + queue = newQueue(); + queue.add(0); + for (int i = 0; i < 255; i++) { + queue.add(i + 1); + Expect.equals(i, queue.removeFirst()); + } + Expect.equals(255, queue.removeFirst()); + Expect.isTrue(queue.isEmpty); + + testAddAll(); + testLengthChanges(); + testLarge(); + testFromListToList(); + } + + void checkQueue(Queue queue, int expectedSize, int expectedSum) { + testLength(expectedSize, queue); + int sum = 0; + void sumElements(int value) { + sum += value; + } + + queue.forEach(sumElements); + Expect.equals(expectedSum, sum); + } + + testLength(int length, Queue queue) { + Expect.equals(length, queue.length); + ((length == 0) ? Expect.isTrue : Expect.isFalse)(queue.isEmpty); + ((length != 0) ? Expect.isTrue : Expect.isFalse)(queue.isNotEmpty); + } + + void testAddAll() { + Set set = new Set.from([1, 2, 4]); + Expect.equals(3, set.length); + + Queue queue1 = newQueueFrom(set); + Queue queue2 = newQueue(); + Queue queue3 = newQueue(); + testLength(3, queue1); + testLength(0, queue2); + testLength(0, queue3); + + queue2.addAll(set); + testLength(3, queue2); + + queue3.addAll(queue1); + testLength(3, queue3); + + int sum = 0; + void f(e) { + sum += e; + } + + ; + + set.forEach(f); + Expect.equals(7, sum); + sum = 0; + + queue1.forEach(f); + Expect.equals(7, sum); + sum = 0; + + queue2.forEach(f); + Expect.equals(7, sum); + sum = 0; + + queue3.forEach(f); + Expect.equals(7, sum); + sum = 0; + + set = new Set.from([]); + queue1 = newQueueFrom(set); + queue2 = newQueue(); + queue3 = newQueue(); + + queue2.addAll(set); + queue3.addAll(queue1); + + Expect.equals(0, set.length); + Expect.equals(0, queue1.length); + Expect.equals(0, queue2.length); + Expect.equals(0, queue3.length); + } + + void testLengthChanges() { + // Test that the length property is updated properly by + // modifications; + Queue queue = newQueue(); + testLength(0, queue); + + for (int i = 1; i <= 10; i++) { + queue.add(i); + testLength(i, queue); + } + + for (int i = 1; i <= 10; i++) { + queue.addFirst(11 - i); + testLength(10 + i, queue); + } + + for (int i = 1; i <= 10; i++) { + queue.addLast(i); + testLength(20 + i, queue); + } + + queue.addAll([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); + testLength(40, queue); + + for (int i = 1; i <= 5; i++) { + Expect.equals(i, queue.removeFirst()); + testLength(40 - i, queue); + } + + for (int i = 1; i <= 5; i++) { + Expect.equals(11 - i, queue.removeLast()); + testLength(35 - i, queue); + } + + Expect.isTrue(queue.remove(10)); + testLength(29, queue); + Expect.isFalse(queue.remove(999)); + testLength(29, queue); + + queue.removeWhere((x) => x == 7); + testLength(26, queue); + + queue.retainWhere((x) => x != 3); + testLength(23, queue); + + Expect.listEquals( + [6, 8, 9, 1, 2, 4, 5, 6, 8, 9, 10, 1, 2, 4, 5, 6, 8, 9, 10, 1, 2, 4, 5], + queue.toList()); + + // Regression test: http://dartbug.com/16270 + // These should all do nothing, and should not throw. + Queue emptyQueue = newQueue(); + emptyQueue.remove(0); + emptyQueue.removeWhere((x) => null); + emptyQueue.retainWhere((x) => null); + } + + void testLarge() { + int N = 10000; + Set set = new Set(); + + Queue queue = newQueue(); + Expect.isTrue(queue.isEmpty); + + for (int i = 0; i < N; i++) { + queue.add(i); + set.add(i); + } + Expect.equals(N, queue.length); + Expect.isFalse(queue.isEmpty); + + Expect.equals(0, queue.elementAt(0)); + Expect.equals(N - 1, queue.elementAt(N - 1)); + Expect.throws(() { + queue.elementAt(-1); + }); + Expect.throws(() { + queue.elementAt(N); + }); + + Iterable skip1 = queue.skip(1); + Iterable take1 = queue.take(1); + Iterable mapped = queue.map((e) => -e); + + for (int i = 0; i < 500; i++) { + Expect.equals(i, take1.first); + Expect.equals(i, queue.first); + Expect.equals(-i, mapped.first); + Expect.equals(i + 1, skip1.first); + Expect.equals(i, queue.removeFirst()); + Expect.equals(i + 1, take1.first); + Expect.equals(-i - 1, mapped.first); + Expect.equals(N - 1 - i, queue.last); + Expect.equals(N - 1 - i, queue.removeLast()); + } + Expect.equals(N - 1000, queue.length); + + Expect.isTrue(queue.remove(N >> 1)); + Expect.equals(N - 1001, queue.length); + + queue.clear(); + Expect.equals(0, queue.length); + Expect.isTrue(queue.isEmpty); + + queue.addAll(set); + Expect.equals(N, queue.length); + Expect.isFalse(queue.isEmpty); + + // Iterate. + for (var element in queue) { + Expect.isTrue(set.contains(element)); + } + + queue.forEach((element) { + Expect.isTrue(set.contains(element)); + }); + + queue.addAll(set); + Expect.equals(N * 2, queue.length); + Expect.isFalse(queue.isEmpty); + + queue.clear(); + Expect.equals(0, queue.length); + Expect.isTrue(queue.isEmpty); + } + + void testFromListToList() { + const int N = 256; + List list = []; + for (int i = 0; i < N; i++) { + Queue queue = newQueueFrom(list); + + Expect.equals(list.length, queue.length); + List to = queue.toList(); + Expect.listEquals(list, to); + + queue.add(i); + list.add(i); + Expect.equals(list.length, queue.length); + to = queue.toList(); + Expect.listEquals(list, to); + } + } +} + +class ListQueueTest extends QueueTest { + Queue newQueue() => new ListQueue(); + Queue newQueueFrom(Iterable elements) => new ListQueue.from(elements); + + void testMain() { + super.testMain(); + trickyTest(); + } + + void trickyTest() { + // Test behavior around the know growing capacities of a ListQueue. + Queue q = new ListQueue(); + + for (int i = 0; i < 255; i++) { + q.add(i); + } + for (int i = 0; i < 128; i++) { + Expect.equals(i, q.removeFirst()); + } + q.add(255); + for (int i = 0; i < 127; i++) { + q.add(i); + } + + Expect.equals(255, q.length); + + // Remove element at end of internal buffer. + q.removeWhere((v) => v == 255); + // Remove element at beginning of internal buffer. + q.removeWhere((v) => v == 0); + // Remove element at both ends of internal buffer. + q.removeWhere((v) => v == 254 || v == 1); + + Expect.equals(251, q.length); + + Iterable i255 = new Iterable.generate(255, (x) => x); + + q = new ListQueue(); + q.addAll(i255); + Expect.listEquals(i255.toList(), q.toList()); + + q = new ListQueue(); + q.addAll(i255.toList()); + Expect.listEquals(i255.toList(), q.toList()); + + q = new ListQueue.from(i255); + for (int i = 0; i < 128; i++) q.removeFirst(); + q.add(256); + q.add(0); + q.addAll(i255.toList()); + Expect.equals(129 + 255, q.length); + + // Test addAll that requires the queue to grow. + q = new ListQueue(); + q.addAll(i255.take(35)); + q.addAll(i255.skip(35).take(96)); + q.addAll(i255.skip(35 + 96)); + Expect.listEquals(i255.toList(), q.toList()); + } +} + +class DoubleLinkedQueueTest extends QueueTest { + Queue newQueue() => new DoubleLinkedQueue(); + Queue newQueueFrom(Iterable elements) => new DoubleLinkedQueue.from(elements); + + void testMain() { + super.testMain(); + testQueueElements(); + } + + void testQueueElements() { + DoubleLinkedQueue queue1 = new DoubleLinkedQueue.from([1, 2, 3]); + DoubleLinkedQueue queue2 = new DoubleLinkedQueue(); + queue2.addAll(queue1); + + Expect.equals(queue1.length, queue2.length); + DoubleLinkedQueueEntry entry1 = queue1.firstEntry(); + DoubleLinkedQueueEntry entry2 = queue2.firstEntry(); + while (entry1 != null) { + Expect.equals(true, !identical(entry1, entry2)); + entry1 = entry1.nextEntry(); + entry2 = entry2.nextEntry(); + } + Expect.equals(null, entry2); + + var firstEntry = queue1.firstEntry(); + var secondEntry = queue1.firstEntry().nextEntry(); + var thirdEntry = queue1.lastEntry(); + firstEntry.prepend(4); + firstEntry.append(5); + secondEntry.prepend(6); + secondEntry.append(7); + thirdEntry.prepend(8); + thirdEntry.append(9); + Expect.equals(9, queue1.length); + Expect.listEquals(queue1.toList(), [4, 1, 5, 6, 2, 7, 8, 3, 9]); + Expect.equals(1, firstEntry.remove()); + Expect.equals(2, secondEntry.remove()); + Expect.equals(3, thirdEntry.remove()); + Expect.equals(6, queue1.length); + Expect.listEquals(queue1.toList(), [4, 5, 6, 7, 8, 9]); + } +} + +void linkEntryTest() { + var entry = new DoubleLinkedQueueEntry(42); + Expect.equals(null, entry.previousEntry()); + Expect.equals(null, entry.nextEntry()); + + entry.append(37); + entry.prepend(87); + var prev = entry.previousEntry(); + var next = entry.nextEntry(); + Expect.equals(42, entry.element); + Expect.equals(37, next.element); + Expect.equals(87, prev.element); + Expect.identical(entry, prev.nextEntry()); + Expect.identical(entry, next.previousEntry()); + Expect.equals(null, next.nextEntry()); + Expect.equals(null, prev.previousEntry()); + + entry.element = 117; + Expect.equals(117, entry.element); + Expect.identical(next, entry.nextEntry()); + Expect.identical(prev, entry.previousEntry()); + + Expect.equals(117, entry.remove()); + Expect.identical(next, prev.nextEntry()); + Expect.identical(prev, next.previousEntry()); + Expect.equals(null, next.nextEntry()); + Expect.equals(null, prev.previousEntry()); + Expect.equals(37, next.element); + Expect.equals(87, prev.element); + + Expect.equals(37, next.remove()); + Expect.equals(87, prev.element); + Expect.equals(null, prev.nextEntry()); + Expect.equals(null, prev.previousEntry()); + + Expect.equals(87, prev.remove()); +} + +main() { + new DoubleLinkedQueueTest().testMain(); + new ListQueueTest().testMain(); + linkEntryTest(); +} diff --git a/tests/corelib/range_error_test.dart b/tests/corelib/range_error_test.dart new file mode 100644 index 00000000000..05107e8a208 --- /dev/null +++ b/tests/corelib/range_error_test.dart @@ -0,0 +1,94 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +// Dart test for testing out of range exceptions on arrays, and the content +// of range_error toString(). + +void main() { + testRead(); + testWrite(); + testToString(); +} + +void testRead() { + testListRead([], 0); + testListRead([], -1); + testListRead([], 1); + + var list = [1]; + testListRead(list, -1); + testListRead(list, 1); + + list = new List(1); + testListRead(list, -1); + testListRead(list, 1); + + list = new List(); + testListRead(list, -1); + testListRead(list, 0); + testListRead(list, 1); +} + +void testWrite() { + testListWrite([], 0); + testListWrite([], -1); + testListWrite([], 1); + + var list = [1]; + testListWrite(list, -1); + testListWrite(list, 1); + + list = new List(1); + testListWrite(list, -1); + testListWrite(list, 1); + + list = new List(); + testListWrite(list, -1); + testListWrite(list, 0); + testListWrite(list, 1); +} + +void testToString() { + for (var name in [null, "THENAME"]) { + for (var message in [null, "THEMESSAGE"]) { + var value = 37; + for (var re in [ + new ArgumentError.value(value, name, message), + new RangeError.value(value, name, message), + new RangeError.index(value, [], name, message), + new RangeError.range(value, 0, 24, name, message) + ]) { + var str = re.toString(); + if (name != null) Expect.isTrue(str.contains(name), "$name in $str"); + if (message != null) + Expect.isTrue(str.contains(message), "$message in $str"); + Expect.isTrue(str.contains("$value"), "$value in $str"); + // No empty ':' separated parts - in that case the colon is omitted too. + Expect.isFalse(str.contains(new RegExp(":\s*:"))); + } + } + } +} + +void testListRead(list, index) { + var exception = null; + try { + var e = list[index]; + } on RangeError catch (e) { + exception = e; + } + Expect.equals(true, exception != null); +} + +void testListWrite(list, index) { + var exception = null; + try { + list[index] = null; + } on RangeError catch (e) { + exception = e; + } + Expect.equals(true, exception != null); +} diff --git a/tests/corelib/reg_exp1_test.dart b/tests/corelib/reg_exp1_test.dart new file mode 100644 index 00000000000..88e3b0a2a01 --- /dev/null +++ b/tests/corelib/reg_exp1_test.dart @@ -0,0 +1,31 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. +// Dart test for testing regular expressions in Dart. + +import "package:expect/expect.dart"; + +class RegExp1Test { + static testMain() { + RegExp exp1 = new RegExp("bar|foo"); + Expect.equals(true, exp1.hasMatch("foo")); + Expect.equals(true, exp1.hasMatch("bar")); + Expect.equals(false, exp1.hasMatch("gim")); + Expect.equals(true, exp1.hasMatch("just foo")); + Expect.equals("bar|foo", exp1.pattern); + Expect.equals(false, exp1.isMultiLine); + Expect.equals(true, exp1.isCaseSensitive); + + RegExp exp2 = new RegExp("o+", caseSensitive: false); + Expect.equals(true, exp2.hasMatch("this looks good")); + Expect.equals(true, exp2.hasMatch("fOO")); + Expect.equals(false, exp2.hasMatch("bar")); + Expect.equals("o+", exp2.pattern); + Expect.equals(false, exp2.isCaseSensitive); + Expect.equals(false, exp2.isMultiLine); + } +} + +main() { + RegExp1Test.testMain(); +} diff --git a/tests/corelib/reg_exp4_test.dart b/tests/corelib/reg_exp4_test.dart new file mode 100644 index 00000000000..f8f63c14409 --- /dev/null +++ b/tests/corelib/reg_exp4_test.dart @@ -0,0 +1,49 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. +// Dart test for testing regular expressions in Dart. + +import "package:expect/expect.dart"; + +main() { + try { + RegExp ex = new RegExp(null); + Expect.fail("Expected: ArgumentError got: no exception"); + } catch (ex) { + if (!(ex is ArgumentError)) { + Expect.fail("Expected: ArgumentError got: ${ex}"); + } + } + try { + new RegExp(r"^\w+$").hasMatch(null); + Expect.fail("Expected: ArgumentError got: no exception"); + } catch (ex) { + if (!(ex is ArgumentError)) { + Expect.fail("Expected: ArgumentError got: ${ex}"); + } + } + try { + new RegExp(r"^\w+$").firstMatch(null); + Expect.fail("Expected: ArgumentError got: no exception"); + } catch (ex) { + if (!(ex is ArgumentError)) { + Expect.fail("Expected: ArgumentError got: ${ex}"); + } + } + try { + new RegExp(r"^\w+$").allMatches(null); + Expect.fail("Expected: ArgumentError got: no exception"); + } catch (ex) { + if (!(ex is ArgumentError)) { + Expect.fail("Expected: ArgumentError got: ${ex}"); + } + } + try { + new RegExp(r"^\w+$").stringMatch(null); + Expect.fail("Expected: ArgumentError got: no exception"); + } catch (ex) { + if (!(ex is ArgumentError)) { + Expect.fail("Expected: ArgumentError got: ${ex}"); + } + } +} diff --git a/tests/corelib/reg_exp5_test.dart b/tests/corelib/reg_exp5_test.dart new file mode 100644 index 00000000000..f67cd6d5941 --- /dev/null +++ b/tests/corelib/reg_exp5_test.dart @@ -0,0 +1,25 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. +// Dart test for testing regular expressions in Dart. + +import "package:expect/expect.dart"; + +main() { + String str = ""; + try { + RegExp ex = new RegExp(str); + } catch (e) { + if (!(e is ArgumentError)) { + Expect.fail("Expected: ArgumentError got: ${e}"); + } + } + Expect.isFalse(new RegExp(r"^\w+$").hasMatch(str)); + Match fm = new RegExp(r"^\w+$").firstMatch(str); + Expect.equals(null, fm); + + Iterable am = new RegExp(r"^\w+$").allMatches(str); + Expect.isFalse(am.iterator.moveNext()); + + Expect.equals(null, new RegExp(r"^\w+$").stringMatch(str)); +} diff --git a/tests/corelib/reg_exp_all_matches_test.dart b/tests/corelib/reg_exp_all_matches_test.dart new file mode 100644 index 00000000000..72a2344fbaf --- /dev/null +++ b/tests/corelib/reg_exp_all_matches_test.dart @@ -0,0 +1,118 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +// Dart test program for RegExp.allMatches. + +class RegExpAllMatchesTest { + static testIterator() { + var matches = new RegExp("foo").allMatches("foo foo"); + Iterator it = matches.iterator; + Expect.isTrue(it.moveNext()); + Expect.equals('foo', it.current.group(0)); + Expect.isTrue(it.moveNext()); + Expect.equals('foo', it.current.group(0)); + Expect.isFalse(it.moveNext()); + + // Run two iterators over the same results. + it = matches.iterator; + Iterator it2 = matches.iterator; + Expect.isTrue(it.moveNext()); + Expect.isTrue(it2.moveNext()); + Expect.equals('foo', it.current.group(0)); + Expect.equals('foo', it2.current.group(0)); + Expect.isTrue(it.moveNext()); + Expect.isTrue(it2.moveNext()); + Expect.equals('foo', it.current.group(0)); + Expect.equals('foo', it2.current.group(0)); + Expect.equals(false, it.moveNext()); + Expect.equals(false, it2.moveNext()); + } + + static testForEach() { + var matches = new RegExp("foo").allMatches("foo foo"); + var strbuf = new StringBuffer(); + matches.forEach((Match m) { + strbuf.write(m.group(0)); + }); + Expect.equals("foofoo", strbuf.toString()); + } + + static testMap() { + var matches = new RegExp("foo?").allMatches("foo fo foo fo"); + var mapped = matches.map((Match m) => "${m.group(0)}bar"); + Expect.equals(4, mapped.length); + var strbuf = new StringBuffer(); + for (String s in mapped) { + strbuf.write(s); + } + Expect.equals("foobarfobarfoobarfobar", strbuf.toString()); + } + + static testFilter() { + var matches = new RegExp("foo?").allMatches("foo fo foo fo"); + var filtered = matches.where((Match m) { + return m.group(0) == 'foo'; + }); + Expect.equals(2, filtered.length); + var strbuf = new StringBuffer(); + for (Match m in filtered) { + strbuf.write(m.group(0)); + } + Expect.equals("foofoo", strbuf.toString()); + } + + static testEvery() { + var matches = new RegExp("foo?").allMatches("foo fo foo fo"); + Expect.equals(true, matches.every((Match m) { + return m.group(0).startsWith("fo"); + })); + Expect.equals(false, matches.every((Match m) { + return m.group(0).startsWith("foo"); + })); + } + + static testSome() { + var matches = new RegExp("foo?").allMatches("foo fo foo fo"); + Expect.equals(true, matches.any((Match m) { + return m.group(0).startsWith("fo"); + })); + Expect.equals(true, matches.any((Match m) { + return m.group(0).startsWith("foo"); + })); + Expect.equals(false, matches.any((Match m) { + return m.group(0).startsWith("fooo"); + })); + } + + static testIsEmpty() { + var matches = new RegExp("foo?").allMatches("foo fo foo fo"); + Expect.equals(false, matches.isEmpty); + matches = new RegExp("fooo").allMatches("foo fo foo fo"); + Expect.equals(true, matches.isEmpty); + } + + static testGetCount() { + var matches = new RegExp("foo?").allMatches("foo fo foo fo"); + Expect.equals(4, matches.length); + matches = new RegExp("fooo").allMatches("foo fo foo fo"); + Expect.equals(0, matches.length); + } + + static testMain() { + testIterator(); + testForEach(); + testMap(); + testFilter(); + testEvery(); + testSome(); + testIsEmpty(); + testGetCount(); + } +} + +main() { + RegExpAllMatchesTest.testMain(); +} diff --git a/tests/corelib/reg_exp_first_match_test.dart b/tests/corelib/reg_exp_first_match_test.dart new file mode 100644 index 00000000000..40e38fa109c --- /dev/null +++ b/tests/corelib/reg_exp_first_match_test.dart @@ -0,0 +1,18 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +// Dart test program for RegExp.firstMatch. + +class RegExpFirstMatchTest { + static testMain() { + Expect.equals('cat', new RegExp("(\\w+)").firstMatch("cat dog")[0]); + Expect.equals(null, new RegExp("foo").firstMatch("bar")); + } +} + +main() { + RegExpFirstMatchTest.testMain(); +} diff --git a/tests/corelib/reg_exp_group_test.dart b/tests/corelib/reg_exp_group_test.dart new file mode 100644 index 00000000000..1bf4af3753b --- /dev/null +++ b/tests/corelib/reg_exp_group_test.dart @@ -0,0 +1,22 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +// Dart test program for RegExp.group. + +class RegExpGroupTest { + static testMain() { + var match = new RegExp("(a(b)((c|de)+))").firstMatch("abcde"); + Expect.equals('abcde', match.group(0)); + Expect.equals('abcde', match.group(1)); + Expect.equals('b', match.group(2)); + Expect.equals('cde', match[3]); + Expect.equals('de', match[4]); + } +} + +main() { + RegExpGroupTest.testMain(); +} diff --git a/tests/corelib/reg_exp_groups_test.dart b/tests/corelib/reg_exp_groups_test.dart new file mode 100644 index 00000000000..70386d0e9ec --- /dev/null +++ b/tests/corelib/reg_exp_groups_test.dart @@ -0,0 +1,22 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +// Dart test program for RegExp.groups. + +class RegExpGroupsTest { + static testMain() { + var match = new RegExp("(a(b)((c|de)+))").firstMatch("abcde"); + var groups = match.groups([0, 4, 2, 3]); + Expect.equals('abcde', groups[0]); + Expect.equals('de', groups[1]); + Expect.equals('b', groups[2]); + Expect.equals('cde', groups[3]); + } +} + +main() { + RegExpGroupsTest.testMain(); +} diff --git a/tests/corelib/reg_exp_has_match_test.dart b/tests/corelib/reg_exp_has_match_test.dart new file mode 100644 index 00000000000..6ff27443fa9 --- /dev/null +++ b/tests/corelib/reg_exp_has_match_test.dart @@ -0,0 +1,19 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +// Dart test program for RegExp.hasMatch. + +class RegExpHasMatchTest { + static testMain() { + Expect.equals(false, new RegExp("bar").hasMatch("foo")); + Expect.equals(true, new RegExp("bar|foo").hasMatch("foo")); + Expect.equals(true, new RegExp("o+").hasMatch("foo")); + } +} + +main() { + RegExpHasMatchTest.testMain(); +} diff --git a/tests/corelib/reg_exp_pattern_test.dart b/tests/corelib/reg_exp_pattern_test.dart new file mode 100644 index 00000000000..7b4d6662067 --- /dev/null +++ b/tests/corelib/reg_exp_pattern_test.dart @@ -0,0 +1,27 @@ +// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. +// Dart test for testing regular expressions in Dart. + +import "package:expect/expect.dart"; + +// Regression test for http://dartbug.com/17998 + +main() { + for (var s in [ + r"a", + r"a|b", + r"(?:)", + r"^", + r"$", + r"^$", + r"$^", + r"", + r"\\", + r"/", + r"[^]", + "\x00", + ]) { + Expect.equals(s, new RegExp(s).pattern); + } +} diff --git a/tests/corelib/reg_exp_start_end_test.dart b/tests/corelib/reg_exp_start_end_test.dart new file mode 100644 index 00000000000..3ec343ea562 --- /dev/null +++ b/tests/corelib/reg_exp_start_end_test.dart @@ -0,0 +1,19 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + var matches = new RegExp("(a(b)((c|de)+))").allMatches("abcde abcde abcde"); + var it = matches.iterator; + int start = 0; + int end = 5; + while (it.moveNext()) { + Match match = it.current; + Expect.equals(start, match.start); + Expect.equals(end, match.end); + start += 6; + end += 6; + } +} diff --git a/tests/corelib/reg_exp_string_match_test.dart b/tests/corelib/reg_exp_string_match_test.dart new file mode 100644 index 00000000000..05978dd215c --- /dev/null +++ b/tests/corelib/reg_exp_string_match_test.dart @@ -0,0 +1,18 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +// Dart test program for RegExp.stringMatch. + +class RegExpStringMatchTest { + static testMain() { + Expect.equals('cat', new RegExp("(\\w+)").stringMatch("cat dog")); + Expect.equals(null, new RegExp("foo").stringMatch("bar")); + } +} + +main() { + RegExpStringMatchTest.testMain(); +} diff --git a/tests/corelib/regexp/UC16_test.dart b/tests/corelib/regexp/UC16_test.dart new file mode 100644 index 00000000000..c89464fe5dd --- /dev/null +++ b/tests/corelib/regexp/UC16_test.dart @@ -0,0 +1,71 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2008 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + // UC16 + // Characters used: + // "\u03a3\u03c2\u03c3\u039b\u03bb" - Sigma, final sigma, sigma, Lambda, + // lambda + shouldBe( + new RegExp(r"x(.)\1x", caseSensitive: false).firstMatch("x\u03a3\u03c3x"), + ["x\u03a3\u03c3x", "\u03a3"], + "backref-UC16"); + assertFalse( + new RegExp(r"x(...)\1", caseSensitive: false) + .hasMatch("x\u03a3\u03c2\u03c3\u03c2\u03c3"), + "\1 ASCII, string short"); + assertTrue( + new RegExp(r"\u03a3((?:))\1\1x", caseSensitive: false) + .hasMatch("\u03c2x"), + "backref-UC16-empty"); + assertTrue( + new RegExp(r"x(?:...|(...))\1x", caseSensitive: false) + .hasMatch("x\u03a3\u03c2\u03c3x"), + "backref-UC16-uncaptured"); + assertTrue( + new RegExp(r"x(?:...|(...))\1x", caseSensitive: false) + .hasMatch("x\u03c2\u03c3\u039b\u03a3\u03c2\u03bbx"), + "backref-UC16-backtrack"); + var longUC16String = + "x\u03a3\u03c2\u039b\u03c2\u03c3\u03bb\u03c3\u03a3\u03bb"; + shouldBe( + new RegExp(r"x(...)\1\1", caseSensitive: false) + .firstMatch(longUC16String), + [longUC16String, longUC16String.substring(1, 4)], + "backref-UC16-twice"); + + assertFalse(new RegExp(r"\xc1", caseSensitive: false).hasMatch('fooA'), + "quickcheck-uc16-pattern-ascii-subject"); + assertFalse(new RegExp(r"[\xe9]").hasMatch('i'), + "charclass-uc16-pattern-ascii-subject"); + assertFalse(new RegExp(r"\u5e74|\u6708").hasMatch('t'), + "alternation-uc16-pattern-ascii-subject"); +} diff --git a/tests/corelib/regexp/alternative-length-miscalculation_test.dart b/tests/corelib/regexp/alternative-length-miscalculation_test.dart new file mode 100644 index 00000000000..a4461aced24 --- /dev/null +++ b/tests/corelib/regexp/alternative-length-miscalculation_test.dart @@ -0,0 +1,37 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + description( + "This page tests for length miscalculations in regular expression processing."); + + var re = new RegExp(r"b|[^b]"); + assertEquals('a'.indexOf(re, 1), -1); + + var re2 = new RegExp(r"[^a]|ab"); + shouldBeFalse(re2.hasMatch('')); +} diff --git a/tests/corelib/regexp/alternatives_test.dart b/tests/corelib/regexp/alternatives_test.dart new file mode 100644 index 00000000000..2211dfb03b4 --- /dev/null +++ b/tests/corelib/regexp/alternatives_test.dart @@ -0,0 +1,52 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + description('Test regular expression processing with alternatives.'); + + var s1 = "

content

"; + shouldBe(firstMatch(s1, new RegExp(r"<((\\/([^>]+)>)|(([^>]+)>))")), + ["

", "p>", null, null, "p>", "p"]); + shouldBe(firstMatch(s1, new RegExp(r"<((ABC>)|(\\/([^>]+)>)|(([^>]+)>))")), + ["

", "p>", null, null, null, "p>", "p"]); + shouldBe(firstMatch(s1, new RegExp(r"<(a|\\/p|.+?)>")), ["

", "p"]); + + // Force YARR to use Interpreter by using iterative parentheses + shouldBe(firstMatch(s1, new RegExp(r"<((\\/([^>]+)>)|((([^>])+)>))")), + ["

", "p>", null, null, "p>", "p", "p"]); + shouldBe(firstMatch(s1, new RegExp(r"<((ABC>)|(\\/([^>]+)>)|((([^>])+)>))")), + ["

", "p>", null, null, null, "p>", "p", "p"]); + shouldBe(firstMatch(s1, new RegExp(r"<(a|\\/p|(.)+?)>")), ["

", "p", "p"]); + + // Force YARR to use Interpreter by using backreference + var s2 = "

p

"; + shouldBe(firstMatch(s2, new RegExp(r"<((\\/([^>]+)>)|(([^>]+)>))\5")), + ["

p", "p>", null, null, "p>", "p"]); + shouldBe(firstMatch(s2, new RegExp(r"<((ABC>)|(\\/([^>]+)>)|(([^>]+)>))\6")), + ["

p", "p>", null, null, null, "p>", "p"]); + shouldBe(firstMatch(s2, new RegExp(r"<(a|\\/p|.+?)>\1")), ["

qrs)123)"), 229); + assertNull(res[118].firstMatch("(ab(cd)ef)"), 230); + assertNull(res[118].firstMatch("(ab(cd(ef)gh)ij)"), 231); + assertNull(res[146].firstMatch("A"), 232); + assertNull(res[146].firstMatch("a"), 233); + assertNull(res[147].firstMatch("A"), 234); + assertNull(res[147].firstMatch("a"), 235); + assertNull(res[147].firstMatch("ab"), 236); + assertNull(res[147].firstMatch("aB"), 237); + assertNull(res[147].firstMatch("*** Failers"), 238); + assertNull(res[147].firstMatch("Ab"), 239); + assertNull(res[147].firstMatch("AB"), 240); + assertThrows(() => new RegExp(r"[\200-\110]"), 241); + // TODO(jgruber): Reintegrate stack-overflow2_test.dart once it passes. + assertToStringEquals("mainmain,main,", res[151].firstMatch("mainmain"), 243); + assertToStringEquals( + "mainOmain,main,", res[151].firstMatch("mainOmain"), 244); + assertToStringEquals("aba,a,", res[153].firstMatch("aba"), 245); + assertToStringEquals("aabbaa,aa,", res[154].firstMatch("aabbaa"), 246); + assertToStringEquals("aabbaa,aa,", res[155].firstMatch("aabbaa"), 247); + assertToStringEquals("aabbaa,aa,", res[156].firstMatch("aabbaa"), 248); + assertToStringEquals("aabbaa,", res[157].firstMatch("aabbaa"), 249); + assertToStringEquals("aabbaa,aa,,", res[158].firstMatch("aabbaa"), 250); + assertToStringEquals("aabbaa,,", res[159].firstMatch("aabbaa"), 251); + assertToStringEquals("aabbaa,", res[160].firstMatch("aabbaa"), 252); + assertToStringEquals("aabbbaa,", res[161].firstMatch("aabbbaa"), 253); + assertToStringEquals("aabbbaa,", res[162].firstMatch("aabbbaa"), 254); + assertToStringEquals("aabbaa,", res[163].firstMatch("aabbaa"), 255); + assertToStringEquals("aabbbaa,", res[164].firstMatch("aabbbaa"), 256); + assertToStringEquals("aabbbaa,aa,,", res[165].firstMatch("aabbbaa"), 257); + assertToStringEquals("aabbbbaa,aa,,", res[166].firstMatch("aabbbbaa"), 258); + // Dart does not have RegExp literals and thus no translatation of the below. + // assertThrows("var re = //;", 259); + assertToStringEquals("a", res[169].firstMatch("ab"), 260); + assertToStringEquals("a", res[169].firstMatch("aB"), 261); + assertToStringEquals("*", res[169].firstMatch("*** Failers"), 262); + assertToStringEquals("A", res[169].firstMatch("AB"), 263); + assertToStringEquals("a", res[169].firstMatch("ab"), 264); + assertToStringEquals("a", res[169].firstMatch("aB"), 265); + assertToStringEquals("*", res[169].firstMatch("*** Failers"), 266); + assertToStringEquals("A", res[169].firstMatch("AB"), 267); + assertNull(res[172].firstMatch("\\"), 268); + assertNull(res[177].firstMatch("*** Failers"), 269); + assertNull(res[177].firstMatch("xxxxx"), 270); + assertNull( + res[177].firstMatch( + "now is the time for all good men to come to the aid of the party"), + 271); + assertNull(res[177].firstMatch("*** Failers"), 272); + assertNull( + res[177].firstMatch("this is not a line with only words and spaces!"), + 273); + assertNull(res[177].firstMatch("12345a"), 274); + assertNull(res[177].firstMatch("*** Failers"), 275); + assertNull(res[177].firstMatch("12345+"), 276); + assertNull(res[177].firstMatch("aaab"), 277); + assertNull(res[177].firstMatch("aaab"), 278); + assertNull(res[177].firstMatch("aaab"), 279); + assertNull(res[177].firstMatch("((abc(ade)ufh()()x"), 280); + assertNull(res[177].firstMatch("(abc)"), 281); + assertNull(res[177].firstMatch("(abc(def)xyz)"), 282); + assertNull(res[177].firstMatch("*** Failers"), 283); + assertNull( + res[177].firstMatch("((()aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + 284); + assertNull(res[177].firstMatch("xaaaab"), 285); + assertNull(res[177].firstMatch("xaaaab"), 286); + assertThrows(() => new RegExp(r"["), 287); + assertThrows(() => new RegExp(r"[a-"), 288); + assertNull(res[189].firstMatch("<>"), 289); + assertNull(res[189].firstMatch(""), 290); + assertNull(res[189].firstMatch(" hij>"), 291); + assertNull(res[189].firstMatch(" hij>"), 292); + assertNull(res[189].firstMatch("def>"), 293); + assertNull(res[189].firstMatch(""), 294); + assertNull(res[189].firstMatch("*** Failers"), 295); + assertNull(res[189].firstMatch(""), 355); + assertToStringEquals("abc", res[215].firstMatch(""), 356); + assertToStringEquals("abc", res[215].firstMatch(" hij>"), 357); + assertToStringEquals("abc", res[215].firstMatch(" hij>"), 358); + assertToStringEquals("abc", res[215].firstMatch("def>"), 359); + assertToStringEquals("abc", res[215].firstMatch(""), 360); + assertNull(res[215].firstMatch("*** Failers"), 361); + assertToStringEquals("abc", res[215].firstMatch("\n\n\nPartner der LCO\nde\nPartner der LINEAS Consulting\nGmbH\nLINEAS Consulting GmbH Hamburg\nPartnerfirmen\n30 days\nindex,follow\n\nja\n3\nPartner\n\n\nLCO\nLINEAS Consulting\n15.10.2003\n\n\n\n\nDie Partnerfirmen der LINEAS Consulting\nGmbH\n\n\n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"), + 448); + assertToStringEquals( + "line\nbreak", res[251].firstMatch("this is a line\nbreak"), 449); + assertToStringEquals( + "line\nbreak", + res[251].firstMatch("line one\nthis is a line\nbreak in the second line"), + 450); + assertToStringEquals( + "line\nbreak", res[252].firstMatch("this is a line\nbreak"), 451); + assertNull(res[252].firstMatch("** Failers"), 452); + assertToStringEquals( + "line\nbreak", + res[252].firstMatch("line one\nthis is a line\nbreak in the second line"), + 453); + assertToStringEquals( + "line\nbreak", res[253].firstMatch("this is a line\nbreak"), 454); + assertNull(res[253].firstMatch("** Failers"), 455); + assertToStringEquals( + "line\nbreak", + res[253].firstMatch("line one\nthis is a line\nbreak in the second line"), + 456); + assertToStringEquals("ab-cd", res[254].firstMatch("ab-cd"), 457); + assertToStringEquals("ab=cd", res[254].firstMatch("ab=cd"), 458); + assertNull(res[254].firstMatch("** Failers"), 459); + assertNull(res[254].firstMatch("ab\ncd"), 460); + assertToStringEquals("ab-cd", res[255].firstMatch("ab-cd"), 461); + assertToStringEquals("ab=cd", res[255].firstMatch("ab=cd"), 462); + assertNull(res[255].firstMatch("ab\ncd"), 463); + assertNull(res[255].firstMatch("AbCd"), 464); + assertNull(res[255].firstMatch("** Failers"), 465); + assertNull(res[255].firstMatch("abcd"), 466); + // We are compatible with JSC, and don't throw an exception in this case. + // assertThrows("var re = /(){2,4294967295}/;", 467); + assertNull(res[255].firstMatch("abcdefghijklAkB"), 468); + assertNull(res[255].firstMatch("abcdefghijklAkB"), 469); + assertNull(res[255].firstMatch("abcdefghijklAkB"), 470); + assertNull( + res[255].firstMatch( + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + 471); + assertNull( + res[255].firstMatch( + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + 472); + assertNull(res[255].firstMatch("(this(and)that"), 473); + assertNull(res[255].firstMatch("(this(and)that)"), 474); + assertNull(res[255].firstMatch("(this(and)that)stuff"), 475); + assertNull(res[255].firstMatch("(this(and)that"), 476); + assertNull(res[255].firstMatch("(this(and)that)"), 477); + assertNull(res[255].firstMatch("(this(and)that"), 478); + assertNull(res[255].firstMatch("(this(and)that)"), 479); + assertNull(res[255].firstMatch("(this(and)that"), 480); + assertNull(res[255].firstMatch("(this(and)that)"), 481); + assertNull(res[255].firstMatch("((this))"), 482); + assertNull(res[255].firstMatch("(this(and)that"), 483); + assertNull(res[255].firstMatch("(this(and)that)"), 484); + assertNull(res[255].firstMatch("(this)"), 485); + assertNull(res[255].firstMatch("((this))"), 486); + assertToStringEquals("abc,b", res[256].firstMatch("abc"), 487); + assertToStringEquals("abc,b", res[256].firstMatch("abc"), 488); + assertNull(res[256].firstMatch("a1bCA"), 489); + assertNull(res[256].firstMatch("a2bCA"), 490); + assertNull(res[257].firstMatch("a bc dCACBCC"), 491); + assertNull(res[257].firstMatch("aabc"), 492); + assertNull(res[257].firstMatch("bc"), 493); + assertNull(res[257].firstMatch("** Failers"), 494); + assertNull(res[257].firstMatch("abc"), 495); + assertNull(res[257].firstMatch("bXaX"), 496); + assertNull(res[257].firstMatch("bbXaaX"), 497); + assertNull(res[257].firstMatch("(b)\\Xa\\X"), 498); + assertNull(res[257].firstMatch("bXXaYYaY"), 499); + assertNull(res[257].firstMatch("bXYaXXaX"), 500); + assertNull(res[257].firstMatch("bXXaYYaY"), 501); + assertToStringEquals("\x0b,\x0b", res[259].firstMatch("\x0b,\x0b"), 502); + assertToStringEquals("\x0c,\x0d", res[259].firstMatch("\x0c,\x0d"), 503); + assertToStringEquals("abc", res[260].firstMatch("xyz\nabc"), 504); + assertToStringEquals("abc", res[260].firstMatch("xyz\nabc"), 505); + assertToStringEquals("abc", res[260].firstMatch("xyz\x0d\nabc"), 506); + assertToStringEquals("abc", res[260].firstMatch("xyz\x0dabc"), 507); + assertToStringEquals("abc", res[260].firstMatch("xyz\x0d\nabc"), 508); + assertNull(res[260].firstMatch("** Failers"), 509); + assertToStringEquals("abc", res[260].firstMatch("xyz\nabc"), 510); + assertToStringEquals("abc", res[260].firstMatch("xyz\x0d\nabc"), 511); + assertToStringEquals("abc", res[260].firstMatch("xyz\nabc"), 512); + assertToStringEquals("abc", res[260].firstMatch("xyz\x0dabc"), 513); + assertToStringEquals("abc", res[260].firstMatch("xyz\x0dabc"), 514); + assertToStringEquals("abc", res[261].firstMatch("xyzabc"), 515); + assertToStringEquals("abc", res[261].firstMatch("xyzabc\n"), 516); + assertToStringEquals("abc", res[261].firstMatch("xyzabc\npqr"), 517); + assertToStringEquals("abc", res[261].firstMatch("xyzabc\x0d"), 518); + assertToStringEquals("abc", res[261].firstMatch("xyzabc\x0dpqr"), 519); + assertToStringEquals("abc", res[261].firstMatch("xyzabc\x0d\n"), 520); + assertToStringEquals( + "abc", res[261].firstMatch("xyzabc\x0d\npqr"), 521); + assertNull(res[261].firstMatch("** Failers"), 522); + assertToStringEquals("abc", res[261].firstMatch("xyzabc\x0d"), 523); + assertToStringEquals("abc", res[261].firstMatch("xyzabc\x0dpqr"), 524); + assertToStringEquals("abc", res[261].firstMatch("xyzabc\x0d\n"), 525); + assertToStringEquals("abc", res[261].firstMatch("xyzabc\x0d\npqr"), 526); + assertToStringEquals("abc", res[262].firstMatch("xyz\x0dabcdef"), 527); + assertToStringEquals("abc", res[262].firstMatch("xyz\nabcdef"), 528); + assertNull(res[262].firstMatch("** Failers"), 529); + assertToStringEquals("abc", res[262].firstMatch("xyz\nabcdef"), 530); + assertToStringEquals("abc", res[263].firstMatch("xyz\nabcdef"), 531); + assertToStringEquals("abc", res[263].firstMatch("xyz\x0dabcdef"), 532); + assertNull(res[263].firstMatch("** Failers"), 533); + assertToStringEquals("abc", res[263].firstMatch("xyz\x0dabcdef"), 534); + assertToStringEquals("abc", res[264].firstMatch("xyz\x0d\nabcdef"), 535); + assertToStringEquals("abc", res[264].firstMatch("xyz\x0dabcdef"), 536); + assertNull(res[264].firstMatch("** Failers"), 537); + assertToStringEquals("abc", res[264].firstMatch("xyz\x0dabcdef"), 538); + assertToStringEquals("abc", res[266].firstMatch("xyz\x0dabc"), 539); + assertToStringEquals("abc", res[266].firstMatch("abc"), 540); + assertToStringEquals("abc", res[267].firstMatch("abc\ndef"), 541); + assertToStringEquals("abc", res[267].firstMatch("abc\x0ddef"), 542); + assertToStringEquals("abc", res[267].firstMatch("abc\x0d\ndef"), 543); + assertToStringEquals("abc", res[267].firstMatch("abc\ndef"), 544); + assertToStringEquals("abc", res[267].firstMatch("abc\x0ddef"), 545); + assertToStringEquals("abc", res[267].firstMatch("abc\x0d\ndef"), 546); + assertToStringEquals("abc", res[267].firstMatch("abc\ndef"), 547); + assertToStringEquals( + "abc", res[267].firstMatch("abc\x0ddef"), 548); + assertToStringEquals( + "abc", res[267].firstMatch("abc\x0d\ndef"), 549); + assertNull(res[268].firstMatch("abc\ndef"), 550); + assertNull(res[268].firstMatch("abc\x0ddef"), 551); + assertNull(res[268].firstMatch("abc\x0d\ndef"), 552); + assertToStringEquals( + "XY,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,XY,Y", + res[269].firstMatch("XYO400"), + 553); + assertToStringEquals("aaaA5", res[278].firstMatch("aaaA5"), 554); + assertNull(res[278].firstMatch("** Failers"), 555); + assertNull(res[278].firstMatch("aaaa5"), 556); + assertToStringEquals("aaaA5", res[279].firstMatch("aaaA5"), 557); + assertToStringEquals("aaaa5", res[279].firstMatch("aaaa5"), 558); + assertToStringEquals("x", res[350].firstMatch("xyCabcCxyz"), 559); + assertToStringEquals("x", res[350].firstMatch("xyCabcCxyz"), 560); + assertToStringEquals("b", res[350].firstMatch("bXaX"), 561); + assertToStringEquals("b", res[350].firstMatch("bXbX"), 562); + assertToStringEquals("*", res[350].firstMatch("** Failers"), 563); + assertToStringEquals("aX", res[350].firstMatch("aXaX"), 564); + assertToStringEquals("aX", res[350].firstMatch("aXbX"), 565); + assertToStringEquals("x", res[350].firstMatch("xx"), 566); + assertToStringEquals("x", res[350].firstMatch("xy"), 567); + assertToStringEquals("y", res[350].firstMatch("yy"), 568); + assertToStringEquals("y", res[350].firstMatch("yx"), 569); + assertToStringEquals("x", res[350].firstMatch("xx"), 570); + assertToStringEquals("x", res[350].firstMatch("xy"), 571); + assertToStringEquals("y", res[350].firstMatch("yy"), 572); + assertToStringEquals("y", res[350].firstMatch("yx"), 573); + assertToStringEquals("b", res[350].firstMatch("bxay"), 574); + assertToStringEquals("b", res[350].firstMatch("bxby"), 575); + assertToStringEquals("*", res[350].firstMatch("** Failers"), 576); + assertToStringEquals("ax", res[350].firstMatch("axby"), 577); + assertToStringEquals("X", res[350].firstMatch("XxXxxx"), 578); + assertToStringEquals("X", res[350].firstMatch("XxXyyx"), 579); + assertToStringEquals("X", res[350].firstMatch("XxXyxx"), 580); + assertToStringEquals("*", res[350].firstMatch("** Failers"), 581); + assertToStringEquals("x", res[350].firstMatch("x"), 582); + assertToStringEquals("ab", res[350].firstMatch("abcabc"), 583); + assertToStringEquals("Xaaa,a", res[351].firstMatch("Xaaa"), 584); + assertToStringEquals("Xaba,a", res[351].firstMatch("Xaba"), 585); + assertThrows(() => new RegExp(r"^[a-\\Q\\E]"), 586); + assertNull(res[353].firstMatch("(xy)x"), 587); + assertNull(res[353].firstMatch("1221"), 588); + assertNull(res[353].firstMatch("Satan, oscillate my metallic sonatas!"), 589); + assertNull(res[353].firstMatch("A man, a plan, a canal: Panama!"), 590); + assertNull(res[353].firstMatch("Able was I ere I saw Elba."), 591); + assertNull(res[353].firstMatch("*** Failers"), 592); + assertNull(res[353].firstMatch("The quick brown fox"), 593); + assertToStringEquals("abcd:,abcd", res[354].firstMatch("abcd:"), 594); + assertToStringEquals("abcd:,abcd", res[354].firstMatch("abcd:"), 595); + assertToStringEquals("a:,a", res[354].firstMatch("a:aaxyz"), 596); + assertToStringEquals("ab:,ab", res[354].firstMatch("ab:ababxyz"), 597); + assertNull(res[354].firstMatch("** Failers"), 598); + assertToStringEquals("a:,a", res[354].firstMatch("a:axyz"), 599); + assertToStringEquals("ab:,ab", res[354].firstMatch("ab:abxyz"), 600); + assertNull(res[354].firstMatch("abd"), 601); + assertNull(res[354].firstMatch("ce"), 602); + assertNull(res[354].firstMatch("abcabc1Xabc2XabcXabcabc"), 603); + assertNull(res[354].firstMatch("abcabc1Xabc2XabcXabcabc"), 604); + assertNull(res[354].firstMatch("abcabc1Xabc2XabcXabcabc"), 605); + assertNull(res[354].firstMatch("abcd"), 606); + assertNull(res[354].firstMatch("metcalfe 33"), 607); + assertNull(res[356].firstMatch("a\x0db"), 608); + assertNull(res[356].firstMatch("a\nb"), 609); + assertToStringEquals("a\x85b", res[356].firstMatch("a\x85b "), 610); + assertNull(res[356].firstMatch("** Failers"), 611); + assertNull(res[356].firstMatch("a\nb"), 612); + assertNull(res[356].firstMatch("a\nb"), 613); + assertNull(res[356].firstMatch("a\x0db"), 614); + assertNull(res[356].firstMatch("a\x0db"), 615); + assertToStringEquals("a\x85b", res[356].firstMatch("a\x85b "), 616); + assertNull(res[356].firstMatch("a\x0db"), 617); + assertToStringEquals( + "abc1", + res[357].firstMatch( + "abc1 \nabc2 \x0babc3xx \x0cabc4 \x0dabc5xx \x0d\nabc6 \x85abc7 JUNK"), + 618); + assertToStringEquals( + "abc1", + res[358].firstMatch( + "abc1\n abc2\x0b abc3\x0c abc4\x0d abc5\x0d\n abc6\x85 abc7 abc9"), + 619); + assertNull(res[361].firstMatch("a\nb"), 620); + assertNull(res[361].firstMatch("a\x0db"), 621); + assertNull(res[361].firstMatch("a\x0d\nb"), 622); + assertNull(res[361].firstMatch("a\x0bb"), 623); + assertNull(res[361].firstMatch("a\x0cb"), 624); + assertNull(res[361].firstMatch("a\x85b"), 625); + assertNull(res[361].firstMatch("** Failers"), 626); + assertNull(res[361].firstMatch("a\n\x0db"), 627); + assertToStringEquals("ab", res[362].firstMatch("ab"), 628); + assertNull(res[362].firstMatch("a\nb"), 629); + assertNull(res[362].firstMatch("a\x0db"), 630); + assertNull(res[362].firstMatch("a\x0d\nb"), 631); + assertNull(res[362].firstMatch("a\x0bb"), 632); + assertNull(res[362].firstMatch("a\x0cb"), 633); + assertNull(res[362].firstMatch("a\x85b"), 634); + assertNull(res[362].firstMatch("a\n\x0db"), 635); + assertNull(res[362].firstMatch("a\n\x0d\x85\x0cb"), 636); + assertNull(res[363].firstMatch("a\nb"), 637); + assertNull(res[363].firstMatch("a\x0db"), 638); + assertNull(res[363].firstMatch("a\x0d\nb"), 639); + assertNull(res[363].firstMatch("a\x0bb"), 640); + assertNull(res[363].firstMatch("a\x0cb"), 641); + assertNull(res[363].firstMatch("a\x85b"), 642); + assertNull(res[363].firstMatch("a\n\x0db"), 643); + assertNull(res[363].firstMatch("a\n\x0d\x85\x0cb"), 644); + assertNull(res[363].firstMatch("** Failers"), 645); + assertNull(res[363].firstMatch("ab"), 646); + assertNull(res[364].firstMatch("a\nb"), 647); + assertNull(res[364].firstMatch("a\n\x0db"), 648); + assertNull(res[364].firstMatch("a\n\x0d\x85b"), 649); + assertNull(res[364].firstMatch("a\x0d\n\x0d\nb"), 650); + assertNull(res[364].firstMatch("a\x0d\n\x0d\n\x0d\nb"), 651); + assertNull(res[364].firstMatch("a\n\x0d\n\x0db"), 652); + assertNull(res[364].firstMatch("a\n\n\x0d\nb"), 653); + assertNull(res[364].firstMatch("** Failers"), 654); + assertNull(res[364].firstMatch("a\n\n\n\x0db"), 655); + assertNull(res[364].firstMatch("a\x0d"), 656); + assertToStringEquals("aRb", res[365].firstMatch("aRb"), 657); + assertNull(res[365].firstMatch("** Failers"), 658); + assertNull(res[365].firstMatch("a\nb"), 659); + assertNull(res[365].firstMatch("abcPXP123"), 660); + assertNull(res[365].firstMatch("abcPXP123"), 661); + assertNull(res[365].firstMatch("1.2.3.4"), 662); + assertNull(res[365].firstMatch("131.111.10.206"), 663); + assertNull(res[365].firstMatch("10.0.0.0"), 664); + assertNull(res[365].firstMatch("** Failers"), 665); + assertNull(res[365].firstMatch("10.6"), 666); + assertNull(res[365].firstMatch("455.3.4.5"), 667); + assertNull(res[365].firstMatch("1.2.3.4"), 668); + assertNull(res[365].firstMatch("131.111.10.206"), 669); + assertNull(res[365].firstMatch("10.0.0.0"), 670); + assertNull(res[365].firstMatch("** Failers"), 671); + assertNull(res[365].firstMatch("10.6"), 672); + assertNull(res[365].firstMatch("455.3.4.5"), 673); + assertNull(res[365].firstMatch("123axbaxbaxbx456"), 674); + assertNull(res[365].firstMatch("123axbaxbaxb456"), 675); + assertNull(res[365].firstMatch("123axbaxbaxbx456"), 676); + assertNull(res[365].firstMatch("123axbaxbaxbx456"), 677); + assertNull(res[365].firstMatch("123axbaxbaxbx456"), 678); + assertNull(res[366].firstMatch("ababababbbabZXXXX"), 679); + assertNull(res[372].firstMatch("a\x0db"), 680); + assertNull(res[372].firstMatch("*** Failers"), 681); + assertNull(res[372].firstMatch("a\nb"), 682); + assertToStringEquals("afoo", res[373].firstMatch("afoo"), 683); + assertNull(res[373].firstMatch("** Failers"), 684); + assertNull(res[373].firstMatch("\x0d\nfoo"), 685); + assertNull(res[373].firstMatch("\nfoo"), 686); + assertToStringEquals("afoo", res[374].firstMatch("afoo"), 687); + assertNull(res[374].firstMatch("\nfoo"), 688); + assertNull(res[374].firstMatch("** Failers"), 689); + assertNull(res[374].firstMatch("\x0d\nfoo"), 690); + assertToStringEquals("afoo", res[375].firstMatch("afoo"), 691); + assertNull(res[375].firstMatch("** Failers"), 692); + assertNull(res[375].firstMatch("\nfoo"), 693); + assertNull(res[375].firstMatch("\x0d\nfoo"), 694); + assertToStringEquals("afoo", res[376].firstMatch("afoo"), 695); + assertNull(res[376].firstMatch("\x0d\nfoo"), 696); + assertNull(res[376].firstMatch("\nfoo"), 697); + assertToStringEquals("", res[377].firstMatch("abc\x0d\x0dxyz"), 698); + assertToStringEquals("", res[377].firstMatch("abc\n\x0dxyz "), 699); + assertNull(res[377].firstMatch("** Failers "), 700); + assertToStringEquals("", res[377].firstMatch("abc\x0d\nxyz"), 701); + assertToStringEquals("", res[377].firstMatch("abc\x0d\n\x0d\n"), 702); + assertToStringEquals("", res[377].firstMatch("abc\x0d\n\x0d\n"), 703); + assertToStringEquals("", res[377].firstMatch("abc\x0d\n\x0d\n"), 704); + assertToStringEquals( + "abc1", + res[378].firstMatch( + "abc1\n abc2\x0b abc3\x0c abc4\x0d abc5\x0d\n abc6\x85 abc9"), + 705); + assertToStringEquals("X", res[379].firstMatch("XABC"), 706); + assertNull(res[379].firstMatch("** Failers "), 707); + assertToStringEquals("X", res[379].firstMatch("XABCB"), 708); + assertThrows(() => new RegExp(r"(ab|c)(?-1)"), 709); + assertNull(res[379].firstMatch("abc"), 710); + assertNull(res[379].firstMatch("xyabcabc"), 711); + assertNull(res[379].firstMatch("** Failers"), 712); + assertNull(res[379].firstMatch("xyabc "), 713); + assertThrows(() => new RegExp(r"x(?-0)y"), 714); + assertThrows(() => new RegExp(r"x(?-1)y"), 715); + assertNull(res[379].firstMatch("abcX"), 716); + assertNull(res[379].firstMatch("Y"), 717); + assertNull(res[379].firstMatch("** Failers"), 718); + assertNull(res[379].firstMatch("abcY "), 719); + assertNull(res[379].firstMatch("YabcXabc"), 720); + assertNull(res[379].firstMatch("YabcXabcXabc"), 721); + assertNull(res[379].firstMatch("** Failers"), 722); + assertToStringEquals("X", res[379].firstMatch("XabcXabc "), 723); + assertNull(res[379].firstMatch("Y!"), 724); + assertNull(res[380].firstMatch("foobar"), 725); + assertNull(res[381].firstMatch("foobar"), 726); + assertToStringEquals("foobaz,foo,baz", res[381].firstMatch("foobaz "), 727); + assertNull(res[382].firstMatch("foobarbaz"), 728); + assertNull(res[382].firstMatch("tom-tom"), 729); + assertNull(res[382].firstMatch("bon-bon "), 730); + assertNull(res[382].firstMatch("** Failers"), 731); + assertNull(res[382].firstMatch("tom-bon "), 732); + assertNull(res[382].firstMatch("tom-tom"), 733); + assertNull(res[382].firstMatch("bon-bon "), 734); + assertThrows(() => new RegExp(r"(?|(abc)|(xyz))"), 735); + assertThrows(() => new RegExp(r"(x)(?|(abc)|(xyz))(x)"), 736); + assertNull(res[383].firstMatch("xabcx"), 737); + assertNull(res[383].firstMatch("xxyzx "), 738); + assertThrows(() => new RegExp(r"(x)(?|(abc)(pqr)|(xyz))(x)"), 739); + assertNull(res[383].firstMatch("xabcpqrx"), 740); + assertNull(res[383].firstMatch("xxyzx "), 741); + assertThrows(() => new RegExp(r"(?|(abc)|(xyz))\1"), 742); + assertNull(res[383].firstMatch("abcabc"), 743); + assertNull(res[383].firstMatch("xyzxyz "), 744); + assertNull(res[383].firstMatch("** Failers"), 745); + assertNull(res[383].firstMatch("abcxyz"), 746); + assertNull(res[383].firstMatch("xyzabc "), 747); + assertNull(res[383].firstMatch("abcabc"), 748); + assertNull(res[383].firstMatch("xyzabc "), 749); + assertNull(res[383].firstMatch("** Failers "), 750); + assertNull(res[383].firstMatch("xyzxyz "), 751); + assertNull(res[384].firstMatch("X X\n"), 752); + assertNull(res[384].firstMatch("X\x09X\x0b"), 753); + assertNull(res[384].firstMatch("** Failers"), 754); + assertNull(res[384].firstMatch("\xa0 X\n "), 755); + assertNull(res[385].firstMatch("\x09 \xa0X\n\x0b\x0c\x0d\n"), 756); + assertNull(res[385].firstMatch("\x09 \xa0\n\x0b\x0c\x0d\n"), 757); + assertNull(res[385].firstMatch("\x09 \xa0\n\x0b\x0c"), 758); + assertNull(res[385].firstMatch("** Failers "), 759); + assertNull(res[385].firstMatch("\x09 \xa0\n\x0b"), 760); + assertNull(res[385].firstMatch(" "), 761); + assertNull(res[386].firstMatch("XY ABCDE"), 762); + assertNull(res[386].firstMatch("XY PQR ST "), 763); + assertNull(res[387].firstMatch("XY AB PQRS"), 764); + assertNull(res[388].firstMatch(">XNNNYZ"), 765); + assertNull(res[388].firstMatch("> X NYQZ"), 766); + assertNull(res[388].firstMatch("** Failers"), 767); + assertNull(res[388].firstMatch(">XYZ "), 768); + assertNull(res[388].firstMatch("> X NY Z"), 769); + assertNull(res[389].firstMatch(">XY\nZ\nA\x0bNN\x0c"), 770); + assertNull(res[389].firstMatch(">\n\x0dX\nY\n\x0bZZZ\nAAA\x0bNNN\x0c"), 771); + assertNull(res[390].firstMatch(">\x09<"), 772); + assertNull(res[391].firstMatch(">\x09 \xa0<"), 773); + assertNull(res[396].firstMatch("** Failers"), 774); + assertNull(res[396].firstMatch("XXXX"), 775); + assertNull(res[397].firstMatch("XXXX Y "), 776); + assertNull(res[419].firstMatch("aaaaaa"), 777); + assertNull(res[419].firstMatch("aaabccc"), 778); + assertNull(res[419].firstMatch("aaabccc"), 779); + assertNull(res[419].firstMatch("aaabccc"), 780); + assertNull(res[419].firstMatch("aaabcccaaabccc"), 781); + assertNull(res[419].firstMatch("aaaxxxxxx"), 782); + assertNull(res[419].firstMatch("aaa++++++ "), 783); + assertNull(res[419].firstMatch("bbbxxxxx"), 784); + assertNull(res[419].firstMatch("bbb+++++ "), 785); + assertNull(res[419].firstMatch("cccxxxx"), 786); + assertNull(res[419].firstMatch("ccc++++ "), 787); + assertNull(res[419].firstMatch("dddddddd "), 788); + assertNull(res[419].firstMatch("aaaxxxxxx"), 789); + assertNull(res[419].firstMatch("aaa++++++ "), 790); + assertNull(res[419].firstMatch("bbbxxxxx"), 791); + assertNull(res[419].firstMatch("bbb+++++ "), 792); + assertNull(res[419].firstMatch("cccxxxx"), 793); + assertNull(res[419].firstMatch("ccc++++ "), 794); + assertNull(res[419].firstMatch("dddddddd "), 795); + assertNull(res[419].firstMatch("aaabccc"), 796); + assertNull(res[419].firstMatch("ABX"), 797); + assertNull(res[419].firstMatch("AADE"), 798); + assertNull(res[419].firstMatch("ACDE"), 799); + assertNull(res[419].firstMatch("** Failers"), 800); + assertNull(res[419].firstMatch("AD "), 801); + assertNull(res[419].firstMatch(" "), 802); + assertNull(res[419].firstMatch("aaaaaa"), 803); + assertNull(res[419].firstMatch("aaabccc"), 804); + assertNull(res[419].firstMatch("aaabccc"), 805); + assertNull(res[419].firstMatch("aaabccc"), 806); + assertNull(res[419].firstMatch("aaabcccaaabccc"), 807); + assertNull(res[419].firstMatch("aaabccc"), 808); + assertNull(res[422].firstMatch("\x0d\nA"), 809); + assertToStringEquals("\nA", res[423].firstMatch("\x0d\nA "), 810); + assertToStringEquals("\nA", res[424].firstMatch("\x0d\nA "), 811); + assertToStringEquals("\nA,\n", res[425].firstMatch("\x0d\nA "), 812); + assertNull(res[425].firstMatch("a\nb"), 813); + assertNull(res[425].firstMatch("** Failers"), 814); + assertNull(res[425].firstMatch("a\x0db "), 815); + assertNull(res[425].firstMatch("a\nb"), 816); + assertNull(res[425].firstMatch("** Failers"), 817); + assertNull(res[425].firstMatch("a\x0db "), 818); + assertNull(res[425].firstMatch("a\x0db"), 819); + assertNull(res[425].firstMatch("** Failers"), 820); + assertNull(res[425].firstMatch("a\nb "), 821); + assertNull(res[425].firstMatch("a\x0db"), 822); + assertNull(res[425].firstMatch("a\nb "), 823); + assertNull(res[425].firstMatch("** Failers"), 824); + assertNull(res[425].firstMatch("a\x0d\nb "), 825); + assertNull(res[425].firstMatch("** Failers"), 826); + assertNull(res[425].firstMatch("a\x0db"), 827); + assertNull(res[425].firstMatch("a\nb "), 828); + assertNull(res[425].firstMatch("a\x0d\nb "), 829); + assertNull(res[425].firstMatch("** Failers"), 830); + assertNull(res[425].firstMatch("a\x0db"), 831); + assertNull(res[425].firstMatch("a\nb "), 832); + assertNull(res[425].firstMatch("a\x0d\nb "), 833); + assertNull(res[425].firstMatch("a\x85b "), 834); + assertNull(res[426].firstMatch("a\x0db"), 835); + assertNull(res[426].firstMatch("a\nb"), 836); + assertNull(res[426].firstMatch("a\x0d\nb"), 837); + assertNull(res[426].firstMatch("** Failers"), 838); + assertNull(res[426].firstMatch("a\x85b"), 839); + assertNull(res[426].firstMatch("a\x0bb "), 840); + assertNull(res[427].firstMatch("a\x0db"), 841); + assertNull(res[427].firstMatch("a\nb"), 842); + assertNull(res[427].firstMatch("a\x0d\nb"), 843); + assertNull(res[427].firstMatch("a\x85b"), 844); + assertNull(res[427].firstMatch("a\x0bb "), 845); + assertNull(res[427].firstMatch("** Failers "), 846); + assertNull(res[427].firstMatch("a\x85b"), 847); + assertNull(res[427].firstMatch("a\x0bb"), 848); + assertNull(res[428].firstMatch("a\x0db"), 849); + assertNull(res[428].firstMatch("a\nb"), 850); + assertNull(res[428].firstMatch("a\x0d\nb"), 851); + assertNull(res[428].firstMatch("** Failers"), 852); + assertNull(res[428].firstMatch("a\x85b"), 853); + assertNull(res[428].firstMatch("a\x0bb "), 854); + assertNull(res[429].firstMatch("a\x0db"), 855); + assertNull(res[429].firstMatch("a\nb"), 856); + assertNull(res[429].firstMatch("a\x0d\nb"), 857); + assertNull(res[429].firstMatch("a\x85b"), 858); + assertNull(res[429].firstMatch("a\x0bb "), 859); + assertNull(res[429].firstMatch("** Failers "), 860); + assertNull(res[429].firstMatch("a\x85b"), 861); + assertNull(res[429].firstMatch("a\x0bb"), 862); + assertNull(res[430].firstMatch("a\x0d\n\nb"), 863); + assertNull(res[430].firstMatch("a\n\x0d\x0db"), 864); + assertNull(res[430].firstMatch("a\x0d\n\x0d\n\x0d\n\x0d\nb"), 865); + assertNull(res[430].firstMatch("** Failers"), 866); + assertNull(res[430].firstMatch("a\x8585b"), 867); + assertNull(res[430].firstMatch("a\x0b\x00bb "), 868); + assertNull(res[431].firstMatch("a\x0d\x0db"), 869); + assertNull(res[431].firstMatch("a\n\n\nb"), 870); + assertNull(res[431].firstMatch("a\x0d\n\n\x0d\x0db"), 871); + assertNull(res[431].firstMatch("a\x8585b"), 872); + assertNull(res[431].firstMatch("a\x0b\x00bb "), 873); + assertNull(res[431].firstMatch("** Failers "), 874); + assertNull(res[431].firstMatch("a\x0d\x0d\x0d\x0d\x0db "), 875); + assertNull(res[431].firstMatch("a\x8585b"), 876); + assertNull(res[431].firstMatch("a\x0b\x00bb"), 877); + assertNull(res[431].firstMatch("a\nb"), 878); + assertNull(res[431].firstMatch("a\x0db "), 879); + assertNull(res[431].firstMatch("a\x85b"), 880); + assertNull(res[431].firstMatch("a\nb"), 881); + assertNull(res[431].firstMatch("a\x0db "), 882); + assertNull(res[431].firstMatch("a\x85b"), 883); + assertThrows(() => new RegExp(r"(?-+a)"), 884); + assertNull(res[443].firstMatch("aaaa"), 885); + assertNull(res[443].firstMatch("bacxxx"), 886); + assertNull(res[443].firstMatch("bbaccxxx "), 887); + assertNull(res[443].firstMatch("bbbacccxx"), 888); + assertNull(res[443].firstMatch("aaaa"), 889); + assertNull(res[443].firstMatch("bacxxx"), 890); + assertNull(res[443].firstMatch("bbaccxxx "), 891); + assertNull(res[443].firstMatch("bbbacccxx"), 892); + assertToStringEquals("a,a", res[444].firstMatch("aaaa"), 893); + assertNull(res[444].firstMatch("bacxxx"), 894); + assertNull(res[444].firstMatch("bbaccxxx "), 895); + assertNull(res[444].firstMatch("bbbacccxx"), 896); + assertToStringEquals("a,a", res[445].firstMatch("aaaa"), 897); + assertNull(res[445].firstMatch("bacxxx"), 898); + assertNull(res[445].firstMatch("bbaccxxx "), 899); + assertNull(res[445].firstMatch("bbbacccxx"), 900); + assertToStringEquals("a,a", res[446].firstMatch("aaaa"), 901); + assertNull(res[446].firstMatch("bacxxx"), 902); + assertNull(res[446].firstMatch("bbaccxxx "), 903); + assertNull(res[446].firstMatch("bbbacccxx"), 904); + assertToStringEquals("a,a,a", res[447].firstMatch("aaaa"), 905); + assertNull(res[447].firstMatch("bacxxx"), 906); + assertNull(res[447].firstMatch("bbaccxxx "), 907); + assertNull(res[447].firstMatch("bbbacccxx"), 908); + assertNull(res[449].firstMatch("bacxxx"), 909); + assertNull(res[449].firstMatch("XaaX"), 910); + assertNull(res[449].firstMatch("XAAX "), 911); + assertNull(res[449].firstMatch("XaaX"), 912); + assertNull(res[449].firstMatch("** Failers "), 913); + assertNull(res[449].firstMatch("XAAX "), 914); + assertNull(res[449].firstMatch("XaaX"), 915); + assertNull(res[449].firstMatch("XAAX "), 916); + assertNull(res[449].firstMatch("xzxx"), 917); + assertNull(res[449].firstMatch("yzyy "), 918); + assertNull(res[449].firstMatch("** Failers"), 919); + assertNull(res[449].firstMatch("xxz "), 920); + assertToStringEquals("a,,,a", res[450].firstMatch("cat"), 921); + assertToStringEquals("a,,,a", res[451].firstMatch("cat"), 922); + assertToStringEquals("TA]", res[452].firstMatch("The ACTA] comes "), 923); + assertToStringEquals("TA]", res[453].firstMatch("The ACTA] comes "), 924); + assertNull(res[453].firstMatch("abcbabc"), 925); + assertNull(res[453].firstMatch("abcbabc"), 926); + assertNull(res[453].firstMatch("abcbabc"), 927); + assertNull(res[453].firstMatch("** Failers "), 928); + assertNull(res[453].firstMatch("abcXabc"), 929); + assertNull(res[453].firstMatch("abcXabc"), 930); + assertNull(res[453].firstMatch("** Failers "), 931); + assertNull(res[453].firstMatch("abcbabc"), 932); + assertNull(res[453].firstMatch("xyzbabcxyz"), 933); + assertNull(res[456].firstMatch("** Failers"), 934); + assertNull(res[456].firstMatch("ab"), 935); + assertNull(res[457].firstMatch("** Failers"), 936); + assertNull(res[457].firstMatch("ab "), 937); + assertNull(res[457].firstMatch("** Failers"), 938); + assertNull(res[457].firstMatch("ab "), 939); + assertToStringEquals("aXb", res[458].firstMatch("aXb"), 940); + assertToStringEquals("a\nb", res[458].firstMatch("a\nb "), 941); + assertNull(res[458].firstMatch("** Failers"), 942); + assertNull(res[458].firstMatch("ab "), 943); + assertToStringEquals("aXb", res[459].firstMatch("aXb"), 944); + assertToStringEquals("a\nX\nXb", res[459].firstMatch("a\nX\nXb "), 945); + assertNull(res[459].firstMatch("** Failers"), 946); + assertNull(res[459].firstMatch("ab "), 947); + assertToStringEquals("acb", res[463].firstMatch("acb"), 948); + assertToStringEquals("ab", res[463].firstMatch("ab"), 949); + assertNull(res[463].firstMatch("ax{100}b "), 950); + assertNull(res[463].firstMatch("*** Failers"), 951); + assertNull(res[463].firstMatch("a\nb "), 952); + assertNull(res[464].firstMatch("ax{4000}xyb "), 953); + assertNull(res[464].firstMatch("ax{4000}yb "), 954); + assertNull(res[464].firstMatch("ax{4000}x{100}yb "), 955); + assertNull(res[464].firstMatch("*** Failers"), 956); + assertNull(res[464].firstMatch("ax{4000}b "), 957); + assertNull(res[464].firstMatch("ac\ncb "), 958); + assertToStringEquals("a\xc0,,\xc0", res[465].firstMatch("a\xc0\x88b"), 959); + assertToStringEquals("ax,,x", res[466].firstMatch("ax{100}b"), 960); + assertToStringEquals( + "a\xc0\x88b,\xc0\x88,b", res[467].firstMatch("a\xc0\x88b"), 961); + assertToStringEquals( + "ax{100}b,x{100},b", res[468].firstMatch("ax{100}b"), 962); + assertToStringEquals( + "a\xc0\x92,\xc0,\x92", res[469].firstMatch("a\xc0\x92bcd"), 963); + assertToStringEquals("ax{,x,{", res[470].firstMatch("ax{240}bcd"), 964); + assertToStringEquals( + "a\xc0\x92,\xc0,\x92", res[471].firstMatch("a\xc0\x92bcd"), 965); + assertToStringEquals("ax{,x,{", res[472].firstMatch("ax{240}bcd"), 966); + assertToStringEquals("a\xc0,,\xc0", res[473].firstMatch("a\xc0\x92bcd"), 967); + assertToStringEquals("ax,,x", res[474].firstMatch("ax{240}bcd"), 968); + assertNull(res[475].firstMatch("ax{1234}xyb "), 969); + assertNull(res[475].firstMatch("ax{1234}x{4321}yb "), 970); + assertNull(res[475].firstMatch("ax{1234}x{4321}x{3412}b "), 971); + assertNull(res[475].firstMatch("*** Failers"), 972); + assertNull(res[475].firstMatch("ax{1234}b "), 973); + assertNull(res[475].firstMatch("ac\ncb "), 974); + assertToStringEquals( + "ax{1234}xyb,x{1234}xy", res[476].firstMatch("ax{1234}xyb "), 975); + assertToStringEquals("ax{1234}x{4321}yb,x{1234}x{4321}y", + res[476].firstMatch("ax{1234}x{4321}yb "), 976); + assertToStringEquals("ax{1234}x{4321}x{3412}b,x{1234}x{4321}x{3412}", + res[476].firstMatch("ax{1234}x{4321}x{3412}b "), 977); + assertToStringEquals("axxxxbcdefghijb,xxxxbcdefghij", + res[476].firstMatch("axxxxbcdefghijb "), 978); + assertToStringEquals( + "ax{1234}x{4321}x{3412}x{3421}b,x{1234}x{4321}x{3412}x{3421}", + res[476].firstMatch("ax{1234}x{4321}x{3412}x{3421}b "), + 979); + assertNull(res[476].firstMatch("*** Failers"), 980); + assertToStringEquals( + "ax{1234}b,x{1234}", res[476].firstMatch("ax{1234}b "), 981); + assertToStringEquals( + "ax{1234}xyb,x{1234}xy", res[477].firstMatch("ax{1234}xyb "), 982); + assertToStringEquals("ax{1234}x{4321}yb,x{1234}x{4321}y", + res[477].firstMatch("ax{1234}x{4321}yb "), 983); + assertToStringEquals("ax{1234}x{4321}x{3412}b,x{1234}x{4321}x{3412}", + res[477].firstMatch("ax{1234}x{4321}x{3412}b "), 984); + assertToStringEquals( + "axxxxb,xxxx", res[477].firstMatch("axxxxbcdefghijb "), 985); + assertToStringEquals( + "ax{1234}x{4321}x{3412}x{3421}b,x{1234}x{4321}x{3412}x{3421}", + res[477].firstMatch("ax{1234}x{4321}x{3412}x{3421}b "), + 986); + assertNull(res[477].firstMatch("*** Failers"), 987); + assertToStringEquals( + "ax{1234}b,x{1234}", res[477].firstMatch("ax{1234}b "), 988); + assertNull(res[478].firstMatch("ax{1234}xyb "), 989); + assertNull(res[478].firstMatch("ax{1234}x{4321}yb "), 990); + assertNull(res[478].firstMatch("ax{1234}x{4321}x{3412}b "), 991); + assertToStringEquals( + "axxxxb,xxxx", res[478].firstMatch("axxxxbcdefghijb "), 992); + assertNull(res[478].firstMatch("ax{1234}x{4321}x{3412}x{3421}b "), 993); + assertToStringEquals( + "axbxxb,xbxx", res[478].firstMatch("axbxxbcdefghijb "), 994); + assertToStringEquals( + "axxxxxb,xxxxx", res[478].firstMatch("axxxxxbcdefghijb "), 995); + assertNull(res[478].firstMatch("*** Failers"), 996); + assertNull(res[478].firstMatch("ax{1234}b "), 997); + assertNull(res[478].firstMatch("axxxxxxbcdefghijb "), 998); + assertNull(res[479].firstMatch("ax{1234}xyb "), 999); + assertNull(res[479].firstMatch("ax{1234}x{4321}yb "), 1000); + assertNull(res[479].firstMatch("ax{1234}x{4321}x{3412}b "), 1001); + assertToStringEquals( + "axxxxb,xxxx", res[479].firstMatch("axxxxbcdefghijb "), 1002); + assertNull(res[479].firstMatch("ax{1234}x{4321}x{3412}x{3421}b "), 1003); + assertToStringEquals( + "axbxxb,xbxx", res[479].firstMatch("axbxxbcdefghijb "), 1004); + assertToStringEquals( + "axxxxxb,xxxxx", res[479].firstMatch("axxxxxbcdefghijb "), 1005); + assertNull(res[479].firstMatch("*** Failers"), 1006); + assertNull(res[479].firstMatch("ax{1234}b "), 1007); + assertNull(res[479].firstMatch("axxxxxxbcdefghijb "), 1008); + assertNull(res[479].firstMatch("*** Failers"), 1009); + assertNull(res[479].firstMatch("x{100}"), 1010); + assertNull(res[479].firstMatch("aXbcd"), 1011); + assertNull(res[479].firstMatch("ax{100}bcd"), 1012); + assertNull(res[479].firstMatch("ax{100000}bcd"), 1013); + assertNull(res[479].firstMatch("x{100}x{100}x{100}b"), 1014); + assertNull(res[479].firstMatch("*** Failers "), 1015); + assertNull(res[479].firstMatch("x{100}x{100}b"), 1016); + assertNull(res[479].firstMatch("x{ab} "), 1017); + assertNull(res[479].firstMatch("\xc2\xab"), 1018); + assertNull(res[479].firstMatch("*** Failers "), 1019); + assertNull(res[479].firstMatch("\x00{ab}"), 1020); + assertNull(res[479].firstMatch("WXYZ"), 1021); + assertNull(res[479].firstMatch("x{256}XYZ "), 1022); + assertNull(res[479].firstMatch("*** Failers"), 1023); + assertNull(res[479].firstMatch("XYZ "), 1024); + assertNull(res[480].firstMatch("Xx{1234}"), 1025); + assertNull(res[481].firstMatch("Xx{1234}YZ"), 1026); + assertToStringEquals("X", res[482].firstMatch("XYZabcdce"), 1027); + assertToStringEquals("X", res[483].firstMatch("XYZabcde"), 1028); + assertNull(res[484].firstMatch("Xabcdefg "), 1029); + assertNull(res[484].firstMatch("Xx{1234} "), 1030); + assertNull(res[484].firstMatch("Xx{1234}YZ"), 1031); + assertNull(res[484].firstMatch("Xx{1234}x{512} "), 1032); + assertNull(res[484].firstMatch("Xx{1234}x{512}YZ"), 1033); + assertNull(res[485].firstMatch("Xabcdefg "), 1034); + assertNull(res[485].firstMatch("Xx{1234} "), 1035); + assertNull(res[485].firstMatch("Xx{1234}YZ"), 1036); + assertNull(res[485].firstMatch("Xx{1234}x{512} "), 1037); + assertToStringEquals("bcd", res[486].firstMatch("bcd"), 1038); + assertToStringEquals("x{", res[487].firstMatch("x{100}bc"), 1040); + assertToStringEquals("x{100}bcA", res[488].firstMatch("x{100}bcAa"), 1041); + assertToStringEquals("x{", res[489].firstMatch("x{100}bca"), 1042); + assertToStringEquals("bcd", res[490].firstMatch("bcd"), 1043); + assertToStringEquals("x{", res[491].firstMatch("x{100}bc"), 1045); + assertToStringEquals("x{100}bc", res[492].firstMatch("x{100}bcAa"), 1046); + assertToStringEquals("x{", res[493].firstMatch("x{100}bca"), 1047); + assertNull(res[493].firstMatch("abcd"), 1048); + assertNull(res[493].firstMatch("abcd"), 1049); + assertToStringEquals("x{", res[493].firstMatch("x{100}x{100} "), 1050); + assertToStringEquals("x{", res[493].firstMatch("x{100}x{100} "), 1051); + assertToStringEquals( + "x{", res[493].firstMatch("x{100}x{100}x{100}x{100} "), 1052); + assertNull(res[493].firstMatch("abce"), 1053); + assertToStringEquals( + "x{", res[493].firstMatch("x{100}x{100}x{100}x{100} "), 1054); + assertNull(res[493].firstMatch("abcdx{100}x{100}x{100}x{100} "), 1055); + assertNull(res[493].firstMatch("abcdx{100}x{100}x{100}x{100} "), 1056); + assertNull(res[493].firstMatch("abcdx{100}x{100}x{100}x{100} "), 1057); + assertNull(res[493].firstMatch("abcdx{100}x{100}x{100}XX"), 1058); + assertNull( + res[493].firstMatch("abcdx{100}x{100}x{100}x{100}x{100}x{100}x{100}XX"), + 1059); + assertNull( + res[493].firstMatch("abcdx{100}x{100}x{100}x{100}x{100}x{100}x{100}XX"), + 1060); + assertToStringEquals( + "Xy", res[493].firstMatch("Xyyyax{100}x{100}bXzzz"), 1061); + assertToStringEquals("X", res[496].firstMatch("1X2"), 1062); + assertToStringEquals("x", res[496].firstMatch("1x{100}2 "), 1063); + assertToStringEquals(">X", res[497].firstMatch("> >X Y"), 1064); + assertToStringEquals(">x", res[497].firstMatch("> >x{100} Y"), 1065); + assertToStringEquals("1", res[498].firstMatch("x{100}3"), 1066); + assertToStringEquals(" ", res[499].firstMatch("x{100} X"), 1067); + assertToStringEquals("abcd", res[500].firstMatch("12abcd34"), 1068); + assertToStringEquals("*** Failers", res[500].firstMatch("*** Failers"), 1069); + assertToStringEquals(" ", res[500].firstMatch("1234 "), 1070); + assertToStringEquals("abc", res[501].firstMatch("12abcd34"), 1071); + assertToStringEquals("ab", res[501].firstMatch("12ab34"), 1072); + assertToStringEquals("***", res[501].firstMatch("*** Failers "), 1073); + assertNull(res[501].firstMatch("1234"), 1074); + assertToStringEquals(" ", res[501].firstMatch("12a34 "), 1075); + assertToStringEquals("ab", res[502].firstMatch("12abcd34"), 1076); + assertToStringEquals("ab", res[502].firstMatch("12ab34"), 1077); + assertToStringEquals("**", res[502].firstMatch("*** Failers "), 1078); + assertNull(res[502].firstMatch("1234"), 1079); + assertToStringEquals(" ", res[502].firstMatch("12a34 "), 1080); + assertToStringEquals("12", res[503].firstMatch("12abcd34"), 1081); + assertNull(res[503].firstMatch("*** Failers"), 1082); + assertToStringEquals("12", res[504].firstMatch("12abcd34"), 1083); + assertToStringEquals("123", res[504].firstMatch("1234abcd"), 1084); + assertNull(res[504].firstMatch("*** Failers "), 1085); + assertNull(res[504].firstMatch("1.4 "), 1086); + assertToStringEquals("12", res[505].firstMatch("12abcd34"), 1087); + assertToStringEquals("12", res[505].firstMatch("1234abcd"), 1088); + assertNull(res[505].firstMatch("*** Failers "), 1089); + assertNull(res[505].firstMatch("1.4 "), 1090); + assertToStringEquals("12abcd34", res[506].firstMatch("12abcd34"), 1091); + assertToStringEquals("***", res[506].firstMatch("*** Failers"), 1092); + assertNull(res[506].firstMatch(" "), 1093); + assertToStringEquals("12a", res[507].firstMatch("12abcd34"), 1094); + assertToStringEquals("123", res[507].firstMatch("1234abcd"), 1095); + assertToStringEquals("***", res[507].firstMatch("*** Failers"), 1096); + assertNull(res[507].firstMatch(" "), 1097); + assertToStringEquals("12", res[508].firstMatch("12abcd34"), 1098); + assertToStringEquals("12", res[508].firstMatch("1234abcd"), 1099); + assertToStringEquals("**", res[508].firstMatch("*** Failers"), 1100); + assertNull(res[508].firstMatch(" "), 1101); + assertToStringEquals("> <", res[509].firstMatch("12> <34"), 1102); + assertNull(res[509].firstMatch("*** Failers"), 1103); + assertToStringEquals("> <", res[510].firstMatch("ab> <", res[510].firstMatch("ab> <", res[511].firstMatch("ab> <", res[511].firstMatch("ab> \xff<"), 1186); + assertNull(res[521].firstMatch(">x{ff}<"), 1187); + assertToStringEquals("X", res[522].firstMatch("XYZ"), 1188); + assertToStringEquals("X", res[523].firstMatch("XYZ"), 1189); + assertToStringEquals("x", res[523].firstMatch("x{123} "), 1190); + assertToStringEquals(",", res[528].firstMatch("catac"), 1191); + assertToStringEquals(",", res[528].firstMatch("ax{256}a "), 1192); + assertToStringEquals(",", res[528].firstMatch("x{85}"), 1193); + assertToStringEquals(",", res[528].firstMatch("\u1234 "), 1194); + assertToStringEquals(",", res[528].firstMatch("\u1234 "), 1195); + assertToStringEquals(",", res[528].firstMatch("abcdefg"), 1196); + assertToStringEquals(",", res[528].firstMatch("ab"), 1197); + assertToStringEquals(",", res[528].firstMatch("a "), 1198); + assertToStringEquals("Ax", res[529].firstMatch("Ax{a3}BC"), 1199); + assertToStringEquals("Ax", res[530].firstMatch("Ax{a3}BC"), 1200); + assertToStringEquals("}=", res[531].firstMatch("+x{a3}== "), 1201); + assertToStringEquals("}=", res[532].firstMatch("+x{a3}== "), 1202); + assertToStringEquals( + "x", res[533].firstMatch("x{442}x{435}x{441}x{442}"), 1203); + assertToStringEquals( + "x", res[534].firstMatch("x{442}x{435}x{441}x{442}"), 1204); + assertToStringEquals( + "x", res[535].firstMatch("x{442}x{435}x{441}x{442}"), 1205); + assertToStringEquals( + "x", res[536].firstMatch("x{442}x{435}x{441}x{442}"), 1206); + assertToStringEquals( + "{", res[537].firstMatch("x{2442}x{2435}x{2441}x{2442}"), 1207); + assertToStringEquals( + "{", res[538].firstMatch("x{2442}x{2435}x{2441}x{2442}"), 1208); + assertToStringEquals("abc\n\x0dx{442}x{435}x{441}x{442}xyz ", + res[539].firstMatch("abc\n\x0dx{442}x{435}x{441}x{442}xyz "), 1209); + assertToStringEquals("x{442}x{435}x{441}x{442}", + res[539].firstMatch("x{442}x{435}x{441}x{442}"), 1210); + assertToStringEquals( + "c d", res[540].firstMatch("abc defx{442}x{443}xyz\npqr"), 1211); + assertToStringEquals( + "c d", res[541].firstMatch("abc defx{442}x{443}xyz\npqr"), 1212); + assertNull(res[542].firstMatch("+x{2442}"), 1213); + assertNull(res[543].firstMatch("+x{2442}"), 1214); + assertNull(res[544].firstMatch("Ax{442}"), 1215); + assertNull(res[545].firstMatch("Ax{442}"), 1216); + assertNull(res[546].firstMatch("Ax{442}"), 1217); + assertNull(res[547].firstMatch("Ax{442}"), 1218); + assertNull(res[548].firstMatch("\x19x{e01ff}"), 1219); + assertNull(res[549].firstMatch("Ax{422}"), 1220); + assertNull(res[550].firstMatch("x{19}x{e01ff}"), 1221); + assertNull(res[551].firstMatch("Ax{442}"), 1222); + assertNull(res[552].firstMatch("Ax{442}"), 1223); + assertNull(res[553].firstMatch("ax{442}"), 1224); + assertNull(res[554].firstMatch("+x{2442}"), 1225); + assertNull(res[555].firstMatch("Mx{442}"), 1226); + assertToStringEquals("abc", res[556].firstMatch("abc"), 1227); + assertToStringEquals("abc", res[557].firstMatch("abc"), 1228); + assertToStringEquals("abc", res[558].firstMatch("abc"), 1229); + assertToStringEquals("abc", res[559].firstMatch("abc"), 1230); + assertNull(res[560].firstMatch("x{100}ax{1234}bcd"), 1231); + assertNull(res[562].firstMatch("x{0041}x{2262}x{0391}x{002e}"), 1232); + assertNull(res[562].firstMatch("x{D55c}x{ad6d}x{C5B4} "), 1233); + assertNull(res[562].firstMatch("x{65e5}x{672c}x{8a9e}"), 1234); + assertToStringEquals( + "{861}X", res[563].firstMatch("x{212ab}x{212ab}x{212ab}x{861}X"), 1235); + assertToStringEquals( + "x{2", res[564].firstMatch("x{212ab}x{212ab}x{212ab}x{861}"), 1236); + assertToStringEquals("x{c", res[564].firstMatch("x{c0}b"), 1237); + assertToStringEquals("ax{", res[564].firstMatch("ax{c0}aaaa/ "), 1238); + assertToStringEquals("ax{", res[564].firstMatch("ax{c0}aaaa/ "), 1239); + assertToStringEquals("ax{", res[564].firstMatch("ax{c0}ax{c0}aaa/ "), 1240); + assertToStringEquals("ax{", res[564].firstMatch("ax{c0}aaaa/ "), 1241); + assertToStringEquals("ax{", res[564].firstMatch("ax{c0}ax{c0}aaa/ "), 1242); + assertToStringEquals("ax{", res[564].firstMatch("ax{c0}aaaa/ "), 1243); + assertToStringEquals("ax{", res[564].firstMatch("ax{c0}ax{c0}aaa/ "), 1244); + assertToStringEquals( + "Sho", res[564].firstMatch("Should produce an error diagnostic"), 1245); + assertNull(res[565].firstMatch("Xx{1234}"), 1246); + assertNull(res[565].firstMatch("X\nabc "), 1247); + assertToStringEquals("b", res[566].firstMatch("bar"), 1248); + assertNull(res[566].firstMatch("*** Failers"), 1249); + assertNull(res[566].firstMatch("c"), 1250); + assertNull(res[566].firstMatch("x{ff}"), 1251); + assertNull(res[566].firstMatch("x{100} "), 1252); + assertToStringEquals("c", res[567].firstMatch("c"), 1253); + assertToStringEquals("x", res[567].firstMatch("x{ff}"), 1254); + assertToStringEquals("x", res[567].firstMatch("x{100} "), 1255); + assertToStringEquals("*", res[567].firstMatch("*** Failers "), 1256); + assertNull(res[567].firstMatch("aaa"), 1257); + assertToStringEquals("x", res[568].firstMatch("x{f1}"), 1258); + assertToStringEquals("x", res[568].firstMatch("x{bf}"), 1259); + assertToStringEquals("x", res[568].firstMatch("x{100}"), 1260); + assertToStringEquals("x", res[568].firstMatch("x{1000} "), 1261); + assertToStringEquals("*", res[568].firstMatch("*** Failers"), 1262); + assertToStringEquals("x", res[568].firstMatch("x{c0} "), 1263); + assertToStringEquals("x", res[568].firstMatch("x{f0} "), 1264); + assertToStringEquals("1", res[568].firstMatch("1234"), 1265); + assertToStringEquals("\"", res[568].firstMatch("\"1234\" "), 1266); + assertToStringEquals("x", res[568].firstMatch("x{100}1234"), 1267); + assertToStringEquals("\"", res[568].firstMatch("\"x{100}1234\" "), 1268); + assertToStringEquals("x", res[568].firstMatch("x{100}x{100}12ab "), 1269); + assertToStringEquals("x", res[568].firstMatch("x{100}x{100}\"12\" "), 1270); + assertToStringEquals("*", res[568].firstMatch("*** Failers "), 1271); + assertToStringEquals("x", res[568].firstMatch("x{100}x{100}abcd"), 1272); + assertToStringEquals("A", res[568].firstMatch("A"), 1273); + assertToStringEquals("x", res[568].firstMatch("x{100}"), 1274); + assertToStringEquals("Z", res[568].firstMatch("Zx{100}"), 1275); + assertToStringEquals("x", res[568].firstMatch("x{100}Z"), 1276); + assertToStringEquals("*", res[568].firstMatch("*** Failers "), 1277); + assertToStringEquals("Z", res[568].firstMatch("Zx{100}"), 1278); + assertToStringEquals("x", res[568].firstMatch("x{100}"), 1279); + assertToStringEquals("x", res[568].firstMatch("x{100}Z"), 1280); + assertToStringEquals("*", res[568].firstMatch("*** Failers "), 1281); + assertToStringEquals("x", res[568].firstMatch("x{100}"), 1282); + assertToStringEquals("x", res[568].firstMatch("x{104}"), 1283); + assertToStringEquals("*", res[568].firstMatch("*** Failers"), 1284); + assertToStringEquals("x", res[568].firstMatch("x{105}"), 1285); + assertToStringEquals("x", res[568].firstMatch("x{ff} "), 1286); + assertToStringEquals("x", res[568].firstMatch("x{100}"), 1287); + assertToStringEquals("\u0100", res[568].firstMatch("\u0100 "), 1288); + assertToStringEquals("\xff", res[569].firstMatch(">\xff<"), 1289); + assertNull(res[570].firstMatch(">x{ff}<"), 1290); + assertToStringEquals( + "\xd6", res[572].firstMatch("\xd6 # Matches without Study"), 1291); + assertToStringEquals("x", res[572].firstMatch("x{d6}"), 1292); + assertToStringEquals( + "\xd6", res[572].firstMatch("\xd6 <-- Same with Study"), 1293); + assertToStringEquals("x", res[572].firstMatch("x{d6}"), 1294); + assertToStringEquals( + "\xd6", res[572].firstMatch("\xd6 # Matches without Study"), 1295); + assertToStringEquals("x", res[572].firstMatch("x{d6} "), 1296); + assertToStringEquals( + "\xd6", res[572].firstMatch("\xd6 <-- Same with Study"), 1297); + assertToStringEquals("x", res[572].firstMatch("x{d6} "), 1298); + assertToStringEquals("\ufffd", res[572].firstMatch("\ufffd]"), 1299); + assertToStringEquals("\ufffd", res[572].firstMatch("\ufffd"), 1300); + assertToStringEquals( + "\ufffd", res[572].firstMatch("\ufffd\ufffd\ufffd"), 1301); + assertToStringEquals( + "\ufffd", res[572].firstMatch("\ufffd\ufffd\ufffd?"), 1302); + assertNull(res[573].firstMatch("\xc0\x80"), 1303); + assertNull(res[573].firstMatch("\xc1\x8f "), 1304); + assertNull(res[573].firstMatch("\xe0\x9f\x80"), 1305); + assertNull(res[573].firstMatch("\xf0\x8f\x80\x80 "), 1306); + assertNull(res[573].firstMatch("\xf8\x87\x80\x80\x80 "), 1307); + assertNull(res[573].firstMatch("\xfc\x83\x80\x80\x80\x80"), 1308); + assertNull(res[573].firstMatch("\xfe\x80\x80\x80\x80\x80 "), 1309); + assertNull(res[573].firstMatch("\xff\x80\x80\x80\x80\x80 "), 1310); + assertNull(res[573].firstMatch("\xc3\x8f"), 1311); + assertNull(res[573].firstMatch("\xe0\xaf\x80"), 1312); + assertNull(res[573].firstMatch("\xe1\x80\x80"), 1313); + assertNull(res[573].firstMatch("\xf0\x9f\x80\x80 "), 1314); + assertNull(res[573].firstMatch("\xf1\x8f\x80\x80 "), 1315); + assertNull(res[573].firstMatch("\xf8\x88\x80\x80\x80 "), 1316); + assertNull(res[573].firstMatch("\xf9\x87\x80\x80\x80 "), 1317); + assertNull(res[573].firstMatch("\xfc\x84\x80\x80\x80\x80"), 1318); + assertNull(res[573].firstMatch("\xfd\x83\x80\x80\x80\x80"), 1319); + assertNull(res[573].firstMatch("?\xf8\x88\x80\x80\x80 "), 1320); + assertNull(res[573].firstMatch("?\xf9\x87\x80\x80\x80 "), 1321); + assertNull(res[573].firstMatch("?\xfc\x84\x80\x80\x80\x80"), 1322); + assertNull(res[573].firstMatch("?\xfd\x83\x80\x80\x80\x80"), 1323); + assertToStringEquals(".", res[574].firstMatch("A.B"), 1324); + assertToStringEquals("{", res[574].firstMatch("Ax{100}B "), 1325); + assertToStringEquals("x", res[575].firstMatch("x{100}X "), 1326); + assertToStringEquals("a", res[575].firstMatch("ax{1234}b"), 1327); + assertNull(res[577].firstMatch("AxxB "), 1328); + assertToStringEquals( + "abc1", + res[578].firstMatch( + "abc1 \nabc2 \x0babc3xx \x0cabc4 \x0dabc5xx \x0d\nabc6 x{0085}abc7 x{2028}abc8 x{2029}abc9 JUNK"), + 1329); + assertToStringEquals( + "abc1", + res[579].firstMatch( + "abc1\n abc2\x0b abc3\x0c abc4\x0d abc5\x0d\n abc6x{0085} abc7x{2028} abc8x{2029} abc9"), + 1330); + assertNull(res[580].firstMatch("a\nb"), 1331); + assertNull(res[580].firstMatch("a\x0db"), 1332); + assertNull(res[580].firstMatch("a\x0d\nb"), 1333); + assertNull(res[580].firstMatch("a\x0bb"), 1334); + assertNull(res[580].firstMatch("a\x0cb"), 1335); + assertNull(res[580].firstMatch("ax{85}b "), 1336); + assertNull(res[580].firstMatch("ax{2028}b "), 1337); + assertNull(res[580].firstMatch("ax{2029}b "), 1338); + assertNull(res[580].firstMatch("** Failers"), 1339); + assertNull(res[580].firstMatch("a\n\x0db "), 1340); + assertToStringEquals("ab", res[581].firstMatch("ab"), 1341); + assertNull(res[581].firstMatch("a\nb"), 1342); + assertNull(res[581].firstMatch("a\x0db"), 1343); + assertNull(res[581].firstMatch("a\x0d\nb"), 1344); + assertNull(res[581].firstMatch("a\x0bb"), 1345); + assertNull(res[581].firstMatch("a\x0cx{2028}x{2029}b"), 1346); + assertNull(res[581].firstMatch("ax{85}b "), 1347); + assertNull(res[581].firstMatch("a\n\x0db "), 1348); + assertNull(res[581].firstMatch("a\n\x0dx{85}\x0cb "), 1349); + assertNull(res[582].firstMatch("a\nb"), 1350); + assertNull(res[582].firstMatch("a\x0db"), 1351); + assertNull(res[582].firstMatch("a\x0d\nb"), 1352); + assertNull(res[582].firstMatch("a\x0bb"), 1353); + assertNull(res[582].firstMatch("a\x0cx{2028}x{2029}b"), 1354); + assertNull(res[582].firstMatch("ax{85}b "), 1355); + assertNull(res[582].firstMatch("a\n\x0db "), 1356); + assertNull(res[582].firstMatch("a\n\x0dx{85}\x0cb "), 1357); + assertNull(res[582].firstMatch("** Failers"), 1358); + assertNull(res[582].firstMatch("ab "), 1359); + assertNull(res[583].firstMatch("a\nb"), 1360); + assertNull(res[583].firstMatch("a\n\x0db"), 1361); + assertNull(res[583].firstMatch("a\n\x0dx{85}b"), 1362); + assertNull(res[583].firstMatch("a\x0d\n\x0d\nb "), 1363); + assertNull(res[583].firstMatch("a\x0d\n\x0d\n\x0d\nb "), 1364); + assertNull(res[583].firstMatch("a\n\x0d\n\x0db"), 1365); + assertNull(res[583].firstMatch("a\n\n\x0d\nb "), 1366); + assertNull(res[583].firstMatch("** Failers"), 1367); + assertNull(res[583].firstMatch("a\n\n\n\x0db"), 1368); + assertNull(res[583].firstMatch("a\x0d"), 1369); + assertNull(res[584].firstMatch("X X\n"), 1370); + assertNull(res[584].firstMatch("X\x09X\x0b"), 1371); + assertNull(res[584].firstMatch("** Failers"), 1372); + assertNull(res[584].firstMatch("x{a0} X\n "), 1373); + assertNull(res[585].firstMatch("\x09 x{a0}X\n\x0b\x0c\x0d\n"), 1374); + assertNull(res[585].firstMatch("\x09 x{a0}\n\x0b\x0c\x0d\n"), 1375); + assertNull(res[585].firstMatch("\x09 x{a0}\n\x0b\x0c"), 1376); + assertNull(res[585].firstMatch("** Failers "), 1377); + assertNull(res[585].firstMatch("\x09 x{a0}\n\x0b"), 1378); + assertNull(res[585].firstMatch(" "), 1379); + assertNull(res[586].firstMatch("x{3001}x{3000}x{2030}x{2028}"), 1380); + assertNull(res[586].firstMatch("Xx{180e}Xx{85}"), 1381); + assertNull(res[586].firstMatch("** Failers"), 1382); + assertNull(res[586].firstMatch("x{2009} X\n "), 1383); + assertNull( + res[587].firstMatch("x{1680}x{180e}x{2007}Xx{2028}x{2029}\x0c\x0d\n"), + 1384); + assertNull( + res[587].firstMatch("\x09x{205f}x{a0}\nx{2029}\x0cx{2028}\n"), 1385); + assertNull(res[587].firstMatch("\x09 x{202f}\n\x0b\x0c"), 1386); + assertNull(res[587].firstMatch("** Failers "), 1387); + assertNull(res[587].firstMatch("\x09x{200a}x{a0}x{2028}\x0b"), 1388); + assertNull(res[587].firstMatch(" "), 1389); + assertNull(res[588].firstMatch(">x{1680}"), 1390); + assertNull( + res[589].firstMatch( + ">x{1680}x{180e}x{2000}x{2003}x{200a}x{202f}x{205f}x{3000}<"), + 1391); + assertToStringEquals("x{1ec5} ", res[593].firstMatch("x{1ec5} "), 1392); + assertNull(res[594].firstMatch("x{0}x{d7ff}x{e000}x{10ffff}"), 1393); + assertNull(res[594].firstMatch("x{d800}"), 1394); + assertNull(res[594].firstMatch("x{d800}?"), 1395); + assertNull(res[594].firstMatch("x{da00}"), 1396); + assertNull(res[594].firstMatch("x{da00}?"), 1397); + assertNull(res[594].firstMatch("x{dfff}"), 1398); + assertNull(res[594].firstMatch("x{dfff}?"), 1399); + assertNull(res[594].firstMatch("x{110000} "), 1400); + assertNull(res[594].firstMatch("x{110000}? "), 1401); + assertNull(res[594].firstMatch("x{2000000} "), 1402); + assertNull(res[594].firstMatch("x{2000000}? "), 1403); + assertNull(res[594].firstMatch("x{7fffffff} "), 1404); + assertNull(res[594].firstMatch("x{7fffffff}? "), 1405); + assertNull(res[595].firstMatch("a\x0db"), 1406); + assertNull(res[595].firstMatch("a\nb"), 1407); + assertNull(res[595].firstMatch("a\x0d\nb"), 1408); + assertNull(res[595].firstMatch("** Failers"), 1409); + assertNull(res[595].firstMatch("ax{85}b"), 1410); + assertNull(res[595].firstMatch("a\x0bb "), 1411); + assertNull(res[596].firstMatch("a\x0db"), 1412); + assertNull(res[596].firstMatch("a\nb"), 1413); + assertNull(res[596].firstMatch("a\x0d\nb"), 1414); + assertNull(res[596].firstMatch("ax{85}b"), 1415); + assertNull(res[596].firstMatch("a\x0bb "), 1416); + assertNull(res[596].firstMatch("** Failers "), 1417); + assertNull(res[596].firstMatch("ax{85}b"), 1418); + assertNull(res[596].firstMatch("a\x0bb"), 1419); + assertNull(res[597].firstMatch("a\x0db"), 1420); + assertNull(res[597].firstMatch("a\nb"), 1421); + assertNull(res[597].firstMatch("a\x0d\nb"), 1422); + assertNull(res[597].firstMatch("** Failers"), 1423); + assertNull(res[597].firstMatch("ax{85}b"), 1424); + assertNull(res[597].firstMatch("a\x0bb "), 1425); + assertNull(res[598].firstMatch("a\x0db"), 1426); + assertNull(res[598].firstMatch("a\nb"), 1427); + assertNull(res[598].firstMatch("a\x0d\nb"), 1428); + assertNull(res[598].firstMatch("ax{85}b"), 1429); + assertNull(res[598].firstMatch("a\x0bb "), 1430); + assertNull(res[598].firstMatch("** Failers "), 1431); + assertNull(res[598].firstMatch("ax{85}b"), 1432); + assertNull(res[598].firstMatch("a\x0bb"), 1433); + assertToStringEquals("QQQx{2029}ABCaXYZ=!bPQR", + res[599].firstMatch("QQQx{2029}ABCaXYZ=!bPQR"), 1434); + assertNull(res[599].firstMatch("** Failers"), 1435); + assertNull(res[599].firstMatch("ax{2029}b"), 1436); + assertNull(res[599].firstMatch("a\xe2\x80\xa9b "), 1437); + assertNull(res[600].firstMatch("ax{1234}b"), 1438); + assertToStringEquals("a\nb", res[600].firstMatch("a\nb "), 1439); + assertNull(res[600].firstMatch("** Failers"), 1440); + assertNull(res[600].firstMatch("ab "), 1441); + assertToStringEquals("aXb", res[601].firstMatch("aXb"), 1442); + assertToStringEquals( + "a\nX\nXx{1234}b", res[601].firstMatch("a\nX\nXx{1234}b "), 1443); + assertNull(res[601].firstMatch("** Failers"), 1444); + assertNull(res[601].firstMatch("ab "), 1445); + assertNull(res[601].firstMatch("x{de}x{de}"), 1446); + assertNull(res[601].firstMatch("x{123} "), 1447); + assertToStringEquals("X", res[602].firstMatch("Ax{1ec5}ABCXYZ"), 1448); + assertNull( + res[604].firstMatch("x{c0}x{30f}x{660}x{66c}x{f01}x{1680}<"), 1449); + assertNull(res[604].firstMatch("\npx{300}9!\$ < "), 1450); + assertNull(res[604].firstMatch("** Failers "), 1451); + assertNull(res[604].firstMatch("apx{300}9!\$ < "), 1452); + assertNull(res[605].firstMatch("X"), 1453); + assertNull(res[605].firstMatch("** Failers "), 1454); + assertNull(res[605].firstMatch(""), 1455); + assertNull(res[606].firstMatch("9"), 1456); + assertNull(res[606].firstMatch("** Failers "), 1457); + assertNull(res[606].firstMatch("x{c0}"), 1458); + assertNull(res[607].firstMatch("X"), 1459); + assertNull(res[607].firstMatch("** Failers "), 1460); + assertNull(res[607].firstMatch("x{30f}"), 1461); + assertNull(res[608].firstMatch("X"), 1462); + assertNull(res[608].firstMatch("** Failers "), 1463); + assertNull(res[608].firstMatch("x{660}"), 1464); + assertNull(res[609].firstMatch("X"), 1465); + assertNull(res[609].firstMatch("** Failers "), 1466); + assertNull(res[609].firstMatch("x{66c}"), 1467); + assertNull(res[610].firstMatch("X"), 1468); + assertNull(res[610].firstMatch("** Failers "), 1469); + assertNull(res[610].firstMatch("x{f01}"), 1470); + assertNull(res[611].firstMatch("X"), 1471); + assertNull(res[611].firstMatch("** Failers "), 1472); + assertNull(res[611].firstMatch("x{1680}"), 1473); + assertNull(res[612].firstMatch("x{017}"), 1474); + assertNull(res[612].firstMatch("x{09f} "), 1475); + assertNull(res[612].firstMatch("** Failers"), 1476); + assertNull(res[612].firstMatch("x{0600} "), 1477); + assertNull(res[613].firstMatch("x{601}"), 1478); + assertNull(res[613].firstMatch("** Failers"), 1479); + assertNull(res[613].firstMatch("x{09f} "), 1480); + assertNull(res[614].firstMatch("x{e0000}"), 1481); + assertNull(res[614].firstMatch("** Failers"), 1482); + assertNull(res[614].firstMatch("x{09f} "), 1483); + assertNull(res[615].firstMatch("x{f8ff}"), 1484); + assertNull(res[615].firstMatch("** Failers"), 1485); + assertNull(res[615].firstMatch("x{09f} "), 1486); + assertNull(res[616].firstMatch("?x{dfff}"), 1487); + assertNull(res[616].firstMatch("** Failers"), 1488); + assertNull(res[616].firstMatch("x{09f} "), 1489); + assertNull(res[617].firstMatch("a"), 1490); + assertNull(res[617].firstMatch("** Failers "), 1491); + assertNull(res[617].firstMatch("Z"), 1492); + assertNull(res[617].firstMatch("x{e000} "), 1493); + assertNull(res[618].firstMatch("x{2b0}"), 1494); + assertNull(res[618].firstMatch("** Failers"), 1495); + assertNull(res[618].firstMatch("a "), 1496); + assertNull(res[619].firstMatch("x{1bb}"), 1497); + assertNull(res[619].firstMatch("x{3400}"), 1498); + assertNull(res[619].firstMatch("x{3401}"), 1499); + assertNull(res[619].firstMatch("x{4d00}"), 1500); + assertNull(res[619].firstMatch("x{4db4}"), 1501); + assertNull(res[619].firstMatch("x{4db5} "), 1502); + assertNull(res[619].firstMatch("** Failers"), 1503); + assertNull(res[619].firstMatch("a "), 1504); + assertNull(res[619].firstMatch("x{2b0}"), 1505); + assertNull(res[619].firstMatch("x{4db6} "), 1506); + assertNull(res[620].firstMatch("x{1c5}"), 1507); + assertNull(res[620].firstMatch("** Failers"), 1508); + assertNull(res[620].firstMatch("a "), 1509); + assertNull(res[620].firstMatch("x{2b0}"), 1510); + assertNull(res[621].firstMatch("A"), 1511); + assertNull(res[621].firstMatch("** Failers"), 1512); + assertNull(res[621].firstMatch("x{2b0}"), 1513); + assertNull(res[622].firstMatch("x{903}"), 1514); + assertNull(res[622].firstMatch("** Failers"), 1515); + assertNull(res[622].firstMatch("X"), 1516); + assertNull(res[622].firstMatch("x{300}"), 1517); + assertNull(res[622].firstMatch(" "), 1518); + assertNull(res[623].firstMatch("x{488}"), 1519); + assertNull(res[623].firstMatch("** Failers"), 1520); + assertNull(res[623].firstMatch("X"), 1521); + assertNull(res[623].firstMatch("x{903}"), 1522); + assertNull(res[623].firstMatch("x{300}"), 1523); + assertNull(res[624].firstMatch("x{300}"), 1524); + assertNull(res[624].firstMatch("** Failers"), 1525); + assertNull(res[624].firstMatch("X"), 1526); + assertNull(res[624].firstMatch("x{903}"), 1527); + assertNull( + res[624].firstMatch( + "0123456789x{660}x{661}x{662}x{663}x{664}x{665}x{666}x{667}x{668}x{669}x{66a}"), + 1528); + assertNull( + res[624].firstMatch( + "x{6f0}x{6f1}x{6f2}x{6f3}x{6f4}x{6f5}x{6f6}x{6f7}x{6f8}x{6f9}x{6fa}"), + 1529); + assertNull( + res[624].firstMatch( + "x{966}x{967}x{968}x{969}x{96a}x{96b}x{96c}x{96d}x{96e}x{96f}x{970}"), + 1530); + assertNull(res[624].firstMatch("** Failers"), 1531); + assertNull(res[624].firstMatch("X"), 1532); + assertNull(res[625].firstMatch("x{16ee}"), 1533); + assertNull(res[625].firstMatch("** Failers"), 1534); + assertNull(res[625].firstMatch("X"), 1535); + assertNull(res[625].firstMatch("x{966}"), 1536); + assertNull(res[626].firstMatch("x{b2}"), 1537); + assertNull(res[626].firstMatch("x{b3}"), 1538); + assertNull(res[626].firstMatch("** Failers"), 1539); + assertNull(res[626].firstMatch("X"), 1540); + assertNull(res[626].firstMatch("x{16ee}"), 1541); + assertNull(res[627].firstMatch("_"), 1542); + assertNull(res[627].firstMatch("x{203f}"), 1543); + assertNull(res[627].firstMatch("** Failers"), 1544); + assertNull(res[627].firstMatch("X"), 1545); + assertNull(res[627].firstMatch("-"), 1546); + assertNull(res[627].firstMatch("x{58a}"), 1547); + assertNull(res[628].firstMatch("-"), 1548); + assertNull(res[628].firstMatch("x{58a}"), 1549); + assertNull(res[628].firstMatch("** Failers"), 1550); + assertNull(res[628].firstMatch("X"), 1551); + assertNull(res[628].firstMatch("x{203f}"), 1552); + assertNull(res[629].firstMatch(")"), 1553); + assertNull(res[629].firstMatch("]"), 1554); + assertNull(res[629].firstMatch("}"), 1555); + assertNull(res[629].firstMatch("x{f3b}"), 1556); + assertNull(res[629].firstMatch("** Failers"), 1557); + assertNull(res[629].firstMatch("X"), 1558); + assertNull(res[629].firstMatch("x{203f}"), 1559); + assertNull(res[629].firstMatch("("), 1560); + assertNull(res[629].firstMatch("["), 1561); + assertNull(res[629].firstMatch("{"), 1562); + assertNull(res[629].firstMatch("x{f3c}"), 1563); + assertNull(res[630].firstMatch("x{bb}"), 1564); + assertNull(res[630].firstMatch("x{2019}"), 1565); + assertNull(res[630].firstMatch("** Failers"), 1566); + assertNull(res[630].firstMatch("X"), 1567); + assertNull(res[630].firstMatch("x{203f}"), 1568); + assertNull(res[631].firstMatch("x{ab}"), 1569); + assertNull(res[631].firstMatch("x{2018}"), 1570); + assertNull(res[631].firstMatch("** Failers"), 1571); + assertNull(res[631].firstMatch("X"), 1572); + assertNull(res[631].firstMatch("x{203f}"), 1573); + assertNull(res[632].firstMatch("!"), 1574); + assertNull(res[632].firstMatch("x{37e}"), 1575); + assertNull(res[632].firstMatch("** Failers"), 1576); + assertNull(res[632].firstMatch("X"), 1577); + assertNull(res[632].firstMatch("x{203f}"), 1578); + assertNull(res[633].firstMatch("("), 1579); + assertNull(res[633].firstMatch("["), 1580); + assertNull(res[633].firstMatch("{"), 1581); + assertNull(res[633].firstMatch("x{f3c}"), 1582); + assertNull(res[633].firstMatch("** Failers"), 1583); + assertNull(res[633].firstMatch("X"), 1584); + assertNull(res[633].firstMatch(")"), 1585); + assertNull(res[633].firstMatch("]"), 1586); + assertNull(res[633].firstMatch("}"), 1587); + assertNull(res[633].firstMatch("x{f3b}"), 1588); + assertNull(res[633].firstMatch("\$x{a2}x{a3}x{a4}x{a5}x{a6}"), 1589); + assertNull(res[633].firstMatch("x{9f2}"), 1590); + assertNull(res[633].firstMatch("** Failers"), 1591); + assertNull(res[633].firstMatch("X"), 1592); + assertNull(res[633].firstMatch("x{2c2}"), 1593); + assertNull(res[634].firstMatch("x{2c2}"), 1594); + assertNull(res[634].firstMatch("** Failers"), 1595); + assertNull(res[634].firstMatch("X"), 1596); + assertNull(res[634].firstMatch("x{9f2}"), 1597); + assertNull(res[634].firstMatch("+<|~x{ac}x{2044}"), 1598); + assertNull(res[634].firstMatch("** Failers"), 1599); + assertNull(res[634].firstMatch("X"), 1600); + assertNull(res[634].firstMatch("x{9f2}"), 1601); + assertNull(res[635].firstMatch("x{a6}"), 1602); + assertNull(res[635].firstMatch("x{482} "), 1603); + assertNull(res[635].firstMatch("** Failers"), 1604); + assertNull(res[635].firstMatch("X"), 1605); + assertNull(res[635].firstMatch("x{9f2}"), 1606); + assertNull(res[636].firstMatch("x{2028}"), 1607); + assertNull(res[636].firstMatch("** Failers"), 1608); + assertNull(res[636].firstMatch("X"), 1609); + assertNull(res[636].firstMatch("x{2029}"), 1610); + assertNull(res[637].firstMatch("x{2029}"), 1611); + assertNull(res[637].firstMatch("** Failers"), 1612); + assertNull(res[637].firstMatch("X"), 1613); + assertNull(res[637].firstMatch("x{2028}"), 1614); + assertNull(res[638].firstMatch("\\ \\"), 1615); + assertNull(res[638].firstMatch("x{a0}"), 1616); + assertNull(res[638].firstMatch("x{1680}"), 1617); + assertNull(res[638].firstMatch("x{180e}"), 1618); + assertNull(res[638].firstMatch("x{2000}"), 1619); + assertNull(res[638].firstMatch("x{2001} "), 1620); + assertNull(res[638].firstMatch("** Failers"), 1621); + assertNull(res[638].firstMatch("x{2028}"), 1622); + assertNull(res[638].firstMatch("x{200d} "), 1623); + assertNull(res[638].firstMatch(" x{660}x{661}x{662}ABC"), 1624); + assertNull(res[638].firstMatch(" x{660}x{661}x{662}ABC"), 1625); + assertNull(res[639].firstMatch(" x{660}x{661}x{662}ABC"), 1626); + assertNull(res[640].firstMatch(" x{660}x{661}x{662}ABC"), 1627); + assertNull(res[641].firstMatch(" x{660}x{661}x{662}ABC"), 1628); + assertNull(res[642].firstMatch(" x{660}x{661}x{662}ABC"), 1629); + assertNull(res[643].firstMatch(" x{660}x{661}x{662}ABC"), 1630); + assertNull(res[644].firstMatch(" x{660}x{661}x{662}ABC"), 1631); + assertNull(res[645].firstMatch(" x{660}x{661}x{662}ABC"), 1632); + assertNull(res[646].firstMatch(" x{660}x{661}x{662}ABC"), 1633); + assertNull(res[647].firstMatch(" x{660}x{661}x{662}ABC"), 1634); + assertNull(res[647].firstMatch(" x{660}x{661}x{662}ABC"), 1635); + assertNull(res[647].firstMatch(" x{660}x{661}x{662}ABC"), 1636); + assertNull(res[647].firstMatch(" ** Failers"), 1637); + assertNull(res[647].firstMatch(" x{660}x{661}x{662}ABC"), 1638); + assertNull(res[648].firstMatch("A"), 1639); + assertNull(res[648].firstMatch("ax{10a0}B "), 1640); + assertNull(res[648].firstMatch("** Failers "), 1641); + assertNull(res[648].firstMatch("a"), 1642); + assertNull(res[648].firstMatch("x{1d00} "), 1643); + assertNull(res[649].firstMatch("1234"), 1644); + assertNull(res[649].firstMatch("** Failers"), 1645); + assertNull(res[649].firstMatch("ABC "), 1646); + assertNull(res[650].firstMatch("1234"), 1647); + assertNull(res[650].firstMatch("** Failers"), 1648); + assertNull(res[650].firstMatch("ABC "), 1649); + assertNull(res[650].firstMatch("A2XYZ"), 1650); + assertNull(res[650].firstMatch("123A5XYZPQR"), 1651); + assertNull(res[650].firstMatch("ABAx{660}XYZpqr"), 1652); + assertNull(res[650].firstMatch("** Failers"), 1653); + assertNull(res[650].firstMatch("AXYZ"), 1654); + assertNull(res[650].firstMatch("XYZ "), 1655); + assertNull(res[650].firstMatch("1XYZ"), 1656); + assertNull(res[650].firstMatch("AB=XYZ.. "), 1657); + assertNull(res[650].firstMatch("XYZ "), 1658); + assertNull(res[650].firstMatch("** Failers"), 1659); + assertNull(res[650].firstMatch("WXYZ "), 1660); + assertNull(res[655].firstMatch("1234"), 1661); + assertNull(res[655].firstMatch("1234"), 1662); + assertNull(res[655].firstMatch("12-34"), 1663); + assertToStringEquals("{", res[655].firstMatch("12+x{661}-34 "), 1664); + assertNull(res[655].firstMatch("** Failers"), 1665); + assertToStringEquals("d", res[655].firstMatch("abcd "), 1666); + assertToStringEquals("d", res[656].firstMatch("abcd"), 1667); + assertNull(res[656].firstMatch("** Failers"), 1668); + assertNull(res[656].firstMatch("1234"), 1669); + assertNull( + res[657].firstMatch( + "11111111111111111111111111111111111111111111111111111111111111111111111"), + 1670); + assertToStringEquals( + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + res[657].firstMatch( + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + 1671); + assertToStringEquals(" ", res[657].firstMatch(" "), 1672); + assertNull( + res[657].firstMatch( + "11111111111111111111111111111111111111111111111111111111111111111111111"), + 1673); + assertToStringEquals( + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + res[657].firstMatch( + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + 1674); + assertNull( + res[658].firstMatch( + "11111111111111111111111111111111111111111111111111111111111111111111111"), + 1675); + assertToStringEquals( + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + res[658].firstMatch( + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + 1676); + assertNull( + res[659].firstMatch( + "11111111111111111111111111111111111111111111111111111111111111111111111"), + 1677); + assertNull( + res[659].firstMatch( + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + 1678); + assertNull( + res[660].firstMatch( + "11111111111111111111111111111111111111111111111111111111111111111111111"), + 1679); + assertToStringEquals( + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + res[660].firstMatch( + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + 1680); + assertNull(res[661].firstMatch("a"), 1681); + assertNull(res[661].firstMatch("A "), 1682); + assertNull(res[662].firstMatch("a"), 1683); + assertNull(res[662].firstMatch("A "), 1684); + assertNull(res[663].firstMatch("A"), 1685); + assertNull(res[663].firstMatch("aZ"), 1686); + assertNull(res[663].firstMatch("** Failers"), 1687); + assertNull(res[663].firstMatch("abc "), 1688); + assertNull(res[664].firstMatch("A"), 1689); + assertNull(res[664].firstMatch("aZ"), 1690); + assertNull(res[664].firstMatch("** Failers"), 1691); + assertNull(res[664].firstMatch("abc "), 1692); + assertNull(res[665].firstMatch("a"), 1693); + assertNull(res[665].firstMatch("Az"), 1694); + assertNull(res[665].firstMatch("** Failers"), 1695); + assertNull(res[665].firstMatch("ABC "), 1696); + assertNull(res[666].firstMatch("a"), 1697); + assertNull(res[666].firstMatch("Az"), 1698); + assertNull(res[666].firstMatch("** Failers"), 1699); + assertNull(res[666].firstMatch("ABC "), 1700); + assertNull(res[666].firstMatch("x{c0}"), 1701); + assertNull(res[666].firstMatch("x{e0} "), 1702); + assertNull(res[666].firstMatch("x{c0}"), 1703); + assertNull(res[666].firstMatch("x{e0} "), 1704); + assertNull(res[666].firstMatch("Ax{391}x{10427}x{ff3a}x{1fb0}"), 1705); + assertNull(res[666].firstMatch("** Failers"), 1706); + assertNull(res[666].firstMatch("ax{391}x{10427}x{ff3a}x{1fb0} "), 1707); + assertNull(res[666].firstMatch("Ax{3b1}x{10427}x{ff3a}x{1fb0}"), 1708); + assertNull(res[666].firstMatch("Ax{391}x{1044F}x{ff3a}x{1fb0}"), 1709); + assertNull(res[666].firstMatch("Ax{391}x{10427}x{ff5a}x{1fb0}"), 1710); + assertNull(res[666].firstMatch("Ax{391}x{10427}x{ff3a}x{1fb8}"), 1711); + assertNull(res[666].firstMatch("Ax{391}x{10427}x{ff3a}x{1fb0}"), 1712); + assertNull(res[666].firstMatch("ax{391}x{10427}x{ff3a}x{1fb0} "), 1713); + assertNull(res[666].firstMatch("Ax{3b1}x{10427}x{ff3a}x{1fb0}"), 1714); + assertNull(res[666].firstMatch("Ax{391}x{1044F}x{ff3a}x{1fb0}"), 1715); + assertNull(res[666].firstMatch("Ax{391}x{10427}x{ff5a}x{1fb0}"), 1716); + assertNull(res[666].firstMatch("Ax{391}x{10427}x{ff3a}x{1fb8}"), 1717); + assertNull(res[666].firstMatch("x{391}x{3b1}x{3b1}x{3b1}x{391}"), 1718); + assertNull(res[666].firstMatch("x{391}x{3b1}x{3b1}x{3b1}x{391}X"), 1719); + assertNull(res[666].firstMatch("x{391}x{3b1}x{3b1}x{3b1}x{391}X"), 1720); + assertNull(res[666].firstMatch("x{391}"), 1721); + assertNull(res[666].firstMatch("x{ff3a}"), 1722); + assertNull(res[666].firstMatch("x{3b1}"), 1723); + assertNull(res[666].firstMatch("x{ff5a} "), 1724); + assertNull(res[666].firstMatch("x{c0}"), 1725); + assertNull(res[666].firstMatch("x{e0} "), 1726); + assertNull(res[666].firstMatch("x{104}"), 1727); + assertNull(res[666].firstMatch("x{105}"), 1728); + assertNull(res[666].firstMatch("x{109} "), 1729); + assertNull(res[666].firstMatch("** Failers"), 1730); + assertNull(res[666].firstMatch("x{100}"), 1731); + assertNull(res[666].firstMatch("x{10a} "), 1732); + assertNull(res[666].firstMatch("Z"), 1733); + assertNull(res[666].firstMatch("z"), 1734); + assertNull(res[666].firstMatch("x{39c}"), 1735); + assertNull(res[666].firstMatch("x{178}"), 1736); + assertNull(res[666].firstMatch("|"), 1737); + assertNull(res[666].firstMatch("x{80}"), 1738); + assertNull(res[666].firstMatch("x{ff}"), 1739); + assertNull(res[666].firstMatch("x{100}"), 1740); + assertNull(res[666].firstMatch("x{101} "), 1741); + assertNull(res[666].firstMatch("** Failers"), 1742); + assertNull(res[666].firstMatch("x{102}"), 1743); + assertNull(res[666].firstMatch("Y"), 1744); + assertNull(res[666].firstMatch("y "), 1745); + assertNull(res[667].firstMatch("A"), 1746); + assertNull(res[667].firstMatch("Ax{300}BC "), 1747); + assertNull(res[667].firstMatch("Ax{300}x{301}x{302}BC "), 1748); + assertNull(res[667].firstMatch("*** Failers"), 1749); + assertNull(res[667].firstMatch("x{300} "), 1750); + assertToStringEquals("X", res[668].firstMatch("X123"), 1751); + assertNull(res[668].firstMatch("*** Failers"), 1752); + assertNull(res[668].firstMatch("AXYZ"), 1753); + assertNull(res[669].firstMatch("Ax{300}x{301}x{302}BCAx{300}x{301} "), 1754); + assertNull(res[669].firstMatch("Ax{300}x{301}x{302}BCAx{300}x{301}C "), 1755); + assertNull(res[670].firstMatch("Ax{300}x{301}x{302}BCAx{300}x{301} "), 1756); + assertNull(res[670].firstMatch("Ax{300}x{301}x{302}BCAx{300}x{301}C "), 1757); + assertToStringEquals( + "A,,A", res[671].firstMatch("Ax{300}x{301}x{302}BCAx{300}x{301} "), 1758); + assertToStringEquals("A,,A", + res[671].firstMatch("Ax{300}x{301}x{302}BCAx{300}x{301}C "), 1759); + assertToStringEquals( + "A,,A", res[672].firstMatch("Ax{300}x{301}x{302}BCAx{300}x{301} "), 1760); + assertToStringEquals("A,,A", + res[672].firstMatch("Ax{300}x{301}x{302}BCAx{300}x{301}C "), 1761); + assertNull(res[673].firstMatch("*** Failers"), 1762); + assertNull(res[673].firstMatch("Ax{300}x{301}x{302}"), 1763); + assertNull(res[674].firstMatch("Ax{300}x{301}Bx{300}X"), 1764); + assertNull(res[674].firstMatch("Ax{300}x{301}Bx{300}Cx{300}x{301}"), 1765); + assertNull(res[674].firstMatch("Ax{300}x{301}Bx{300}Cx{300}x{301}X"), 1766); + assertNull( + res[674].firstMatch("Ax{300}x{301}Bx{300}Cx{300}x{301}DAx{300}X"), 1767); + assertNull(res[675].firstMatch("Ax{300}x{301}Bx{300}X"), 1768); + assertNull(res[675].firstMatch("Ax{300}x{301}Bx{300}Cx{300}x{301}"), 1769); + assertNull(res[675].firstMatch("Ax{300}x{301}Bx{300}Cx{300}x{301}X"), 1770); + assertNull( + res[675].firstMatch("Ax{300}x{301}Bx{300}Cx{300}x{301}DAx{300}X"), 1771); + assertNull(res[675].firstMatch("x{2e81}x{3007}x{2f804}x{31a0}"), 1772); + assertNull(res[675].firstMatch("** Failers"), 1773); + assertNull(res[675].firstMatch("x{2e7f} "), 1774); + assertNull(res[675].firstMatch("x{3105}"), 1775); + assertNull(res[675].firstMatch("** Failers"), 1776); + assertNull(res[675].firstMatch("x{30ff} "), 1777); + assertNull(res[676].firstMatch("x{06e9}"), 1778); + assertNull(res[676].firstMatch("x{060b}"), 1779); + assertNull(res[676].firstMatch("** Failers"), 1780); + assertNull(res[676].firstMatch("Xx{06e9} "), 1781); + assertNull(res[677].firstMatch("x{2f800}"), 1782); + assertNull(res[677].firstMatch("** Failers"), 1783); + assertNull(res[677].firstMatch("x{a014}"), 1784); + assertNull(res[677].firstMatch("x{a4c6} "), 1785); + assertNull(res[678].firstMatch("AXYZ"), 1786); + assertNull(res[678].firstMatch("x{1234}XYZ "), 1787); + assertNull(res[678].firstMatch("** Failers"), 1788); + assertNull(res[678].firstMatch("X "), 1789); + assertNull(res[679].firstMatch("** Failers"), 1790); + assertNull(res[679].firstMatch("AX"), 1791); + assertNull(res[680].firstMatch("XYZ"), 1792); + assertNull(res[680].firstMatch("AXYZ"), 1793); + assertNull(res[680].firstMatch("x{1234}XYZ "), 1794); + assertNull(res[680].firstMatch("** Failers"), 1795); + assertNull(res[680].firstMatch("ABXYZ "), 1796); + assertNull(res[681].firstMatch("XYZ"), 1797); + assertNull(res[681].firstMatch("** Failers"), 1798); + assertNull(res[681].firstMatch("AXYZ"), 1799); + assertNull(res[681].firstMatch("x{1234}XYZ "), 1800); + assertNull(res[681].firstMatch("ABXYZ "), 1801); + assertNull(res[681].firstMatch("AXYZ"), 1802); + assertNull(res[681].firstMatch("x{1234}XYZ"), 1803); + assertNull(res[681].firstMatch("Ax{1234}XYZ"), 1804); + assertNull(res[681].firstMatch("** Failers"), 1805); + assertNull(res[681].firstMatch("XYZ"), 1806); + assertNull(res[681].firstMatch("** Failers"), 1807); + assertNull(res[681].firstMatch("AXYZ"), 1808); + assertNull(res[681].firstMatch("x{1234}XYZ"), 1809); + assertNull(res[681].firstMatch("Ax{1234}XYZ"), 1810); + assertNull(res[681].firstMatch("XYZ"), 1811); + assertNull(res[682].firstMatch("XYZ"), 1812); + assertNull(res[682].firstMatch("AXYZ"), 1813); + assertNull(res[682].firstMatch("x{1234}XYZ"), 1814); + assertNull(res[682].firstMatch("Ax{1234}XYZ"), 1815); + assertNull(res[682].firstMatch("** Failers"), 1816); + assertNull(res[683].firstMatch("XYZ"), 1817); + assertNull(res[683].firstMatch("** Failers"), 1818); + assertNull(res[683].firstMatch("AXYZ"), 1819); + assertNull(res[683].firstMatch("x{1234}XYZ"), 1820); + assertNull(res[683].firstMatch("Ax{1234}XYZ"), 1821); + assertToStringEquals("AX", res[684].firstMatch("AXYZ"), 1822); + assertNull(res[684].firstMatch("x{1234}XYZ "), 1823); + assertNull(res[684].firstMatch("** Failers"), 1824); + assertNull(res[684].firstMatch("X "), 1825); + assertNull(res[685].firstMatch("** Failers"), 1826); + assertToStringEquals("AX", res[685].firstMatch("AX"), 1827); + assertToStringEquals("X", res[686].firstMatch("XYZ"), 1828); + assertToStringEquals("AX", res[686].firstMatch("AXYZ"), 1829); + assertNull(res[686].firstMatch("x{1234}XYZ "), 1830); + assertNull(res[686].firstMatch("** Failers"), 1831); + assertNull(res[686].firstMatch("ABXYZ "), 1832); + assertToStringEquals("X", res[687].firstMatch("XYZ"), 1833); + assertNull(res[687].firstMatch("** Failers"), 1834); + assertToStringEquals("AX", res[687].firstMatch("AXYZ"), 1835); + assertNull(res[687].firstMatch("x{1234}XYZ "), 1836); + assertNull(res[687].firstMatch("ABXYZ "), 1837); + assertToStringEquals("AX", res[688].firstMatch("AXYZ"), 1838); + assertNull(res[688].firstMatch("x{1234}XYZ"), 1839); + assertNull(res[688].firstMatch("Ax{1234}XYZ"), 1840); + assertNull(res[688].firstMatch("** Failers"), 1841); + assertNull(res[688].firstMatch("XYZ"), 1842); + assertNull(res[689].firstMatch("** Failers"), 1843); + assertToStringEquals("AX", res[689].firstMatch("AXYZ"), 1844); + assertNull(res[689].firstMatch("x{1234}XYZ"), 1845); + assertNull(res[689].firstMatch("Ax{1234}XYZ"), 1846); + assertNull(res[689].firstMatch("XYZ"), 1847); + assertToStringEquals("X", res[690].firstMatch("XYZ"), 1848); + assertToStringEquals("AX", res[690].firstMatch("AXYZ"), 1849); + assertNull(res[690].firstMatch("x{1234}XYZ"), 1850); + assertNull(res[690].firstMatch("Ax{1234}XYZ"), 1851); + assertNull(res[690].firstMatch("** Failers"), 1852); + assertToStringEquals("X", res[691].firstMatch("XYZ"), 1853); + assertNull(res[691].firstMatch("** Failers"), 1854); + assertToStringEquals("AX", res[691].firstMatch("AXYZ"), 1855); + assertNull(res[691].firstMatch("x{1234}XYZ"), 1856); + assertNull(res[691].firstMatch("Ax{1234}XYZ"), 1857); + assertNull(res[692].firstMatch("abcdefgh"), 1858); + assertNull(res[692].firstMatch("x{1234}\n\x0dx{3456}xyz "), 1859); + assertNull(res[693].firstMatch("abcdefgh"), 1860); + assertNull(res[693].firstMatch("x{1234}\n\x0dx{3456}xyz "), 1861); + assertNull(res[694].firstMatch("** Failers"), 1862); + assertNull(res[694].firstMatch("abcdefgh"), 1863); + assertNull(res[694].firstMatch("x{1234}\n\x0dx{3456}xyz "), 1864); + assertNull(res[695].firstMatch(" AXY"), 1865); + assertNull(res[695].firstMatch(" aXY"), 1866); + assertNull(res[695].firstMatch(" x{1c5}XY"), 1867); + assertNull(res[695].firstMatch(" ** Failers"), 1868); + assertNull(res[695].firstMatch(" x{1bb}XY"), 1869); + assertNull(res[695].firstMatch(" x{2b0}XY"), 1870); + assertNull(res[695].firstMatch(" !XY "), 1871); + assertNull(res[696].firstMatch(" AXY"), 1872); + assertNull(res[696].firstMatch(" aXY"), 1873); + assertNull(res[696].firstMatch(" x{1c5}XY"), 1874); + assertNull(res[696].firstMatch(" ** Failers"), 1875); + assertNull(res[696].firstMatch(" x{1bb}XY"), 1876); + assertNull(res[696].firstMatch(" x{2b0}XY"), 1877); + assertNull(res[696].firstMatch(" !XY "), 1878); + assertNull(res[696].firstMatch(" AXY"), 1879); + assertNull(res[696].firstMatch(" aXY"), 1880); + assertNull(res[696].firstMatch(" AbcdeXyz "), 1881); + assertNull(res[696].firstMatch(" x{1c5}AbXY"), 1882); + assertNull(res[696].firstMatch(" abcDEXypqreXlmn "), 1883); + assertNull(res[696].firstMatch(" ** Failers"), 1884); + assertNull(res[696].firstMatch(" x{1bb}XY"), 1885); + assertNull(res[696].firstMatch(" x{2b0}XY"), 1886); + assertNull(res[696].firstMatch(" !XY "), 1887); + assertNull(res[697].firstMatch(" AXY"), 1888); + assertNull(res[697].firstMatch(" aXY"), 1889); + assertNull(res[697].firstMatch(" AbcdeXyz "), 1890); + assertNull(res[697].firstMatch(" x{1c5}AbXY"), 1891); + assertNull(res[697].firstMatch(" abcDEXypqreXlmn "), 1892); + assertNull(res[697].firstMatch(" ** Failers"), 1893); + assertNull(res[697].firstMatch(" x{1bb}XY"), 1894); + assertNull(res[697].firstMatch(" x{2b0}XY"), 1895); + assertNull(res[697].firstMatch(" !XY "), 1896); + assertNull(res[697].firstMatch(" AXY"), 1897); + assertNull(res[697].firstMatch(" aXY"), 1898); + assertNull(res[697].firstMatch(" AbcdeXyz "), 1899); + assertNull(res[697].firstMatch(" x{1c5}AbXY"), 1900); + assertNull(res[697].firstMatch(" abcDEXypqreXlmn "), 1901); + assertNull(res[697].firstMatch(" ** Failers"), 1902); + assertNull(res[697].firstMatch(" x{1bb}XY"), 1903); + assertNull(res[697].firstMatch(" x{2b0}XY"), 1904); + assertNull(res[697].firstMatch(" !XY "), 1905); + assertNull(res[698].firstMatch(" AXY"), 1906); + assertNull(res[698].firstMatch(" aXY"), 1907); + assertNull(res[698].firstMatch(" AbcdeXyz "), 1908); + assertNull(res[698].firstMatch(" x{1c5}AbXY"), 1909); + assertNull(res[698].firstMatch(" abcDEXypqreXlmn "), 1910); + assertNull(res[698].firstMatch(" ** Failers"), 1911); + assertNull(res[698].firstMatch(" x{1bb}XY"), 1912); + assertNull(res[698].firstMatch(" x{2b0}XY"), 1913); + assertNull(res[698].firstMatch(" !XY "), 1914); + assertNull(res[699].firstMatch(" !XY"), 1915); + assertNull(res[699].firstMatch(" x{1bb}XY"), 1916); + assertNull(res[699].firstMatch(" x{2b0}XY"), 1917); + assertNull(res[699].firstMatch(" ** Failers"), 1918); + assertNull(res[699].firstMatch(" x{1c5}XY"), 1919); + assertNull(res[699].firstMatch(" AXY "), 1920); + assertNull(res[700].firstMatch(" !XY"), 1921); + assertNull(res[700].firstMatch(" x{1bb}XY"), 1922); + assertNull(res[700].firstMatch(" x{2b0}XY"), 1923); + assertNull(res[700].firstMatch(" ** Failers"), 1924); + assertNull(res[700].firstMatch(" x{1c5}XY"), 1925); + assertNull(res[700].firstMatch(" AXY "), 1926); + assertNull(res[701].firstMatch("\xa0!"), 1927); + assertNull(res[701].firstMatch("AabcabcYZ "), 1928); + assertToStringEquals("L=abcX,L=abc,abc", res[702].firstMatch("L=abcX"), 1929); + assertNull(res[702].firstMatch("x{c0}"), 1930); + assertNull(res[702].firstMatch("x{e0} "), 1931); + assertNull(res[702].firstMatch("x{c0}"), 1932); + assertNull(res[702].firstMatch("x{e0} "), 1933); + assertNull(res[703].firstMatch("x{1b00}x{12000}x{7c0}x{a840}x{10900}"), 1934); + assertNull(res[706].firstMatch("123abcdefg"), 1935); + assertNull(res[706].firstMatch("123abc\xc4\xc5zz"), 1936); + assertNull(res[710].firstMatch("A\x80"), 1937); + assertNull(res[725].firstMatch("x{60e} "), 1938); + assertNull(res[725].firstMatch("x{656} "), 1939); + assertNull(res[725].firstMatch("x{657} "), 1940); + assertNull(res[725].firstMatch("x{658} "), 1941); + assertNull(res[725].firstMatch("x{659} "), 1942); + assertNull(res[725].firstMatch("x{65a} "), 1943); + assertNull(res[725].firstMatch("x{65b} "), 1944); + assertNull(res[725].firstMatch("x{65c} "), 1945); + assertNull(res[725].firstMatch("x{65d} "), 1946); + assertNull(res[725].firstMatch("x{65e} "), 1947); + assertNull(res[725].firstMatch("x{66a} "), 1948); + assertNull(res[725].firstMatch("x{6e9} "), 1949); + assertNull(res[725].firstMatch("x{6ef}"), 1950); + assertNull(res[725].firstMatch("x{6fa} "), 1951); + assertNull(res[725].firstMatch("** Failers"), 1952); + assertNull(res[725].firstMatch("x{600}"), 1953); + assertNull(res[725].firstMatch("x{650}"), 1954); + assertNull(res[725].firstMatch("x{651} "), 1955); + assertNull(res[725].firstMatch("x{652} "), 1956); + assertNull(res[725].firstMatch("x{653} "), 1957); + assertNull(res[725].firstMatch("x{654} "), 1958); + assertNull(res[725].firstMatch("x{655} "), 1959); + assertNull(res[725].firstMatch("x{65f} "), 1960); + assertNull(res[726].firstMatch("x{1d2b} "), 1961); + assertNull(res[727].firstMatch("x{589}"), 1962); + assertNull(res[727].firstMatch("x{60c}"), 1963); + assertNull(res[727].firstMatch("x{61f} "), 1964); + assertNull(res[727].firstMatch("x{964}"), 1965); + assertNull(res[727].firstMatch("x{965} "), 1966); + assertNull(res[727].firstMatch("x{970} "), 1967); + assertNull(res[728].firstMatch("x{64b}"), 1968); + assertNull(res[728].firstMatch("x{654}"), 1969); + assertNull(res[728].firstMatch("x{655}"), 1970); + assertNull(res[728].firstMatch("x{200c} "), 1971); + assertNull(res[728].firstMatch("** Failers"), 1972); + assertNull(res[728].firstMatch("x{64a}"), 1973); + assertNull(res[728].firstMatch("x{656} "), 1974); + assertNull(res[729].firstMatch("x{10450}"), 1975); + assertNull(res[729].firstMatch("x{1047f}"), 1976); + assertNull(res[730].firstMatch("x{10400}"), 1977); + assertNull(res[730].firstMatch("x{1044f}"), 1978); + assertNull(res[731].firstMatch("x{10480}"), 1979); + assertNull(res[731].firstMatch("x{1049d}"), 1980); + assertNull(res[731].firstMatch("x{104a0}"), 1981); + assertNull(res[731].firstMatch("x{104a9}"), 1982); + assertNull(res[731].firstMatch("** Failers"), 1983); + assertNull(res[731].firstMatch("x{1049e}"), 1984); + assertNull(res[731].firstMatch("x{1049f}"), 1985); + assertNull(res[731].firstMatch("x{104aa} "), 1986); + assertNull(res[731].firstMatch("\xe2\x80\xa8\xe2\x80\xa8"), 1987); + assertNull(res[731].firstMatch("x{2028}x{2028}x{2028}"), 1988); + assertNull(res[732].firstMatch("x{c0}x{e0}x{116}x{117}"), 1989); + assertNull(res[732].firstMatch("x{c0}x{e0}x{116}x{117}"), 1990); + assertNull( + res[733].firstMatch( + "x{102A4}x{AA52}x{A91D}x{1C46}x{10283}x{1092E}x{1C6B}x{A93B}x{A8BF}x{1BA0}x{A50A}===="), + 1991); + assertNull(res[733].firstMatch("x{a77d}x{1d79}"), 1992); + assertNull(res[733].firstMatch("x{1d79}x{a77d} "), 1993); + assertNull(res[733].firstMatch("x{a77d}x{1d79}"), 1994); + assertNull(res[733].firstMatch("** Failers "), 1995); + assertNull(res[733].firstMatch("x{1d79}x{a77d} "), 1996); + assertToStringEquals("AA,A", res[734].firstMatch("AA"), 1997); + assertToStringEquals("Aa,A", res[734].firstMatch("Aa"), 1998); + assertToStringEquals("aa,a", res[734].firstMatch("aa"), 1999); + assertToStringEquals("aA,a", res[734].firstMatch("aA"), 2000); + assertNull(res[734].firstMatch("x{de}x{de}"), 2001); + assertNull(res[734].firstMatch("x{de}x{fe}"), 2002); + assertNull(res[734].firstMatch("x{fe}x{fe}"), 2003); + assertNull(res[734].firstMatch("x{fe}x{de}"), 2004); + assertNull(res[734].firstMatch("x{10a}x{10a}"), 2005); + assertNull(res[734].firstMatch("x{10a}x{10b}"), 2006); + assertNull(res[734].firstMatch("x{10b}x{10b}"), 2007); + assertNull(res[734].firstMatch("x{10b}x{10a}"), 2008); + assertToStringEquals("abc", res[736].firstMatch("abc"), 2009); + assertToStringEquals("abc", res[737].firstMatch("abc"), 2010); + assertToStringEquals("abbbbc", res[737].firstMatch("abbbbc"), 2011); + assertToStringEquals("ac", res[737].firstMatch("ac"), 2012); + assertToStringEquals("abc", res[738].firstMatch("abc"), 2013); + assertToStringEquals("abbbbbbc", res[738].firstMatch("abbbbbbc"), 2014); + assertNull(res[738].firstMatch("*** Failers "), 2015); + assertNull(res[738].firstMatch("ac"), 2016); + assertNull(res[738].firstMatch("ab"), 2017); + assertToStringEquals("a", res[739].firstMatch("a"), 2018); + assertToStringEquals( + "aaaaaaaaaaaaaaaaa", res[739].firstMatch("aaaaaaaaaaaaaaaaa"), 2019); + assertToStringEquals("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + res[739].firstMatch("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa "), 2020); + assertToStringEquals("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + res[739].firstMatch("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaF "), 2021); + assertToStringEquals("a,a", res[740].firstMatch("a"), 2022); + assertToStringEquals("a,a", res[740].firstMatch("abcd"), 2023); + assertToStringEquals("a,a", res[740].firstMatch("african"), 2024); + assertToStringEquals("abc", res[741].firstMatch("abcdef"), 2025); + assertNull(res[741].firstMatch("*** Failers"), 2026); + assertNull(res[741].firstMatch("xyzabc"), 2027); + assertNull(res[741].firstMatch("xyz\nabc "), 2028); + assertToStringEquals("abc", res[742].firstMatch("abcdef"), 2029); + assertToStringEquals("abc", res[742].firstMatch("xyz\nabc "), 2030); + assertNull(res[742].firstMatch("*** Failers"), 2031); + assertNull(res[742].firstMatch("xyzabc"), 2032); + assertNull(res[743].firstMatch("abcdef"), 2033); + assertNull(res[743].firstMatch("*** Failers"), 2034); + assertNull(res[743].firstMatch("xyzabc"), 2035); + assertNull(res[743].firstMatch("xyz\nabc "), 2036); + assertNull(res[744].firstMatch("abcdef"), 2037); + assertNull(res[744].firstMatch("*** Failers"), 2038); + assertNull(res[744].firstMatch("xyzabc"), 2039); + assertNull(res[744].firstMatch("xyz\nabc "), 2040); + assertNull(res[745].firstMatch("abcdef"), 2041); + assertNull(res[745].firstMatch("xyzabc>3"), 2042); + assertNull(res[745].firstMatch("*** Failers"), 2043); + assertNull(res[745].firstMatch("xyzabc "), 2044); + assertNull(res[745].firstMatch("xyzabc>2 "), 2045); + assertToStringEquals("x9yzz", res[746].firstMatch("x9yzz"), 2046); + assertToStringEquals("x0y+z", res[746].firstMatch("x0y+z"), 2047); + assertNull(res[746].firstMatch("*** Failers"), 2048); + assertNull(res[746].firstMatch("xyz"), 2049); + assertNull(res[746].firstMatch("xxy0z "), 2050); + assertToStringEquals("x yzz", res[747].firstMatch("x yzz"), 2051); + assertToStringEquals("x y+z", res[747].firstMatch("x y+z"), 2052); + assertNull(res[747].firstMatch("*** Failers"), 2053); + assertNull(res[747].firstMatch("xyz"), 2054); + assertNull(res[747].firstMatch("xxyyz"), 2055); + assertToStringEquals("xxy+z", res[748].firstMatch("xxy+z"), 2056); + assertNull(res[748].firstMatch("*** Failers"), 2057); + assertNull(res[748].firstMatch("xxy0z"), 2058); + assertNull(res[748].firstMatch("x+y+z "), 2059); + assertToStringEquals("x+y", res[749].firstMatch("x+y"), 2060); + assertToStringEquals("x-y", res[749].firstMatch("x-y"), 2061); + assertNull(res[749].firstMatch("*** Failers"), 2062); + assertNull(res[749].firstMatch("x\ny"), 2063); + assertToStringEquals("x+y", res[750].firstMatch("x+y"), 2064); + assertToStringEquals("x-y", res[750].firstMatch("x-y"), 2065); + assertNull(res[750].firstMatch("x\ny"), 2066); + assertNull(res[750].firstMatch("a+bc+dp+q"), 2067); + assertNull(res[750].firstMatch("a+bc\ndp+q"), 2068); + assertNull(res[750].firstMatch("x\nyp+q "), 2069); + assertNull(res[750].firstMatch("*** Failers "), 2070); + assertNull(res[750].firstMatch("a\nbc\ndp+q"), 2071); + assertNull(res[750].firstMatch("a+bc\ndp\nq"), 2072); + assertNull(res[750].firstMatch("x\nyp\nq "), 2073); + assertNull(res[751].firstMatch("ba0"), 2074); + assertNull(res[751].firstMatch("*** Failers"), 2075); + assertNull(res[751].firstMatch("ba0\n"), 2076); + assertNull(res[751].firstMatch("ba0\ncd "), 2077); + assertNull(res[752].firstMatch("ba0"), 2078); + assertNull(res[752].firstMatch("*** Failers"), 2079); + assertNull(res[752].firstMatch("ba0\n"), 2080); + assertNull(res[752].firstMatch("ba0\ncd "), 2081); + assertNull(res[753].firstMatch("ba0"), 2082); + assertNull(res[753].firstMatch("ba0\n"), 2083); + assertNull(res[753].firstMatch("*** Failers"), 2084); + assertNull(res[753].firstMatch("ba0\ncd "), 2085); + assertNull(res[754].firstMatch("ba0"), 2086); + assertNull(res[754].firstMatch("ba0\n"), 2087); + assertNull(res[754].firstMatch("*** Failers"), 2088); + assertNull(res[754].firstMatch("ba0\ncd "), 2089); + assertToStringEquals("a0", res[755].firstMatch("ba0"), 2090); + assertNull(res[755].firstMatch("ba0\n"), 2091); + assertNull(res[755].firstMatch("*** Failers"), 2092); + assertNull(res[755].firstMatch("ba0\ncd "), 2093); + assertToStringEquals("a0", res[756].firstMatch("ba0"), 2094); + assertToStringEquals("a0", res[756].firstMatch("ba0\n"), 2095); + assertToStringEquals("a0", res[756].firstMatch("ba0\ncd "), 2096); + assertNull(res[756].firstMatch("*** Failers"), 2097); + assertToStringEquals("abc", res[757].firstMatch("abc"), 2098); + assertToStringEquals("aBc", res[757].firstMatch("aBc"), 2099); + assertToStringEquals("ABC", res[757].firstMatch("ABC"), 2100); + assertToStringEquals("b", res[758].firstMatch("abcd"), 2101); + assertToStringEquals("abz", res[759].firstMatch("abz"), 2102); + assertToStringEquals("abb", res[759].firstMatch("abbz"), 2103); + assertToStringEquals("az", res[759].firstMatch("azz "), 2104); + assertToStringEquals("yz", res[760].firstMatch("ayzq"), 2105); + assertToStringEquals("xyz", res[760].firstMatch("axyzq"), 2106); + assertToStringEquals("xxyz", res[760].firstMatch("axxyz"), 2107); + assertToStringEquals("xxxyz", res[760].firstMatch("axxxyzq"), 2108); + assertToStringEquals("xxxyz", res[760].firstMatch("axxxxyzq"), 2109); + assertNull(res[760].firstMatch("*** Failers"), 2110); + assertNull(res[760].firstMatch("ax"), 2111); + assertNull(res[760].firstMatch("axx "), 2112); + assertNull(res[760].firstMatch(" "), 2113); + assertToStringEquals("xxxyz", res[761].firstMatch("axxxyzq"), 2114); + assertToStringEquals("xxxyz", res[761].firstMatch("axxxxyzq"), 2115); + assertNull(res[761].firstMatch("*** Failers"), 2116); + assertNull(res[761].firstMatch("ax"), 2117); + assertNull(res[761].firstMatch("axx "), 2118); + assertNull(res[761].firstMatch("ayzq"), 2119); + assertNull(res[761].firstMatch("axyzq"), 2120); + assertNull(res[761].firstMatch("axxyz"), 2121); + assertNull(res[761].firstMatch(" "), 2122); + assertToStringEquals("xxyz", res[762].firstMatch("axxyz"), 2123); + assertToStringEquals("xxxyz", res[762].firstMatch("axxxyzq"), 2124); + assertToStringEquals("xxxyz", res[762].firstMatch("axxxxyzq"), 2125); + assertNull(res[762].firstMatch("*** Failers"), 2126); + assertNull(res[762].firstMatch("ax"), 2127); + assertNull(res[762].firstMatch("axx "), 2128); + assertNull(res[762].firstMatch("ayzq"), 2129); + assertNull(res[762].firstMatch("axyzq"), 2130); + assertNull(res[762].firstMatch(" "), 2131); + assertToStringEquals("b", res[763].firstMatch("bac"), 2132); + assertToStringEquals("bcdef", res[763].firstMatch("bcdefax"), 2133); + assertToStringEquals("*** F", res[763].firstMatch("*** Failers"), 2134); + assertToStringEquals(" ", res[763].firstMatch("aaaaa "), 2135); + assertToStringEquals("b", res[764].firstMatch("bac"), 2136); + assertToStringEquals("bcdef", res[764].firstMatch("bcdefax"), 2137); + assertToStringEquals("*** F", res[764].firstMatch("*** Failers"), 2138); + assertToStringEquals("", res[764].firstMatch("aaaaa "), 2139); + assertToStringEquals("xyz", res[765].firstMatch("xyz"), 2140); + assertToStringEquals("wxyz", res[765].firstMatch("awxyza"), 2141); + assertToStringEquals("bcdef", res[765].firstMatch("abcdefa"), 2142); + assertToStringEquals("bcdef", res[765].firstMatch("abcdefghijk"), 2143); + assertToStringEquals("*** F", res[765].firstMatch("*** Failers"), 2144); + assertNull(res[765].firstMatch("axya"), 2145); + assertNull(res[765].firstMatch("axa"), 2146); + assertToStringEquals(" ", res[765].firstMatch("aaaaa "), 2147); + assertToStringEquals("1234", res[766].firstMatch("1234b567"), 2148); + assertToStringEquals("", res[766].firstMatch("xyz"), 2149); + assertToStringEquals("a", res[767].firstMatch("a1234b567"), 2150); + assertToStringEquals("xyz", res[767].firstMatch("xyz"), 2151); + assertToStringEquals(" ", res[767].firstMatch(" "), 2152); + assertToStringEquals("1234", res[768].firstMatch("ab1234c56"), 2153); + assertNull(res[768].firstMatch("*** Failers"), 2154); + assertNull(res[768].firstMatch("xyz"), 2155); + assertToStringEquals("ab", res[769].firstMatch("ab123c56"), 2156); + assertToStringEquals("*** Failers", res[769].firstMatch("*** Failers"), 2157); + assertNull(res[769].firstMatch("789"), 2158); + assertToStringEquals("5A", res[770].firstMatch("045ABC"), 2159); + assertToStringEquals("A", res[770].firstMatch("ABC"), 2160); + assertNull(res[770].firstMatch("*** Failers"), 2161); + assertNull(res[770].firstMatch("XYZ"), 2162); + assertToStringEquals("A", res[771].firstMatch("ABC"), 2163); + assertToStringEquals("BA", res[771].firstMatch("BAC"), 2164); + assertToStringEquals("A", res[771].firstMatch("9ABC "), 2165); + assertNull(res[771].firstMatch("*** Failers"), 2166); + assertToStringEquals("aaaa", res[772].firstMatch("aaaa"), 2167); + assertToStringEquals("xyz", res[773].firstMatch("xyz"), 2168); + assertToStringEquals("ggggggggxyz", res[773].firstMatch("ggggggggxyz"), 2169); + assertToStringEquals("abcdxyz", res[774].firstMatch("abcdxyz"), 2170); + assertToStringEquals("axyz", res[774].firstMatch("axyz"), 2171); + assertNull(res[774].firstMatch("*** Failers"), 2172); + assertNull(res[774].firstMatch("xyz"), 2173); + assertToStringEquals("xyz", res[775].firstMatch("xyz"), 2174); + assertToStringEquals("cxyz", res[775].firstMatch("cxyz "), 2175); + assertToStringEquals("12X", res[776].firstMatch("12X"), 2176); + assertToStringEquals("123X", res[776].firstMatch("123X"), 2177); + assertNull(res[776].firstMatch("*** Failers"), 2178); + assertNull(res[776].firstMatch("X"), 2179); + assertNull(res[776].firstMatch("1X"), 2180); + assertNull(res[776].firstMatch("1234X "), 2181); + assertToStringEquals("a4", res[777].firstMatch("a45"), 2182); + assertToStringEquals("b9", res[777].firstMatch("b93"), 2183); + assertToStringEquals("c9", res[777].firstMatch("c99z"), 2184); + assertToStringEquals("d0", res[777].firstMatch("d04"), 2185); + assertNull(res[777].firstMatch("*** Failers"), 2186); + assertNull(res[777].firstMatch("e45"), 2187); + assertNull(res[777].firstMatch("abcd "), 2188); + assertNull(res[777].firstMatch("abcd1234"), 2189); + assertNull(res[777].firstMatch("1234 "), 2190); + assertToStringEquals("a4", res[778].firstMatch("a45"), 2191); + assertToStringEquals("b9", res[778].firstMatch("b93"), 2192); + assertToStringEquals("c9", res[778].firstMatch("c99z"), 2193); + assertToStringEquals("d0", res[778].firstMatch("d04"), 2194); + assertToStringEquals("abcd1", res[778].firstMatch("abcd1234"), 2195); + assertToStringEquals("1", res[778].firstMatch("1234 "), 2196); + assertNull(res[778].firstMatch("*** Failers"), 2197); + assertNull(res[778].firstMatch("e45"), 2198); + assertNull(res[778].firstMatch("abcd "), 2199); + assertToStringEquals("a4", res[779].firstMatch("a45"), 2200); + assertToStringEquals("b9", res[779].firstMatch("b93"), 2201); + assertToStringEquals("c9", res[779].firstMatch("c99z"), 2202); + assertToStringEquals("d0", res[779].firstMatch("d04"), 2203); + assertToStringEquals("abcd1", res[779].firstMatch("abcd1234"), 2204); + assertNull(res[779].firstMatch("*** Failers"), 2205); + assertNull(res[779].firstMatch("1234 "), 2206); + assertNull(res[779].firstMatch("e45"), 2207); + assertNull(res[779].firstMatch("abcd "), 2208); + assertToStringEquals("aX", res[780].firstMatch("aX"), 2209); + assertToStringEquals("aaX", res[780].firstMatch("aaX "), 2210); + assertToStringEquals("a4", res[781].firstMatch("a45"), 2211); + assertToStringEquals("b9", res[781].firstMatch("b93"), 2212); + assertToStringEquals("c9", res[781].firstMatch("c99z"), 2213); + assertToStringEquals("d0", res[781].firstMatch("d04"), 2214); + assertToStringEquals("1", res[781].firstMatch("1234 "), 2215); + assertNull(res[781].firstMatch("*** Failers"), 2216); + assertNull(res[781].firstMatch("abcd1234"), 2217); + assertNull(res[781].firstMatch("e45"), 2218); + assertToStringEquals("ab4", res[782].firstMatch("ab45"), 2219); + assertToStringEquals("bcd9", res[782].firstMatch("bcd93"), 2220); + assertNull(res[782].firstMatch("*** Failers"), 2221); + assertNull(res[782].firstMatch("1234 "), 2222); + assertNull(res[782].firstMatch("a36 "), 2223); + assertNull(res[782].firstMatch("abcd1234"), 2224); + assertNull(res[782].firstMatch("ee45"), 2225); + assertToStringEquals("abc4,abc", res[783].firstMatch("abc45"), 2226); + assertToStringEquals( + "abcabcabc4,abc", res[783].firstMatch("abcabcabc45"), 2227); + assertToStringEquals("4,", res[783].firstMatch("42xyz "), 2228); + assertNull(res[783].firstMatch("*** Failers"), 2229); + assertToStringEquals("abc4,abc", res[784].firstMatch("abc45"), 2230); + assertToStringEquals( + "abcabcabc4,abc", res[784].firstMatch("abcabcabc45"), 2231); + assertNull(res[784].firstMatch("*** Failers"), 2232); + assertNull(res[784].firstMatch("42xyz "), 2233); + assertToStringEquals("abc4,abc", res[785].firstMatch("abc45"), 2234); + assertToStringEquals("4,", res[785].firstMatch("42xyz "), 2235); + assertNull(res[785].firstMatch("*** Failers"), 2236); + assertNull(res[785].firstMatch("abcabcabc45"), 2237); + assertToStringEquals("abcabc4,abc", res[786].firstMatch("abcabc45"), 2238); + assertToStringEquals( + "abcabcabc4,abc", res[786].firstMatch("abcabcabc45"), 2239); + assertNull(res[786].firstMatch("*** Failers"), 2240); + assertNull(res[786].firstMatch("abcabcabcabc45"), 2241); + assertNull(res[786].firstMatch("abc45"), 2242); + assertNull(res[786].firstMatch("42xyz "), 2243); + assertNull(res[786].firstMatch("1abc2abc3456"), 2244); + assertNull(res[786].firstMatch("1abc2xyz3456 "), 2245); + assertToStringEquals("ab=ab,ab,ab", res[787].firstMatch("ab=ab"), 2246); + assertToStringEquals("ab=ab,ab,ab", res[787].firstMatch("ab=ab"), 2247); + assertNull(res[787].firstMatch("abc"), 2248); + assertNull(res[787].firstMatch("a(b)c"), 2249); + assertNull(res[787].firstMatch("a(b(c))d "), 2250); + assertNull(res[787].firstMatch("*** Failers)"), 2251); + assertNull(res[787].firstMatch("a(b(c)d "), 2252); + assertNull(res[787].firstMatch(">abc>123abc>1(2)3abc>(1(2)3)"), 2259); + assertNull(res[787].firstMatch(""), 2260); + assertNull(res[787].firstMatch(" hij>"), 2261); + assertNull(res[787].firstMatch(" hij>"), 2262); + assertNull(res[787].firstMatch("def> "), 2263); + assertNull(res[787].firstMatch(" "), 2264); + assertNull(res[787].firstMatch("*** Failers"), 2265); + assertNull(res[787].firstMatch("3 "), 2323); + assertNull(res[795].firstMatch("*** Failers "), 2324); + assertNull(res[795].firstMatch("defabcxyz"), 2325); + assertNull(res[796].firstMatch("abP"), 2326); + assertNull(res[796].firstMatch("abcdeP"), 2327); + assertToStringEquals("abcdef", res[796].firstMatch("abcdefP"), 2328); + assertNull(res[796].firstMatch("*** Failers"), 2329); + assertNull(res[796].firstMatch("abxP "), 2330); + assertNull(res[797].firstMatch("aP"), 2331); + assertNull(res[797].firstMatch("aaP"), 2332); + assertNull(res[797].firstMatch("aa2P "), 2333); + assertNull(res[797].firstMatch("aaaP"), 2334); + assertNull(res[797].firstMatch("aaa23P "), 2335); + assertNull(res[797].firstMatch("aaaa12345P"), 2336); + assertToStringEquals("aa0z", res[797].firstMatch("aa0zP"), 2337); + assertToStringEquals( + "aaaa4444444444444z", res[797].firstMatch("aaaa4444444444444zP "), 2338); + assertNull(res[797].firstMatch("*** Failers"), 2339); + assertNull(res[797].firstMatch("azP "), 2340); + assertNull(res[797].firstMatch("aaaaaP "), 2341); + assertNull(res[797].firstMatch("a56P "), 2342); + assertNull( + res[799].firstMatch("adfadadaklhlkalkajhlkjahdfasdfasdfladsfjkjPZ"), + 2343); + assertNull( + res[799].firstMatch("lkjhlkjhlkjhlkjhabbbbbbcdaefabbbbbbbefaPBZ"), 2344); + assertNull(res[799].firstMatch("cdabbbbbbbbPRBZ"), 2345); + assertNull(res[799].firstMatch("efabbbbbbbbbbbbbbbbPRBZ"), 2346); + assertNull(res[799].firstMatch("bbbbbbbbbbbbcdXyasdfadfPRBZ "), 2347); + assertNull(res[799].firstMatch("abc"), 2348); + assertNull(res[799].firstMatch("** Failers"), 2349); + assertNull(res[799].firstMatch("def "), 2350); + assertToStringEquals( + "the quick brown fox", res[800].firstMatch("the quick brown fox"), 2351); + assertNull(res[800].firstMatch("The quick brown FOX"), 2352); + assertToStringEquals("the quick brown fox", + res[800].firstMatch("What do you know about the quick brown fox?"), 2353); + assertNull( + res[800].firstMatch("What do you know about THE QUICK BROWN FOX?"), 2354); + assertToStringEquals( + "the quick brown fox", res[801].firstMatch("the quick brown fox"), 2355); + assertToStringEquals( + "The quick brown FOX", res[801].firstMatch("The quick brown FOX"), 2356); + assertToStringEquals("the quick brown fox", + res[801].firstMatch("What do you know about the quick brown fox?"), 2357); + assertToStringEquals("THE QUICK BROWN FOX", + res[801].firstMatch("What do you know about THE QUICK BROWN FOX?"), 2358); + assertToStringEquals("abcd\x09\n\x0d\x0cae9;\$\\?caxyz", + res[802].firstMatch("abcd\x09\n\x0d\x0cae9;\$\\?caxyz"), 2359); + assertToStringEquals("abxyzpqrrrabbxyyyypqAzz", + res[803].firstMatch("abxyzpqrrrabbxyyyypqAzz"), 2360); + assertToStringEquals("abxyzpqrrrabbxyyyypqAzz", + res[803].firstMatch("abxyzpqrrrabbxyyyypqAzz"), 2361); + assertToStringEquals("aabxyzpqrrrabbxyyyypqAzz", + res[803].firstMatch("aabxyzpqrrrabbxyyyypqAzz"), 2362); + assertToStringEquals("aaabxyzpqrrrabbxyyyypqAzz", + res[803].firstMatch("aaabxyzpqrrrabbxyyyypqAzz"), 2363); + assertToStringEquals("aaaabxyzpqrrrabbxyyyypqAzz", + res[803].firstMatch("aaaabxyzpqrrrabbxyyyypqAzz"), 2364); + assertToStringEquals("abcxyzpqrrrabbxyyyypqAzz", + res[803].firstMatch("abcxyzpqrrrabbxyyyypqAzz"), 2365); + assertToStringEquals("aabcxyzpqrrrabbxyyyypqAzz", + res[803].firstMatch("aabcxyzpqrrrabbxyyyypqAzz"), 2366); + assertToStringEquals("aaabcxyzpqrrrabbxyyyypAzz", + res[803].firstMatch("aaabcxyzpqrrrabbxyyyypAzz"), 2367); + assertToStringEquals("aaabcxyzpqrrrabbxyyyypqAzz", + res[803].firstMatch("aaabcxyzpqrrrabbxyyyypqAzz"), 2368); + assertToStringEquals("aaabcxyzpqrrrabbxyyyypqqAzz", + res[803].firstMatch("aaabcxyzpqrrrabbxyyyypqqAzz"), 2369); + assertToStringEquals("aaabcxyzpqrrrabbxyyyypqqqAzz", + res[803].firstMatch("aaabcxyzpqrrrabbxyyyypqqqAzz"), 2370); + assertToStringEquals("aaabcxyzpqrrrabbxyyyypqqqqAzz", + res[803].firstMatch("aaabcxyzpqrrrabbxyyyypqqqqAzz"), 2371); + assertToStringEquals("aaabcxyzpqrrrabbxyyyypqqqqqAzz", + res[803].firstMatch("aaabcxyzpqrrrabbxyyyypqqqqqAzz"), 2372); + assertToStringEquals("aaabcxyzpqrrrabbxyyyypqqqqqqAzz", + res[803].firstMatch("aaabcxyzpqrrrabbxyyyypqqqqqqAzz"), 2373); + assertToStringEquals("aaaabcxyzpqrrrabbxyyyypqAzz", + res[803].firstMatch("aaaabcxyzpqrrrabbxyyyypqAzz"), 2374); + assertToStringEquals("abxyzzpqrrrabbxyyyypqAzz", + res[803].firstMatch("abxyzzpqrrrabbxyyyypqAzz"), 2375); + assertToStringEquals("aabxyzzzpqrrrabbxyyyypqAzz", + res[803].firstMatch("aabxyzzzpqrrrabbxyyyypqAzz"), 2376); + assertToStringEquals("aaabxyzzzzpqrrrabbxyyyypqAzz", + res[803].firstMatch("aaabxyzzzzpqrrrabbxyyyypqAzz"), 2377); + assertToStringEquals("aaaabxyzzzzpqrrrabbxyyyypqAzz", + res[803].firstMatch("aaaabxyzzzzpqrrrabbxyyyypqAzz"), 2378); + assertToStringEquals("abcxyzzpqrrrabbxyyyypqAzz", + res[803].firstMatch("abcxyzzpqrrrabbxyyyypqAzz"), 2379); + assertToStringEquals("aabcxyzzzpqrrrabbxyyyypqAzz", + res[803].firstMatch("aabcxyzzzpqrrrabbxyyyypqAzz"), 2380); + assertToStringEquals("aaabcxyzzzzpqrrrabbxyyyypqAzz", + res[803].firstMatch("aaabcxyzzzzpqrrrabbxyyyypqAzz"), 2381); + assertToStringEquals("aaaabcxyzzzzpqrrrabbxyyyypqAzz", + res[803].firstMatch("aaaabcxyzzzzpqrrrabbxyyyypqAzz"), 2382); + assertToStringEquals("aaaabcxyzzzzpqrrrabbbxyyyypqAzz", + res[803].firstMatch("aaaabcxyzzzzpqrrrabbbxyyyypqAzz"), 2383); + assertToStringEquals("aaaabcxyzzzzpqrrrabbbxyyyyypqAzz", + res[803].firstMatch("aaaabcxyzzzzpqrrrabbbxyyyyypqAzz"), 2384); + assertToStringEquals("aaabcxyzpqrrrabbxyyyypABzz", + res[803].firstMatch("aaabcxyzpqrrrabbxyyyypABzz"), 2385); + assertToStringEquals("aaabcxyzpqrrrabbxyyyypABBzz", + res[803].firstMatch("aaabcxyzpqrrrabbxyyyypABBzz"), 2386); + assertToStringEquals("aaabxyzpqrrrabbxyyyypqAzz", + res[803].firstMatch(">>>aaabxyzpqrrrabbxyyyypqAzz"), 2387); + assertToStringEquals("aaaabxyzpqrrrabbxyyyypqAzz", + res[803].firstMatch(">aaaabxyzpqrrrabbxyyyypqAzz"), 2388); + assertToStringEquals("abcxyzpqrrrabbxyyyypqAzz", + res[803].firstMatch(">>>>abcxyzpqrrrabbxyyyypqAzz"), 2389); + assertNull(res[803].firstMatch("*** Failers"), 2390); + assertNull(res[803].firstMatch("abxyzpqrrabbxyyyypqAzz"), 2391); + assertNull(res[803].firstMatch("abxyzpqrrrrabbxyyyypqAzz"), 2392); + assertNull(res[803].firstMatch("abxyzpqrrrabxyyyypqAzz"), 2393); + assertNull(res[803].firstMatch("aaaabcxyzzzzpqrrrabbbxyyyyyypqAzz"), 2394); + assertNull(res[803].firstMatch("aaaabcxyzzzzpqrrrabbbxyyypqAzz"), 2395); + assertNull(res[803].firstMatch("aaabcxyzpqrrrabbxyyyypqqqqqqqAzz"), 2396); + assertToStringEquals("abczz,abc", res[804].firstMatch("abczz"), 2397); + assertToStringEquals("abcabczz,abc", res[804].firstMatch("abcabczz"), 2398); + assertNull(res[804].firstMatch("*** Failers"), 2399); + assertNull(res[804].firstMatch("zz"), 2400); + assertNull(res[804].firstMatch("abcabcabczz"), 2401); + assertNull(res[804].firstMatch(">>abczz"), 2402); + assertToStringEquals("bc,b", res[805].firstMatch("bc"), 2403); + assertToStringEquals("bbc,b", res[805].firstMatch("bbc"), 2404); + assertToStringEquals("bbbc,bb", res[805].firstMatch("bbbc"), 2405); + assertToStringEquals("bac,a", res[805].firstMatch("bac"), 2406); + assertToStringEquals("bbac,a", res[805].firstMatch("bbac"), 2407); + assertToStringEquals("aac,a", res[805].firstMatch("aac"), 2408); + assertToStringEquals( + "abbbbbbbbbbbc,bbbbbbbbbbb", res[805].firstMatch("abbbbbbbbbbbc"), 2409); + assertToStringEquals( + "bbbbbbbbbbbac,a", res[805].firstMatch("bbbbbbbbbbbac"), 2410); + assertNull(res[805].firstMatch("*** Failers"), 2411); + assertNull(res[805].firstMatch("aaac"), 2412); + assertNull(res[805].firstMatch("abbbbbbbbbbbac"), 2413); + assertToStringEquals("bc,b", res[806].firstMatch("bc"), 2414); + assertToStringEquals("bbc,bb", res[806].firstMatch("bbc"), 2415); + assertToStringEquals("bbbc,bbb", res[806].firstMatch("bbbc"), 2416); + assertToStringEquals("bac,a", res[806].firstMatch("bac"), 2417); + assertToStringEquals("bbac,a", res[806].firstMatch("bbac"), 2418); + assertToStringEquals("aac,a", res[806].firstMatch("aac"), 2419); + assertToStringEquals( + "abbbbbbbbbbbc,bbbbbbbbbbb", res[806].firstMatch("abbbbbbbbbbbc"), 2420); + assertToStringEquals( + "bbbbbbbbbbbac,a", res[806].firstMatch("bbbbbbbbbbbac"), 2421); + assertNull(res[806].firstMatch("*** Failers"), 2422); + assertNull(res[806].firstMatch("aaac"), 2423); + assertNull(res[806].firstMatch("abbbbbbbbbbbac"), 2424); + assertToStringEquals("bbc,bb", res[806].firstMatch("bbc"), 2425); + assertToStringEquals("babc,ba", res[807].firstMatch("babc"), 2426); + assertToStringEquals("bbabc,ba", res[807].firstMatch("bbabc"), 2427); + assertToStringEquals("bababc,ba", res[807].firstMatch("bababc"), 2428); + assertNull(res[807].firstMatch("*** Failers"), 2429); + assertNull(res[807].firstMatch("bababbc"), 2430); + assertNull(res[807].firstMatch("babababc"), 2431); + assertToStringEquals("babc,ba", res[808].firstMatch("babc"), 2432); + assertToStringEquals("bbabc,ba", res[808].firstMatch("bbabc"), 2433); + assertToStringEquals("bababc,ba", res[808].firstMatch("bababc"), 2434); + assertNull(res[808].firstMatch("*** Failers"), 2435); + assertNull(res[808].firstMatch("bababbc"), 2436); + assertNull(res[808].firstMatch("babababc"), 2437); + assertThrows(() => new RegExp(r"^\\ca\\cA\\c[\\c{\\c:"), 2438); + assertNull(res[808].firstMatch("\x01\x01e;z"), 2439); + assertToStringEquals("a", res[809].firstMatch("athing"), 2440); + assertToStringEquals("b", res[809].firstMatch("bthing"), 2441); + assertToStringEquals("]", res[809].firstMatch("]thing"), 2442); + assertToStringEquals("c", res[809].firstMatch("cthing"), 2443); + assertToStringEquals("d", res[809].firstMatch("dthing"), 2444); + assertToStringEquals("e", res[809].firstMatch("ething"), 2445); + assertNull(res[809].firstMatch("*** Failers"), 2446); + assertNull(res[809].firstMatch("fthing"), 2447); + assertNull(res[809].firstMatch("[thing"), 2448); + assertNull(res[809].firstMatch("\\thing"), 2449); + assertNull(res[810].firstMatch("]thing"), 2450); + assertNull(res[810].firstMatch("cthing"), 2451); + assertNull(res[810].firstMatch("dthing"), 2452); + assertNull(res[810].firstMatch("ething"), 2453); + assertNull(res[810].firstMatch("*** Failers"), 2454); + assertNull(res[810].firstMatch("athing"), 2455); + assertNull(res[810].firstMatch("fthing"), 2456); + assertToStringEquals("f", res[811].firstMatch("fthing"), 2457); + assertToStringEquals("[", res[811].firstMatch("[thing"), 2458); + assertToStringEquals("\\", res[811].firstMatch("\\thing"), 2459); + assertToStringEquals("*", res[811].firstMatch("*** Failers"), 2460); + assertNull(res[811].firstMatch("athing"), 2461); + assertNull(res[811].firstMatch("bthing"), 2462); + assertNull(res[811].firstMatch("]thing"), 2463); + assertNull(res[811].firstMatch("cthing"), 2464); + assertNull(res[811].firstMatch("dthing"), 2465); + assertNull(res[811].firstMatch("ething"), 2466); + assertNull(res[812].firstMatch("athing"), 2467); + assertNull(res[812].firstMatch("fthing"), 2468); + assertNull(res[812].firstMatch("*** Failers"), 2469); + assertNull(res[812].firstMatch("]thing"), 2470); + assertNull(res[812].firstMatch("cthing"), 2471); + assertNull(res[812].firstMatch("dthing"), 2472); + assertNull(res[812].firstMatch("ething"), 2473); + assertNull(res[812].firstMatch("\ufffd"), 2474); + assertNull(res[812].firstMatch("\ufffd"), 2475); + assertToStringEquals("0", res[813].firstMatch("0"), 2476); + assertToStringEquals("1", res[813].firstMatch("1"), 2477); + assertToStringEquals("2", res[813].firstMatch("2"), 2478); + assertToStringEquals("3", res[813].firstMatch("3"), 2479); + assertToStringEquals("4", res[813].firstMatch("4"), 2480); + assertToStringEquals("5", res[813].firstMatch("5"), 2481); + assertToStringEquals("6", res[813].firstMatch("6"), 2482); + assertToStringEquals("7", res[813].firstMatch("7"), 2483); + assertToStringEquals("8", res[813].firstMatch("8"), 2484); + assertToStringEquals("9", res[813].firstMatch("9"), 2485); + assertToStringEquals("10", res[813].firstMatch("10"), 2486); + assertToStringEquals("100", res[813].firstMatch("100"), 2487); + assertNull(res[813].firstMatch("*** Failers"), 2488); + assertNull(res[813].firstMatch("abc"), 2489); + assertToStringEquals("enter", res[814].firstMatch("enter"), 2490); + assertToStringEquals("inter", res[814].firstMatch("inter"), 2491); + assertToStringEquals("uponter", res[814].firstMatch("uponter"), 2492); + assertToStringEquals("xxx0", res[815].firstMatch("xxx0"), 2493); + assertToStringEquals("xxx1234", res[815].firstMatch("xxx1234"), 2494); + assertNull(res[815].firstMatch("*** Failers"), 2495); + assertNull(res[815].firstMatch("xxx"), 2496); + assertToStringEquals("x123", res[816].firstMatch("x123"), 2497); + assertToStringEquals("xx123", res[816].firstMatch("xx123"), 2498); + assertToStringEquals("123456", res[816].firstMatch("123456"), 2499); + assertNull(res[816].firstMatch("*** Failers"), 2500); + assertNull(res[816].firstMatch("123"), 2501); + assertToStringEquals("x1234", res[816].firstMatch("x1234"), 2502); + assertToStringEquals("x123", res[817].firstMatch("x123"), 2503); + assertToStringEquals("xx123", res[817].firstMatch("xx123"), 2504); + assertToStringEquals("123456", res[817].firstMatch("123456"), 2505); + assertNull(res[817].firstMatch("*** Failers"), 2506); + assertNull(res[817].firstMatch("123"), 2507); + assertToStringEquals("x1234", res[817].firstMatch("x1234"), 2508); + assertToStringEquals("abc!pqr=apquxz.ixr.zzz.ac.uk,abc,pqr", + res[818].firstMatch("abc!pqr=apquxz.ixr.zzz.ac.uk"), 2509); + assertNull(res[818].firstMatch("*** Failers"), 2510); + assertNull(res[818].firstMatch("!pqr=apquxz.ixr.zzz.ac.uk"), 2511); + assertNull(res[818].firstMatch("abc!=apquxz.ixr.zzz.ac.uk"), 2512); + assertNull(res[818].firstMatch("abc!pqr=apquxz:ixr.zzz.ac.uk"), 2513); + assertNull(res[818].firstMatch("abc!pqr=apquxz.ixr.zzz.ac.ukk"), 2514); + assertToStringEquals( + ":", res[819].firstMatch("Well, we need a colon: somewhere"), 2515); + assertNull(res[819].firstMatch("*** Fail if we don't"), 2516); + assertToStringEquals("0abc,0abc", res[820].firstMatch("0abc"), 2517); + assertToStringEquals("abc,abc", res[820].firstMatch("abc"), 2518); + assertToStringEquals("fed,fed", res[820].firstMatch("fed"), 2519); + assertToStringEquals("E,E", res[820].firstMatch("E"), 2520); + assertToStringEquals("::,::", res[820].firstMatch("::"), 2521); + assertToStringEquals("5f03:12C0::932e,5f03:12C0::932e", + res[820].firstMatch("5f03:12C0::932e"), 2522); + assertToStringEquals("def,def", res[820].firstMatch("fed def"), 2523); + assertToStringEquals("ff,ff", res[820].firstMatch("Any old stuff"), 2524); + assertNull(res[820].firstMatch("*** Failers"), 2525); + assertNull(res[820].firstMatch("0zzz"), 2526); + assertNull(res[820].firstMatch("gzzz"), 2527); + assertNull(res[820].firstMatch("fed "), 2528); + assertNull(res[820].firstMatch("Any old rubbish"), 2529); + assertToStringEquals(".1.2.3,1,2,3", res[821].firstMatch(".1.2.3"), 2530); + assertToStringEquals( + "A.12.123.0,12,123,0", res[821].firstMatch("A.12.123.0"), 2531); + assertNull(res[821].firstMatch("*** Failers"), 2532); + assertNull(res[821].firstMatch(".1.2.3333"), 2533); + assertNull(res[821].firstMatch("1.2.3"), 2534); + assertNull(res[821].firstMatch("1234.2.3"), 2535); + assertToStringEquals("1 IN SOA non-sp1 non-sp2(,1,non-sp1,non-sp2", + res[822].firstMatch("1 IN SOA non-sp1 non-sp2("), 2536); + assertToStringEquals( + "1 IN SOA non-sp1 non-sp2 (,1,non-sp1,non-sp2", + res[822].firstMatch("1 IN SOA non-sp1 non-sp2 ("), + 2537); + assertNull(res[822].firstMatch("*** Failers"), 2538); + assertNull(res[822].firstMatch("1IN SOA non-sp1 non-sp2("), 2539); + assertToStringEquals("a.,", res[823].firstMatch("a."), 2540); + assertToStringEquals("Z.,", res[823].firstMatch("Z."), 2541); + assertToStringEquals("2.,", res[823].firstMatch("2."), 2542); + assertToStringEquals( + "ab-c.pq-r.,.pq-r", res[823].firstMatch("ab-c.pq-r."), 2543); + assertToStringEquals( + "sxk.zzz.ac.uk.,.uk", res[823].firstMatch("sxk.zzz.ac.uk."), 2544); + assertToStringEquals("x-.y-.,.y-", res[823].firstMatch("x-.y-."), 2545); + assertNull(res[823].firstMatch("*** Failers"), 2546); + assertNull(res[823].firstMatch("-abc.peq."), 2547); + assertToStringEquals("*.a,,,", res[824].firstMatch("*.a"), 2548); + assertToStringEquals("*.b0-a,0-a,,", res[824].firstMatch("*.b0-a"), 2549); + assertToStringEquals( + "*.c3-b.c,3-b,.c,", res[824].firstMatch("*.c3-b.c"), 2550); + assertToStringEquals( + "*.c-a.b-c,-a,.b-c,-c", res[824].firstMatch("*.c-a.b-c"), 2551); + assertNull(res[824].firstMatch("*** Failers"), 2552); + assertNull(res[824].firstMatch("*.0"), 2553); + assertNull(res[824].firstMatch("*.a-"), 2554); + assertNull(res[824].firstMatch("*.a-b.c-"), 2555); + assertNull(res[824].firstMatch("*.c-a.0-c"), 2556); + assertToStringEquals("abde,de,abd,e", res[825].firstMatch("abde"), 2557); + assertToStringEquals("abdf,,abd,f", res[826].firstMatch("abdf"), 2558); + assertToStringEquals("ab,abcd,cd,ab", res[827].firstMatch("abcd"), 2559); + assertToStringEquals("a.b.c.d,.d", res[828].firstMatch("a.b.c.d"), 2560); + assertToStringEquals("A.B.C.D,.D", res[828].firstMatch("A.B.C.D"), 2561); + assertToStringEquals( + "a.b.c.1.2.3.C,.C", res[828].firstMatch("a.b.c.1.2.3.C"), 2562); + assertToStringEquals("\"1234\",", res[829].firstMatch("\"1234\""), 2563); + assertToStringEquals("\"abcd\" ;,;", res[829].firstMatch("\"abcd\" ;"), 2564); + assertToStringEquals( + "\"\" ; rhubarb,; rhubarb", res[829].firstMatch("\"\" ; rhubarb"), 2565); + assertNull(res[829].firstMatch("*** Failers"), 2566); + assertNull(res[829].firstMatch("\"1234\" : things"), 2567); + assertNull(res[830].firstMatch("\\"), 2568); + assertNull(res[830].firstMatch("*** Failers"), 2569); + assertToStringEquals("ab c", res[831].firstMatch("ab c"), 2570); + assertNull(res[831].firstMatch("*** Failers"), 2571); + assertNull(res[831].firstMatch("abc"), 2572); + assertNull(res[831].firstMatch("ab cde"), 2573); + assertToStringEquals("ab c", res[831].firstMatch("ab c"), 2574); + assertNull(res[831].firstMatch("*** Failers"), 2575); + assertNull(res[831].firstMatch("abc"), 2576); + assertNull(res[831].firstMatch("ab cde"), 2577); + assertToStringEquals("a bcd", res[832].firstMatch("a bcd"), 2578); + assertNull(res[832].firstMatch("a b d"), 2579); + assertNull(res[832].firstMatch("*** Failers"), 2580); + assertNull(res[832].firstMatch("abcd"), 2581); + assertNull(res[832].firstMatch("ab d"), 2582); + assertToStringEquals("abcdefhijklm,abc,bc,c,def,ef,f,hij,ij,j,klm,lm,m", + res[833].firstMatch("abcdefhijklm"), 2583); + assertToStringEquals("abcdefhijklm,bc,c,ef,f,ij,j,lm,m", + res[834].firstMatch("abcdefhijklm"), 2584); + assertNull(res[835].firstMatch("a+ Z0+\x08\n\x1d\x12"), 2585); + assertNull(res[835].firstMatch(".^\$(*+)|{?,?}"), 2586); + assertToStringEquals("z", res[836].firstMatch("z"), 2587); + assertToStringEquals("az", res[836].firstMatch("az"), 2588); + assertToStringEquals("aaaz", res[836].firstMatch("aaaz"), 2589); + assertToStringEquals("a", res[836].firstMatch("a"), 2590); + assertToStringEquals("aa", res[836].firstMatch("aa"), 2591); + assertToStringEquals("aaaa", res[836].firstMatch("aaaa"), 2592); + assertToStringEquals("a", res[836].firstMatch("a+"), 2593); + assertToStringEquals("aa", res[836].firstMatch("aa+"), 2594); + assertToStringEquals("z", res[837].firstMatch("z"), 2595); + assertToStringEquals("a", res[837].firstMatch("az"), 2596); + assertToStringEquals("a", res[837].firstMatch("aaaz"), 2597); + assertToStringEquals("a", res[837].firstMatch("a"), 2598); + assertToStringEquals("a", res[837].firstMatch("aa"), 2599); + assertToStringEquals("a", res[837].firstMatch("aaaa"), 2600); + assertToStringEquals("a", res[837].firstMatch("a+"), 2601); + assertToStringEquals("a", res[837].firstMatch("aa+"), 2602); + assertToStringEquals("az", res[838].firstMatch("az"), 2603); + assertToStringEquals("aaaz", res[838].firstMatch("aaaz"), 2604); + assertToStringEquals("aa", res[838].firstMatch("aa"), 2605); + assertToStringEquals("aaaa", res[838].firstMatch("aaaa"), 2606); + assertToStringEquals("aa", res[838].firstMatch("aa+"), 2607); + assertToStringEquals("az", res[839].firstMatch("az"), 2608); + assertToStringEquals("aa", res[839].firstMatch("aaaz"), 2609); + assertToStringEquals("aa", res[839].firstMatch("aa"), 2610); + assertToStringEquals("aa", res[839].firstMatch("aaaa"), 2611); + assertToStringEquals("aa", res[839].firstMatch("aa+"), 2612); + assertToStringEquals("1234567890", res[840].firstMatch("1234567890"), 2613); + assertToStringEquals("12345678ab", res[840].firstMatch("12345678ab"), 2614); + assertToStringEquals("12345678__", res[840].firstMatch("12345678__"), 2615); + assertNull(res[840].firstMatch("*** Failers"), 2616); + assertNull(res[840].firstMatch("1234567"), 2617); + assertToStringEquals("uoie", res[841].firstMatch("uoie"), 2618); + assertToStringEquals("1234", res[841].firstMatch("1234"), 2619); + assertToStringEquals("12345", res[841].firstMatch("12345"), 2620); + assertToStringEquals("aaaaa", res[841].firstMatch("aaaaa"), 2621); + assertNull(res[841].firstMatch("*** Failers"), 2622); + assertNull(res[841].firstMatch("123456"), 2623); + assertToStringEquals("uoie", res[842].firstMatch("uoie"), 2624); + assertToStringEquals("1234", res[842].firstMatch("1234"), 2625); + assertToStringEquals("1234", res[842].firstMatch("12345"), 2626); + assertToStringEquals("aaaa", res[842].firstMatch("aaaaa"), 2627); + assertToStringEquals("1234", res[842].firstMatch("123456"), 2628); + assertToStringEquals("From abcd Mon Sep 01 12:33,abcd", + res[843].firstMatch("From abcd Mon Sep 01 12:33:02 1997"), 2629); + assertToStringEquals("From abcd Mon Sep 01 12:33,Sep ", + res[844].firstMatch("From abcd Mon Sep 01 12:33:02 1997"), 2630); + assertToStringEquals("From abcd Mon Sep 1 12:33,Sep ", + res[844].firstMatch("From abcd Mon Sep 1 12:33:02 1997"), 2631); + assertNull(res[844].firstMatch("*** Failers"), 2632); + assertNull(res[844].firstMatch("From abcd Sep 01 12:33:02 1997"), 2633); + assertNull(res[845].firstMatch("12\n34"), 2634); + assertNull(res[845].firstMatch("12\x0d34"), 2635); + assertToStringEquals( + "brown", res[846].firstMatch("the quick brown\x09 fox"), 2636); + assertToStringEquals("foolish see?,lish see?", + res[847].firstMatch("foobar is foolish see?"), 2637); + assertToStringEquals( + "rowbar etc, etc", res[848].firstMatch("foobar crowbar etc"), 2638); + assertToStringEquals("barrel,rel", res[848].firstMatch("barrel"), 2639); + assertToStringEquals("2barrel,rel", res[848].firstMatch("2barrel"), 2640); + assertToStringEquals("A barrel,rel", res[848].firstMatch("A barrel"), 2641); + assertToStringEquals("abc,abc", res[849].firstMatch("abc456"), 2642); + assertNull(res[849].firstMatch("*** Failers"), 2643); + assertNull(res[849].firstMatch("abc123"), 2644); + assertToStringEquals("1234", res[850].firstMatch("1234"), 2645); + assertToStringEquals("1234", res[851].firstMatch("1234"), 2646); + assertToStringEquals("abcd", res[852].firstMatch("abcd"), 2647); + assertToStringEquals("abcd", res[853].firstMatch("abcd"), 2648); + assertToStringEquals("abc", res[854].firstMatch("the abc"), 2649); + assertNull(res[854].firstMatch("*** Failers"), 2650); + assertNull(res[854].firstMatch("abc"), 2651); + assertToStringEquals("abc", res[855].firstMatch("abc"), 2652); + assertNull(res[855].firstMatch("*** Failers"), 2653); + assertNull(res[855].firstMatch("the abc"), 2654); + assertToStringEquals("aabb,b", res[856].firstMatch("aabbbbb"), 2655); + assertToStringEquals("aabbbbb,abbbbb", res[857].firstMatch("aabbbbb"), 2656); + assertToStringEquals("aa,a", res[858].firstMatch("aabbbbb"), 2657); + assertToStringEquals("aabb,b", res[859].firstMatch("aabbbbb"), 2658); + assertToStringEquals("Alan Other ", + res[860].firstMatch("Alan Other "), 2659); + assertToStringEquals( + "user@dom.ain", res[860].firstMatch(""), 2660); + assertToStringEquals( + "user@dom.ain", res[860].firstMatch("user@dom.ain"), 2661); + assertToStringEquals( + "\"A. Other\" (a comment)", + res[860].firstMatch("\"A. Other\" (a comment)"), + 2662); + assertToStringEquals(" Other (a comment)", + res[860].firstMatch("A. Other (a comment)"), 2663); + assertToStringEquals( + "\"/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/\"@x400-re.lay", + res[860].firstMatch( + "\"/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/\"@x400-re.lay"), + 2664); + assertToStringEquals("user@some.where", + res[860].firstMatch("A missing angle ", + res[861].firstMatch("Alan Other "), 2668); + assertToStringEquals( + "user@dom.ain", res[861].firstMatch(""), 2669); + assertToStringEquals( + "user@dom.ain", res[861].firstMatch("user@dom.ain"), 2670); + assertToStringEquals( + "\"A. Other\" ", + res[861].firstMatch("\"A. Other\" (a comment)"), + 2671); + assertToStringEquals(" Other ", + res[861].firstMatch("A. Other (a comment)"), 2672); + assertToStringEquals( + "\"/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/\"@x400-re.lay", + res[861].firstMatch( + "\"/s=user/ou=host/o=place/prmd=uu.yy/admd= /c=gb/\"@x400-re.lay"), + 2673); + assertToStringEquals("user@some.where", + res[861].firstMatch("A missing angle new RegExp(r"a(?)b"), 2834); + assertNull(res[925].firstMatch("ab "), 2835); + assertToStringEquals("foo table,foo,table", + res[926].firstMatch("Food is on the foo table"), 2836); + assertToStringEquals( + "food is under the bar in the bar,d is under the bar in the ", + res[927].firstMatch("The food is under the bar in the barn."), + 2837); + assertToStringEquals("food is under the bar,d is under the ", + res[928].firstMatch("The food is under the bar in the barn."), 2838); + assertToStringEquals("I have 2 numbers: 53147,I have 2 numbers: 53147,", + res[929].firstMatch("I have 2 numbers: 53147"), 2839); + assertToStringEquals("I have 2 numbers: 53147,I have 2 numbers: 5314,7", + res[930].firstMatch("I have 2 numbers: 53147"), 2840); + assertToStringEquals( + ",,", res[931].firstMatch("I have 2 numbers: 53147"), 2841); + assertToStringEquals("I have 2,I have ,2", + res[932].firstMatch("I have 2 numbers: 53147"), 2842); + assertToStringEquals("I have 2 numbers: 53147,I have 2 numbers: 5314,7", + res[933].firstMatch("I have 2 numbers: 53147"), 2843); + assertToStringEquals("I have 2 numbers: 53147,I have 2 numbers: ,53147", + res[934].firstMatch("I have 2 numbers: 53147"), 2844); + assertToStringEquals("I have 2 numbers: 53147,I have 2 numbers: ,53147", + res[935].firstMatch("I have 2 numbers: 53147"), 2845); + assertToStringEquals("I have 2 numbers: 53147,I have 2 numbers: ,53147", + res[936].firstMatch("I have 2 numbers: 53147"), 2846); + assertToStringEquals("AB", res[937].firstMatch("ABC123"), 2847); + assertToStringEquals(" ", res[937].firstMatch(" "), 2848); + assertToStringEquals("ABC,ABC", res[938].firstMatch("ABC445"), 2849); + assertNull(res[938].firstMatch("*** Failers"), 2850); + assertNull(res[938].firstMatch("ABC123"), 2851); + assertToStringEquals("W46]", res[939].firstMatch("W46]789 "), 2852); + assertToStringEquals("-46]", res[939].firstMatch("-46]789"), 2853); + assertNull(res[939].firstMatch("*** Failers"), 2854); + assertNull(res[939].firstMatch("Wall"), 2855); + assertNull(res[939].firstMatch("Zebra"), 2856); + assertNull(res[939].firstMatch("42"), 2857); + assertNull(res[939].firstMatch("[abcd] "), 2858); + assertNull(res[939].firstMatch("]abcd["), 2859); + assertNull(res[939].firstMatch(" "), 2860); + assertToStringEquals("W", res[940].firstMatch("W46]789 "), 2861); + assertToStringEquals("W", res[940].firstMatch("Wall"), 2862); + assertToStringEquals("Z", res[940].firstMatch("Zebra"), 2863); + assertToStringEquals("X", res[940].firstMatch("Xylophone "), 2864); + assertToStringEquals("4", res[940].firstMatch("42"), 2865); + assertToStringEquals("[", res[940].firstMatch("[abcd] "), 2866); + assertToStringEquals("]", res[940].firstMatch("]abcd["), 2867); + assertToStringEquals("\\", res[940].firstMatch("\\backslash "), 2868); + assertNull(res[940].firstMatch("*** Failers"), 2869); + assertNull(res[940].firstMatch("-46]789"), 2870); + assertNull(res[940].firstMatch("well"), 2871); + assertToStringEquals("01/01/2000", res[941].firstMatch("01/01/2000"), 2872); + assertToStringEquals("01/01/2000", res[941].firstMatch("01/01/2000"), 2872); + assertToStringEquals(",", res[944].firstMatch("bcd"), 2873); + assertToStringEquals(",", res[944].firstMatch("abc"), 2874); + assertToStringEquals(",", res[944].firstMatch("aab "), 2875); + assertToStringEquals(",", res[945].firstMatch("bcd"), 2876); + assertToStringEquals("a,a", res[945].firstMatch("abc"), 2877); + assertToStringEquals("a,a", res[945].firstMatch("aab "), 2878); + assertToStringEquals(",", res[946].firstMatch("bcd"), 2879); + assertToStringEquals("a,a", res[946].firstMatch("abc"), 2880); + assertToStringEquals("aa,a", res[946].firstMatch("aab "), 2881); + assertToStringEquals(",", res[947].firstMatch("bcd"), 2882); + assertToStringEquals("a,a", res[947].firstMatch("abc"), 2883); + assertToStringEquals("aa,a", res[947].firstMatch("aab"), 2884); + assertToStringEquals("aaa,a", res[947].firstMatch("aaa "), 2885); + assertToStringEquals(",", res[948].firstMatch("bcd"), 2886); + assertToStringEquals("a,a", res[948].firstMatch("abc"), 2887); + assertToStringEquals("aa,a", res[948].firstMatch("aab"), 2888); + assertToStringEquals("aaa,a", res[948].firstMatch("aaa"), 2889); + assertToStringEquals("aaaaaaaa,a", res[948].firstMatch("aaaaaaaa "), 2890); + assertNull(res[949].firstMatch("bcd"), 2891); + assertToStringEquals("a,a", res[949].firstMatch("abc"), 2892); + assertToStringEquals("a,a", res[949].firstMatch("aab "), 2893); + assertNull(res[950].firstMatch("bcd"), 2894); + assertToStringEquals("a,a", res[950].firstMatch("abc"), 2895); + assertToStringEquals("aa,a", res[950].firstMatch("aab "), 2896); + assertNull(res[951].firstMatch("bcd"), 2897); + assertToStringEquals("a,a", res[951].firstMatch("abc"), 2898); + assertToStringEquals("aa,a", res[951].firstMatch("aab"), 2899); + assertToStringEquals("aaa,a", res[951].firstMatch("aaa "), 2900); + assertNull(res[952].firstMatch("bcd"), 2901); + assertToStringEquals("a,a", res[952].firstMatch("abc"), 2902); + assertToStringEquals("aa,a", res[952].firstMatch("aab"), 2903); + assertToStringEquals("aaa,a", res[952].firstMatch("aaa"), 2904); + assertToStringEquals("aaaaaaaa,a", res[952].firstMatch("aaaaaaaa "), 2905); + assertToStringEquals( + "bib.gif", res[953].firstMatch("borfle\nbib.gif\nno"), 2906); + assertToStringEquals( + "bib.gif", res[954].firstMatch("borfle\nbib.gif\nno"), 2907); + assertToStringEquals( + "bib.gif", res[955].firstMatch("borfle\nbib.gif\nno"), 2908); + assertToStringEquals( + "bib.gif", res[956].firstMatch("borfle\nbib.gif\nno"), 2909); + assertToStringEquals( + "bib.gif", res[957].firstMatch("borfle\nbib.gif\nno"), 2910); + assertToStringEquals("no", res[958].firstMatch("borfle\nbib.gif\nno"), 2911); + assertToStringEquals( + "borfle", res[959].firstMatch("borfle\nbib.gif\nno"), 2912); + assertToStringEquals("no", res[960].firstMatch("borfle\nbib.gif\nno"), 2913); + assertToStringEquals( + "borfle", res[961].firstMatch("borfle\nbib.gif\nno"), 2914); + assertToStringEquals("", res[962].firstMatch("borfle\nbib.gif\nno\n"), 2915); + assertToStringEquals( + "borfle", res[963].firstMatch("borfle\nbib.gif\nno\n"), 2916); + assertToStringEquals("", res[964].firstMatch("borfle\nbib.gif\nno\n"), 2917); + assertToStringEquals( + "borfle", res[965].firstMatch("borfle\nbib.gif\nno\n"), 2918); + assertToStringEquals( + "1234X,1234X", res[966].firstMatch("abcde\n1234Xyz"), 2919); + assertToStringEquals("B,B", res[966].firstMatch("BarFoo "), 2920); + assertNull(res[966].firstMatch("*** Failers"), 2921); + assertNull(res[966].firstMatch("abcde\nBar "), 2922); + assertToStringEquals( + "1234X,1234X", res[967].firstMatch("abcde\n1234Xyz"), 2923); + assertToStringEquals("B,B", res[967].firstMatch("BarFoo "), 2924); + assertToStringEquals("B,B", res[967].firstMatch("abcde\nBar "), 2925); + assertToStringEquals( + "1234X,1234X", res[968].firstMatch("abcde\n1234Xyz"), 2926); + assertToStringEquals("B,B", res[968].firstMatch("BarFoo "), 2927); + assertNull(res[968].firstMatch("*** Failers"), 2928); + assertNull(res[968].firstMatch("abcde\nBar "), 2929); + assertToStringEquals( + "1234X,1234X", res[969].firstMatch("abcde\n1234Xyz"), 2930); + assertToStringEquals("B,B", res[969].firstMatch("BarFoo "), 2931); + assertToStringEquals("B,B", res[969].firstMatch("abcde\nBar "), 2932); + assertToStringEquals( + "1234X,1234X", res[969].firstMatch("abcde\n1234Xyz"), 2933); + assertToStringEquals("B,B", res[969].firstMatch("BarFoo "), 2934); + assertNull(res[969].firstMatch("*** Failers "), 2935); + assertToStringEquals("B,B", res[969].firstMatch("abcde\nBar "), 2936); + assertToStringEquals( + "1234X,1234X", res[969].firstMatch("abcde\n1234Xyz"), 2937); + assertToStringEquals("B,B", res[969].firstMatch("BarFoo "), 2938); + assertNull(res[969].firstMatch("*** Failers "), 2939); + assertToStringEquals("B,B", res[969].firstMatch("abcde\nBar "), 2940); + assertNull(res[970].firstMatch("**** Failers"), 2941); + assertNull(res[970].firstMatch("abc\nB"), 2942); + assertNull(res[970].firstMatch(" "), 2943); + assertNull(res[970].firstMatch("abc\nB"), 2944); + assertNull(res[970].firstMatch("abc\nB"), 2945); + assertNull(res[970].firstMatch(" "), 2946); + assertNull(res[970].firstMatch("abc\nB"), 2947); + assertNull(res[970].firstMatch("abc\nB"), 2948); + assertToStringEquals("B", res[970].firstMatch("B\n"), 2949); + assertToStringEquals( + "123456654321", res[971].firstMatch("123456654321"), 2950); + assertToStringEquals( + "123456654321", res[972].firstMatch("123456654321 "), 2951); + assertToStringEquals( + "123456654321", res[973].firstMatch("123456654321"), 2952); + assertToStringEquals( + "abcabcabcabc", res[974].firstMatch("abcabcabcabc"), 2953); + assertToStringEquals( + "abcabcabcabc", res[975].firstMatch("abcabcabcabc"), 2954); + assertToStringEquals( + "abcabcabcabc,c", res[976].firstMatch("abcabcabcabc "), 2955); + assertToStringEquals("n", res[977].firstMatch("n"), 2956); + assertNull(res[977].firstMatch("*** Failers "), 2957); + assertNull(res[977].firstMatch("z "), 2958); + assertToStringEquals("abcd", res[978].firstMatch("abcd"), 2959); + assertNull(res[978].firstMatch("*** Failers"), 2960); + assertNull(res[978].firstMatch("abce "), 2961); + assertToStringEquals("abe", res[979].firstMatch("abe"), 2962); + assertNull(res[979].firstMatch("*** Failers"), 2963); + assertNull(res[979].firstMatch("abcde "), 2964); + assertToStringEquals("abd,", res[980].firstMatch("abd"), 2965); + assertNull(res[980].firstMatch("*** Failers"), 2966); + assertNull(res[980].firstMatch("abcd "), 2967); + assertToStringEquals("a,", res[981].firstMatch("a"), 2968); + assertToStringEquals("ab,b", res[981].firstMatch("ab"), 2969); + assertToStringEquals("abbbb,bbbb", res[981].firstMatch("abbbb"), 2970); + assertToStringEquals("a,", res[981].firstMatch("*** Failers"), 2971); + assertNull(res[981].firstMatch("bbbbb "), 2972); + assertToStringEquals("abe", res[982].firstMatch("abe"), 2973); + assertNull(res[982].firstMatch("*** Failers"), 2974); + assertNull(res[982].firstMatch("ab1e "), 2975); + assertToStringEquals( + "\"quick\",quick", res[983].firstMatch("the \"quick\" brown fox"), 2976); + assertToStringEquals("\"the \\\"quick\\\" brown fox\", brown fox", + res[983].firstMatch("\"the \\\"quick\\\" brown fox\" "), 2977); + assertToStringEquals("", res[984].firstMatch("abc"), 2978); + assertToStringEquals("", res[985].firstMatch("abc "), 2979); + assertToStringEquals("", res[986].firstMatch("abc "), 2980); + // Dart does not have RegExp literals and thus no translatation of the below. + // assertThrows("var re = //;", 2981); + assertToStringEquals("", res[986].firstMatch("abc"), 2982); + assertToStringEquals("acb", res[988].firstMatch("acb"), 2983); + assertToStringEquals("a\nb", res[988].firstMatch("a\nb"), 2984); + assertToStringEquals("acb", res[989].firstMatch("acb"), 2985); + assertNull(res[989].firstMatch("*** Failers "), 2986); + assertNull(res[989].firstMatch("a\nb "), 2987); + assertToStringEquals("acb", res[990].firstMatch("acb"), 2988); + assertToStringEquals("a\nb", res[990].firstMatch("a\nb "), 2989); + assertToStringEquals("acb", res[991].firstMatch("acb"), 2990); + assertNull(res[991].firstMatch("a\nb "), 2991); + assertToStringEquals("bac,a", res[992].firstMatch("bac"), 2992); + assertToStringEquals("bbac,a", res[992].firstMatch("bbac"), 2993); + assertToStringEquals("bbbac,a", res[992].firstMatch("bbbac"), 2994); + assertToStringEquals("bbbbac,a", res[992].firstMatch("bbbbac"), 2995); + assertToStringEquals("bbbbbac,a", res[992].firstMatch("bbbbbac "), 2996); + assertToStringEquals("bac,a", res[993].firstMatch("bac"), 2997); + assertToStringEquals("bbac,a", res[993].firstMatch("bbac"), 2998); + assertToStringEquals("bbbac,a", res[993].firstMatch("bbbac"), 2999); + assertToStringEquals("bbbbac,a", res[993].firstMatch("bbbbac"), 3000); + assertToStringEquals("bbbbbac,a", res[993].firstMatch("bbbbbac "), 3001); + assertToStringEquals("x", res[994].firstMatch("x\nb\n"), 3002); + assertToStringEquals("x", res[994].firstMatch("a\x08x\n "), 3003); + assertNull(res[995].firstMatch("\x00{ab} "), 3004); + assertToStringEquals("CD,", res[996].firstMatch("CD "), 3005); + assertToStringEquals("CD,", res[997].firstMatch("CD "), 3006); + assertNull(res[997].firstMatch("foo"), 3007); + assertNull(res[997].firstMatch("catfood"), 3008); + assertNull(res[997].firstMatch("arfootle"), 3009); + assertNull(res[997].firstMatch("rfoosh"), 3010); + assertNull(res[997].firstMatch("*** Failers"), 3011); + assertNull(res[997].firstMatch("barfoo"), 3012); + assertNull(res[997].firstMatch("towbarfoo"), 3013); + assertNull(res[997].firstMatch("catfood"), 3014); + assertNull(res[997].firstMatch("*** Failers"), 3015); + assertNull(res[997].firstMatch("foo"), 3016); + assertNull(res[997].firstMatch("barfoo"), 3017); + assertNull(res[997].firstMatch("towbarfoo"), 3018); + assertNull(res[997].firstMatch("fooabar"), 3019); + assertNull(res[997].firstMatch("*** Failers"), 3020); + assertNull(res[997].firstMatch("bar"), 3021); + assertNull(res[997].firstMatch("foobbar"), 3022); + assertNull(res[997].firstMatch(" "), 3023); + assertNull(res[998].firstMatch("abc"), 3024); + assertNull(res[998].firstMatch("*** Failers"), 3025); + assertNull(res[998].firstMatch("abc\n "), 3026); + assertNull(res[998].firstMatch("qqq\nabc"), 3027); + assertNull(res[998].firstMatch("abc\nzzz"), 3028); + assertNull(res[998].firstMatch("qqq\nabc\nzzz"), 3029); + assertNull( + res[998].firstMatch( + "/this/is/a/very/long/line/in/deed/with/very/many/slashes/in/it/you/see/"), + 3030); + assertNull( + res[998].firstMatch( + "/this/is/a/very/long/line/in/deed/with/very/many/slashes/in/and/foo"), + 3031); + assertNull(res[998].firstMatch("1.230003938"), 3032); + assertNull(res[998].firstMatch("1.875000282"), 3033); + assertNull(res[998].firstMatch("*** Failers "), 3034); + assertNull(res[998].firstMatch("1.235 "), 3035); + assertNull( + res[998].firstMatch( + "now is the time for all good men to come to the aid of the party"), + 3036); + assertNull(res[998].firstMatch("*** Failers"), 3037); + assertNull( + res[998].firstMatch("this is not a line with only words and spaces!"), + 3038); + assertToStringEquals("12345a,12345,a", res[999].firstMatch("12345a"), 3039); + assertToStringEquals("12345,1234,5", res[999].firstMatch("12345+ "), 3040); + assertToStringEquals("12345a,12345,a", res[999].firstMatch("12345a"), 3041); + assertNull(res[999].firstMatch("*** Failers"), 3042); + assertToStringEquals("12345,1234,5", res[999].firstMatch("12345+ "), 3043); + assertNull(res[999].firstMatch("aaab"), 3044); + assertNull(res[999].firstMatch("aaab"), 3045); + assertNull(res[999].firstMatch("aaab"), 3046); + assertNull(res[999].firstMatch("aaabbbccc"), 3047); + assertNull(res[999].firstMatch("aaabbbbccccd"), 3048); + assertToStringEquals( + "aaabbbbcccc,ccc", res[1000].firstMatch("aaabbbbccccd"), 3049); + assertToStringEquals( + "abc,b", res[1000].firstMatch("((abc(ade)ufh()()x"), 3050); + assertNull(res[1000].firstMatch(""), 3051); + assertToStringEquals("abc,b", res[1000].firstMatch("(abc)"), 3052); + assertToStringEquals("abc,b", res[1000].firstMatch("(abc(def)xyz)"), 3053); + assertNull(res[1000].firstMatch("*** Failers"), 3054); + assertNull(res[1000].firstMatch("ab"), 3055); + assertNull(res[1000].firstMatch("Ab"), 3056); + assertNull(res[1000].firstMatch("*** Failers "), 3057); + assertNull(res[1000].firstMatch("aB"), 3058); + assertNull(res[1000].firstMatch("AB"), 3059); + assertNull(res[1000].firstMatch(" "), 3060); + assertToStringEquals("bc,b", res[1000].firstMatch("a bcd e"), 3061); + assertNull(res[1000].firstMatch("*** Failers"), 3062); + assertToStringEquals("c,", res[1000].firstMatch("a b cd e"), 3063); + assertToStringEquals("abc,b", res[1000].firstMatch("abcd e "), 3064); + assertToStringEquals("bc,b", res[1000].firstMatch("a bcde "), 3065); + assertToStringEquals("bc,b", res[1000].firstMatch("a bcde f"), 3066); + assertNull(res[1000].firstMatch("*** Failers"), 3067); + assertToStringEquals("abc,b", res[1000].firstMatch("abcdef "), 3068); + assertToStringEquals("abc,b", res[1000].firstMatch("abc"), 3069); + assertToStringEquals("c,", res[1000].firstMatch("aBc"), 3070); + assertNull(res[1000].firstMatch("*** Failers"), 3071); + assertNull(res[1000].firstMatch("abC"), 3072); + assertNull(res[1000].firstMatch("aBC "), 3073); + assertToStringEquals("bc,b", res[1000].firstMatch("Abc"), 3074); + assertToStringEquals("c,", res[1000].firstMatch("ABc"), 3075); + assertNull(res[1000].firstMatch("ABC"), 3076); + assertNull(res[1000].firstMatch("AbC"), 3077); + assertNull(res[1000].firstMatch(""), 3078); + assertToStringEquals("abc,b", res[1000].firstMatch("abc"), 3079); + assertToStringEquals("c,", res[1000].firstMatch("aBc"), 3080); + assertNull(res[1000].firstMatch("*** Failers "), 3081); + assertNull(res[1000].firstMatch("ABC"), 3082); + assertNull(res[1000].firstMatch("abC"), 3083); + assertNull(res[1000].firstMatch("aBC"), 3084); + assertNull(res[1000].firstMatch(""), 3085); + assertToStringEquals("c,", res[1000].firstMatch("aBc"), 3086); + assertToStringEquals("c,", res[1000].firstMatch("aBBc"), 3087); + assertNull(res[1000].firstMatch("*** Failers "), 3088); + assertNull(res[1000].firstMatch("aBC"), 3089); + assertNull(res[1000].firstMatch("aBBC"), 3090); + assertNull(res[1000].firstMatch(""), 3091); + assertToStringEquals("abc,b", res[1000].firstMatch("abcd"), 3092); + assertNull(res[1000].firstMatch("abCd"), 3093); + assertNull(res[1000].firstMatch("*** Failers"), 3094); + assertNull(res[1000].firstMatch("aBCd"), 3095); + assertToStringEquals("abc,b", res[1000].firstMatch("abcD "), 3096); + assertNull(res[1000].firstMatch(""), 3097); + assertNull(res[1000].firstMatch("more than million"), 3098); + assertNull(res[1000].firstMatch("more than MILLION"), 3099); + assertNull(res[1000].firstMatch("more \n than Million "), 3100); + assertNull(res[1000].firstMatch("*** Failers"), 3101); + assertNull(res[1000].firstMatch("MORE THAN MILLION "), 3102); + assertNull(res[1000].firstMatch("more \n than \n million "), 3103); + assertNull(res[1000].firstMatch("more than million"), 3104); + assertNull(res[1000].firstMatch("more than MILLION"), 3105); + assertNull(res[1000].firstMatch("more \n than Million "), 3106); + assertNull(res[1000].firstMatch("*** Failers"), 3107); + assertNull(res[1000].firstMatch("MORE THAN MILLION "), 3108); + assertNull(res[1000].firstMatch("more \n than \n million "), 3109); + assertNull(res[1000].firstMatch(""), 3110); + assertToStringEquals("abc,b", res[1000].firstMatch("abc"), 3111); + assertToStringEquals("bc,b", res[1000].firstMatch("aBbc"), 3112); + assertToStringEquals("c,", res[1000].firstMatch("aBBc "), 3113); + assertNull(res[1000].firstMatch("*** Failers"), 3114); + assertToStringEquals("bc,b", res[1000].firstMatch("Abc"), 3115); + assertNull(res[1000].firstMatch("abAb "), 3116); + assertNull(res[1000].firstMatch("abbC "), 3117); + assertNull(res[1000].firstMatch(""), 3118); + assertToStringEquals("abc,b", res[1000].firstMatch("abc"), 3119); + assertToStringEquals("c,", res[1000].firstMatch("aBc"), 3120); + assertNull(res[1000].firstMatch("*** Failers"), 3121); + assertNull(res[1000].firstMatch("Ab "), 3122); + assertNull(res[1000].firstMatch("abC"), 3123); + assertNull(res[1000].firstMatch("aBC "), 3124); + assertNull(res[1000].firstMatch(""), 3125); + assertToStringEquals("c,", res[1000].firstMatch("abxxc"), 3126); + assertToStringEquals("c,", res[1000].firstMatch("aBxxc"), 3127); + assertNull(res[1000].firstMatch("*** Failers"), 3128); + assertToStringEquals("c,", res[1000].firstMatch("Abxxc"), 3129); + assertToStringEquals("c,", res[1000].firstMatch("ABxxc"), 3130); + assertNull(res[1000].firstMatch("abxxC "), 3131); + assertToStringEquals("abc,b", res[1000].firstMatch("abc:"), 3132); + assertNull(res[1000].firstMatch("12"), 3133); + assertNull(res[1000].firstMatch("*** Failers"), 3134); + assertNull(res[1000].firstMatch("123"), 3135); + assertNull(res[1000].firstMatch("xyz "), 3136); + assertToStringEquals("abc,b", res[1000].firstMatch("abc:"), 3137); + assertNull(res[1000].firstMatch("12"), 3138); + assertNull(res[1000].firstMatch("*** Failers"), 3139); + assertNull(res[1000].firstMatch("123"), 3140); + assertNull(res[1000].firstMatch("xyz "), 3141); + assertNull(res[1000].firstMatch(""), 3142); + assertNull(res[1000].firstMatch("foobar"), 3143); + assertToStringEquals("c,", res[1000].firstMatch("cat"), 3144); + assertToStringEquals("c,", res[1000].firstMatch("fcat"), 3145); + assertToStringEquals("c,", res[1000].firstMatch("focat "), 3146); + assertNull(res[1000].firstMatch("*** Failers"), 3147); + assertToStringEquals("c,", res[1000].firstMatch("foocat "), 3148); + assertNull(res[1000].firstMatch("foobar"), 3149); + assertToStringEquals("c,", res[1000].firstMatch("cat"), 3150); + assertToStringEquals("c,", res[1000].firstMatch("fcat"), 3151); + assertToStringEquals("c,", res[1000].firstMatch("focat "), 3152); + assertNull(res[1000].firstMatch("*** Failers"), 3153); + assertToStringEquals("c,", res[1000].firstMatch("foocat "), 3154); + assertNull(res[1000].firstMatch("a"), 3155); + assertNull(res[1000].firstMatch("aa"), 3156); + assertNull(res[1000].firstMatch("aaaa"), 3157); + assertNull(res[1000].firstMatch(""), 3158); + assertToStringEquals("abc,abc", res[1001].firstMatch("abc"), 3159); + assertToStringEquals("abcabc,abc", res[1001].firstMatch("abcabc"), 3160); + assertToStringEquals( + "abcabcabc,abc", res[1001].firstMatch("abcabcabc"), 3161); + assertToStringEquals(",", res[1001].firstMatch("xyz "), 3162); + assertToStringEquals("a,a", res[1002].firstMatch("a"), 3163); + assertToStringEquals("aaaaa,aaaaa", res[1002].firstMatch("aaaaa "), 3164); + assertToStringEquals("a,a", res[1003].firstMatch("a"), 3165); + assertToStringEquals("b,b", res[1003].firstMatch("b"), 3166); + assertToStringEquals("ababab,ababab", res[1003].firstMatch("ababab"), 3167); + assertToStringEquals("aaaab,aaaab", res[1003].firstMatch("aaaabcde"), 3168); + assertToStringEquals("bbbb,bbbb", res[1003].firstMatch("bbbb "), 3169); + assertToStringEquals("b,b", res[1004].firstMatch("b"), 3170); + assertToStringEquals("bbbb,bbbb", res[1004].firstMatch("bbbb"), 3171); + assertToStringEquals(",", res[1004].firstMatch("aaa "), 3172); + assertToStringEquals("cccc,cccc", res[1005].firstMatch("cccc"), 3173); + assertToStringEquals(",", res[1005].firstMatch("abab "), 3174); + assertToStringEquals("a,a", res[1006].firstMatch("a"), 3175); + assertToStringEquals("aaaa,a", res[1006].firstMatch("aaaa "), 3176); + assertToStringEquals("a,a", res[1007].firstMatch("a"), 3177); + assertToStringEquals("b,b", res[1007].firstMatch("b"), 3178); + assertToStringEquals("abab,b", res[1007].firstMatch("abab"), 3179); + assertToStringEquals("baba,a", res[1007].firstMatch("baba "), 3180); + assertToStringEquals("b,b", res[1008].firstMatch("b"), 3181); + assertToStringEquals("bbbb,b", res[1008].firstMatch("bbbb"), 3182); + assertToStringEquals(",", res[1008].firstMatch("aaa "), 3183); + assertToStringEquals("c,c", res[1009].firstMatch("c"), 3184); + assertToStringEquals("cccc,c", res[1009].firstMatch("cccc"), 3185); + assertToStringEquals(",", res[1009].firstMatch("baba "), 3186); + assertToStringEquals(",", res[1009].firstMatch("a"), 3187); + assertToStringEquals(",", res[1009].firstMatch("aaabcde "), 3188); + assertToStringEquals(",", res[1009].firstMatch("aaaaa"), 3189); + assertToStringEquals(",", res[1009].firstMatch("aabbaa "), 3190); + assertToStringEquals(",", res[1009].firstMatch("aaaaa"), 3191); + assertToStringEquals(",", res[1009].firstMatch("aabbaa "), 3192); + assertToStringEquals("12-sep-98,8", res[1009].firstMatch("12-sep-98"), 3193); + assertToStringEquals("12-09-98,8", res[1009].firstMatch("12-09-98"), 3194); + assertToStringEquals("*** F,F", res[1009].firstMatch("*** Failers"), 3195); + assertToStringEquals("sep-12-98,8", res[1009].firstMatch("sep-12-98"), 3196); + assertToStringEquals(" , ", res[1009].firstMatch(" "), 3197); + assertToStringEquals("s,s", res[1009].firstMatch("saturday"), 3198); + assertToStringEquals("sund,d", res[1009].firstMatch("sunday"), 3199); + assertToStringEquals("S,S", res[1009].firstMatch("Saturday"), 3200); + assertToStringEquals("Sund,d", res[1009].firstMatch("Sunday"), 3201); + assertToStringEquals("SATURDAY,Y", res[1009].firstMatch("SATURDAY"), 3202); + assertToStringEquals("SUNDAY,Y", res[1009].firstMatch("SUNDAY"), 3203); + assertToStringEquals("SunD,D", res[1009].firstMatch("SunDay"), 3204); + assertToStringEquals(",", res[1009].firstMatch("abcx"), 3205); + assertToStringEquals(",", res[1009].firstMatch("aBCx"), 3206); + assertToStringEquals(",", res[1009].firstMatch("bbx"), 3207); + assertToStringEquals("BBx,x", res[1009].firstMatch("BBx"), 3208); + assertToStringEquals("*** F,F", res[1009].firstMatch("*** Failers"), 3209); + assertToStringEquals(",", res[1009].firstMatch("abcX"), 3210); + assertToStringEquals(",", res[1009].firstMatch("aBCX"), 3211); + assertToStringEquals(",", res[1009].firstMatch("bbX"), 3212); + assertToStringEquals( + "BBX , ", res[1009].firstMatch("BBX "), 3213); + assertToStringEquals(",", res[1009].firstMatch("ac"), 3214); + assertToStringEquals(",", res[1009].firstMatch("aC"), 3215); + assertToStringEquals(",", res[1009].firstMatch("bD"), 3216); + assertToStringEquals("eleph,h", res[1009].firstMatch("elephant"), 3217); + assertToStringEquals("Europe , ", res[1009].firstMatch("Europe "), 3218); + assertToStringEquals("frog,g", res[1009].firstMatch("frog"), 3219); + assertToStringEquals("Fr,r", res[1009].firstMatch("France"), 3220); + assertToStringEquals("*** F,F", res[1009].firstMatch("*** Failers"), 3221); + assertToStringEquals("Afric,c", res[1009].firstMatch("Africa "), 3222); + assertToStringEquals(",", res[1009].firstMatch("ab"), 3223); + assertToStringEquals(",", res[1009].firstMatch("aBd"), 3224); + assertToStringEquals("xy,y", res[1009].firstMatch("xy"), 3225); + assertToStringEquals("xY,Y", res[1009].firstMatch("xY"), 3226); + assertToStringEquals("ze,e", res[1009].firstMatch("zebra"), 3227); + assertToStringEquals("Z,Z", res[1009].firstMatch("Zambesi"), 3228); + assertToStringEquals("*** F,F", res[1009].firstMatch("*** Failers"), 3229); + assertToStringEquals(",", res[1009].firstMatch("aCD "), 3230); + assertToStringEquals("XY , ", res[1009].firstMatch("XY "), 3231); + assertToStringEquals("foo\n,\n", res[1009].firstMatch("foo\nbar"), 3232); + assertToStringEquals("*** F,F", res[1009].firstMatch("*** Failers"), 3233); + assertToStringEquals(",", res[1009].firstMatch("bar"), 3234); + assertToStringEquals(",", res[1009].firstMatch("baz\nbar "), 3235); + assertToStringEquals(",", res[1009].firstMatch("barbaz"), 3236); + assertToStringEquals(",", res[1009].firstMatch("barbarbaz "), 3237); + assertToStringEquals("koo,o", res[1009].firstMatch("koobarbaz "), 3238); + assertToStringEquals("*** F,F", res[1009].firstMatch("*** Failers"), 3239); + assertToStringEquals(",", res[1009].firstMatch("baz"), 3240); + assertToStringEquals("foo,o", res[1009].firstMatch("foobarbaz "), 3241); + assertToStringEquals("abc", res[1012].firstMatch("abc"), 3242); + assertToStringEquals("abc", res[1012].firstMatch("xabcy"), 3243); + assertToStringEquals("abc", res[1012].firstMatch("ababc"), 3244); + assertNull(res[1012].firstMatch("*** Failers"), 3245); + assertNull(res[1012].firstMatch("xbc"), 3246); + assertNull(res[1012].firstMatch("axc"), 3247); + assertNull(res[1012].firstMatch("abx"), 3248); + assertToStringEquals("abc", res[1013].firstMatch("abc"), 3249); + assertToStringEquals("abc", res[1014].firstMatch("abc"), 3250); + assertToStringEquals("abbc", res[1014].firstMatch("abbc"), 3251); + assertToStringEquals("abbbbc", res[1014].firstMatch("abbbbc"), 3252); + assertToStringEquals("a", res[1015].firstMatch("abbbbc"), 3253); + assertToStringEquals("abbb", res[1016].firstMatch("abbbbc"), 3254); + assertToStringEquals("abbbbc", res[1017].firstMatch("abbbbc"), 3255); + assertToStringEquals("abbc", res[1018].firstMatch("abbc"), 3256); + assertNull(res[1018].firstMatch("*** Failers"), 3257); + assertNull(res[1018].firstMatch("abc"), 3258); + assertNull(res[1018].firstMatch("abq"), 3259); + assertToStringEquals("abbbbc", res[1020].firstMatch("abbbbc"), 3260); + assertToStringEquals("abbbbc", res[1021].firstMatch("abbbbc"), 3261); + assertToStringEquals("abbbbc", res[1022].firstMatch("abbbbc"), 3262); + assertToStringEquals("abbbbc", res[1023].firstMatch("abbbbc"), 3263); + assertNull(res[1024].firstMatch("*** Failers"), 3264); + assertNull(res[1024].firstMatch("abq"), 3265); + assertNull(res[1024].firstMatch("abbbbc"), 3266); + assertToStringEquals("abbc", res[1025].firstMatch("abbc"), 3267); + assertToStringEquals("abc", res[1025].firstMatch("abc"), 3268); + assertToStringEquals("abc", res[1026].firstMatch("abc"), 3269); + assertToStringEquals("abc", res[1028].firstMatch("abc"), 3270); + assertToStringEquals("abc", res[1029].firstMatch("abc"), 3271); + assertToStringEquals("abc", res[1030].firstMatch("abc"), 3272); + assertNull(res[1030].firstMatch("*** Failers"), 3273); + assertNull(res[1030].firstMatch("abbbbc"), 3274); + assertNull(res[1030].firstMatch("abcc"), 3275); + assertToStringEquals("abc", res[1031].firstMatch("abcc"), 3276); + assertToStringEquals("abc", res[1033].firstMatch("aabc"), 3277); + assertNull(res[1033].firstMatch("*** Failers"), 3278); + assertToStringEquals("abc", res[1033].firstMatch("aabc"), 3279); + assertNull(res[1033].firstMatch("aabcd"), 3280); + assertToStringEquals("", res[1034].firstMatch("abc"), 3281); + assertToStringEquals("", res[1035].firstMatch("abc"), 3282); + assertToStringEquals("abc", res[1036].firstMatch("abc"), 3283); + assertToStringEquals("axc", res[1036].firstMatch("axc"), 3284); + assertToStringEquals("axyzc", res[1037].firstMatch("axyzc"), 3285); + assertToStringEquals("abd", res[1038].firstMatch("abd"), 3286); + assertNull(res[1038].firstMatch("*** Failers"), 3287); + assertNull(res[1038].firstMatch("axyzd"), 3288); + assertNull(res[1038].firstMatch("abc"), 3289); + assertToStringEquals("ace", res[1039].firstMatch("ace"), 3290); + assertToStringEquals("ac", res[1040].firstMatch("aac"), 3291); + assertToStringEquals("a-", res[1041].firstMatch("a-"), 3292); + assertToStringEquals("a-", res[1042].firstMatch("a-"), 3293); + assertToStringEquals("a]", res[1043].firstMatch("a]"), 3294); + assertNull(res[1044].firstMatch("a]b"), 3295); + assertToStringEquals("aed", res[1045].firstMatch("aed"), 3296); + assertNull(res[1045].firstMatch("*** Failers"), 3297); + assertNull(res[1045].firstMatch("abd"), 3298); + assertNull(res[1045].firstMatch("abd"), 3299); + assertToStringEquals("adc", res[1046].firstMatch("adc"), 3300); + assertNull(res[1047].firstMatch("adc"), 3301); + assertNull(res[1047].firstMatch("*** Failers"), 3302); + assertNull(res[1047].firstMatch("a-c"), 3303); + assertNull(res[1047].firstMatch("a]c"), 3304); + assertToStringEquals("a", res[1048].firstMatch("a-"), 3305); + assertToStringEquals("a", res[1048].firstMatch("-a"), 3306); + assertToStringEquals("a", res[1048].firstMatch("-a-"), 3307); + assertNull(res[1049].firstMatch("*** Failers"), 3308); + assertNull(res[1049].firstMatch("xy"), 3309); + assertNull(res[1049].firstMatch("yz"), 3310); + assertNull(res[1049].firstMatch("xyz"), 3311); + assertToStringEquals("a", res[1050].firstMatch("*** Failers"), 3312); + assertNull(res[1050].firstMatch("a-"), 3313); + assertNull(res[1050].firstMatch("-a"), 3314); + assertNull(res[1050].firstMatch("-a-"), 3315); + assertToStringEquals("y", res[1051].firstMatch("xy"), 3316); + assertToStringEquals("y", res[1052].firstMatch("yz"), 3317); + assertToStringEquals("y", res[1053].firstMatch("xyz"), 3318); + assertToStringEquals("a", res[1054].firstMatch("a"), 3319); + assertToStringEquals("-", res[1055].firstMatch("-"), 3320); + assertToStringEquals("*", res[1055].firstMatch("*** Failers"), 3321); + assertToStringEquals("-", res[1055].firstMatch("-"), 3322); + assertNull(res[1055].firstMatch("a"), 3323); + assertToStringEquals("a b", res[1056].firstMatch("a b"), 3324); + assertToStringEquals("a-b", res[1057].firstMatch("a-b"), 3325); + assertNull(res[1057].firstMatch("*** Failers"), 3326); + assertToStringEquals("a-b", res[1057].firstMatch("a-b"), 3327); + assertNull(res[1057].firstMatch("a b"), 3328); + assertToStringEquals("1", res[1058].firstMatch("1"), 3329); + assertToStringEquals("-", res[1059].firstMatch("-"), 3330); + assertToStringEquals("*", res[1059].firstMatch("*** Failers"), 3331); + assertToStringEquals("-", res[1059].firstMatch("-"), 3332); + assertNull(res[1059].firstMatch("1"), 3333); + assertToStringEquals("a", res[1060].firstMatch("a"), 3334); + assertToStringEquals("-", res[1061].firstMatch("-"), 3335); + assertToStringEquals("*", res[1061].firstMatch("*** Failers"), 3336); + assertToStringEquals("-", res[1061].firstMatch("-"), 3337); + assertNull(res[1061].firstMatch("a"), 3338); + assertToStringEquals("a b", res[1062].firstMatch("a b"), 3339); + assertToStringEquals("a-b", res[1063].firstMatch("a-b"), 3340); + assertNull(res[1063].firstMatch("*** Failers"), 3341); + assertToStringEquals("a-b", res[1063].firstMatch("a-b"), 3342); + assertNull(res[1063].firstMatch("a b"), 3343); + assertToStringEquals("1", res[1064].firstMatch("1"), 3344); + assertToStringEquals("-", res[1065].firstMatch("-"), 3345); + assertToStringEquals("*", res[1065].firstMatch("*** Failers"), 3346); + assertToStringEquals("-", res[1065].firstMatch("-"), 3347); + assertNull(res[1065].firstMatch("1"), 3348); + assertToStringEquals("ab", res[1066].firstMatch("abc"), 3349); + assertToStringEquals("ab", res[1066].firstMatch("abcd"), 3350); + assertToStringEquals("ef,", res[1067].firstMatch("def"), 3351); + assertToStringEquals("a(b", res[1069].firstMatch("a(b"), 3352); + assertNull(res[1069].firstMatch("ab"), 3353); + assertNull(res[1069].firstMatch("a((b"), 3354); + assertNull(res[1070].firstMatch("a\x08"), 3355); + assertToStringEquals("a,a,a", res[1071].firstMatch("abc"), 3356); + assertToStringEquals("abc,a,c", res[1072].firstMatch("abc"), 3357); + assertToStringEquals("abc", res[1073].firstMatch("aabbabc"), 3358); + assertToStringEquals("abc", res[1074].firstMatch("aabbabc"), 3359); + assertToStringEquals("abc", res[1075].firstMatch("abcabc"), 3360); + assertToStringEquals("ab,b", res[1076].firstMatch("ab"), 3361); + assertToStringEquals("ab,b", res[1077].firstMatch("ab"), 3362); + assertToStringEquals("ab,b", res[1078].firstMatch("ab"), 3363); + assertToStringEquals("ab,b", res[1079].firstMatch("ab"), 3364); + assertToStringEquals("a,a", res[1080].firstMatch("ab"), 3365); + assertToStringEquals("a,a", res[1081].firstMatch("ab"), 3366); + assertToStringEquals("cde", res[1082].firstMatch("cde"), 3367); + assertNull(res[1083].firstMatch("*** Failers"), 3368); + assertNull(res[1083].firstMatch("b"), 3369); + assertToStringEquals("abbbcd,c", res[1085].firstMatch("abbbcd"), 3370); + assertToStringEquals("abcd,a", res[1086].firstMatch("abcd"), 3371); + assertToStringEquals("e", res[1087].firstMatch("e"), 3372); + assertToStringEquals("ef,e", res[1088].firstMatch("ef"), 3373); + assertToStringEquals("abcdefg", res[1089].firstMatch("abcdefg"), 3374); + assertToStringEquals("ab", res[1090].firstMatch("xabyabbbz"), 3375); + assertToStringEquals("a", res[1090].firstMatch("xayabbbz"), 3376); + assertToStringEquals("cde,cd", res[1091].firstMatch("abcde"), 3377); + assertToStringEquals("hij", res[1092].firstMatch("hij"), 3378); + assertToStringEquals("ef,", res[1094].firstMatch("abcdef"), 3379); + assertToStringEquals("bcd,b", res[1095].firstMatch("abcd"), 3380); + assertToStringEquals("abc,a", res[1096].firstMatch("abc"), 3381); + assertToStringEquals("abc,bc", res[1097].firstMatch("abc"), 3382); + assertToStringEquals("abcd,bc,d", res[1098].firstMatch("abcd"), 3383); + assertToStringEquals("abcd,bc,d", res[1099].firstMatch("abcd"), 3384); + assertToStringEquals("abcd,b,cd", res[1100].firstMatch("abcd"), 3385); + assertToStringEquals("adcdcde", res[1101].firstMatch("adcdcde"), 3386); + assertNull(res[1102].firstMatch("*** Failers"), 3387); + assertNull(res[1102].firstMatch("abcde"), 3388); + assertNull(res[1102].firstMatch("adcdcde"), 3389); + assertToStringEquals("abc,ab", res[1103].firstMatch("abc"), 3390); + assertToStringEquals("abcd,abc,a,b,d", res[1104].firstMatch("abcd"), 3391); + assertToStringEquals("alpha", res[1105].firstMatch("alpha"), 3392); + assertToStringEquals("bh,", res[1106].firstMatch("abh"), 3393); + assertToStringEquals("effgz,effgz,", res[1107].firstMatch("effgz"), 3394); + assertToStringEquals("ij,ij,j", res[1107].firstMatch("ij"), 3395); + assertToStringEquals("effgz,effgz,", res[1107].firstMatch("reffgz"), 3396); + assertNull(res[1107].firstMatch("*** Failers"), 3397); + assertNull(res[1107].firstMatch("effg"), 3398); + assertNull(res[1107].firstMatch("bcdd"), 3399); + assertToStringEquals( + "a,a,a,a,a,a,a,a,a,a,a", res[1108].firstMatch("a"), 3400); + assertToStringEquals("a,a,a,a,a,a,a,a,a,a", res[1109].firstMatch("a"), 3401); + assertNull(res[1110].firstMatch("*** Failers"), 3402); + assertNull(res[1110].firstMatch("aa"), 3403); + assertNull(res[1110].firstMatch("uh-uh"), 3404); + assertToStringEquals( + "multiple words", res[1111].firstMatch("multiple words, yeah"), 3405); + assertToStringEquals("abcde,ab,de", res[1112].firstMatch("abcde"), 3406); + assertToStringEquals("(a, b),a,b", res[1113].firstMatch("(a, b)"), 3407); + assertToStringEquals("abcd", res[1115].firstMatch("abcd"), 3408); + assertToStringEquals("abcd,bc", res[1116].firstMatch("abcd"), 3409); + assertToStringEquals("ac", res[1117].firstMatch("ac"), 3410); + assertToStringEquals("ABC", res[1118].firstMatch("ABC"), 3411); + assertToStringEquals("ABC", res[1118].firstMatch("XABCY"), 3412); + assertToStringEquals("ABC", res[1118].firstMatch("ABABC"), 3413); + assertNull(res[1118].firstMatch("*** Failers"), 3414); + assertNull(res[1118].firstMatch("aaxabxbaxbbx"), 3415); + assertNull(res[1118].firstMatch("XBC"), 3416); + assertNull(res[1118].firstMatch("AXC"), 3417); + assertNull(res[1118].firstMatch("ABX"), 3418); + assertToStringEquals("ABC", res[1119].firstMatch("ABC"), 3419); + assertToStringEquals("ABC", res[1120].firstMatch("ABC"), 3420); + assertToStringEquals("ABBC", res[1120].firstMatch("ABBC"), 3421); + assertToStringEquals("ABBBBC", res[1121].firstMatch("ABBBBC"), 3422); + assertToStringEquals("ABBBBC", res[1122].firstMatch("ABBBBC"), 3423); + assertToStringEquals("ABBC", res[1123].firstMatch("ABBC"), 3424); + assertNull(res[1124].firstMatch("*** Failers"), 3425); + assertNull(res[1124].firstMatch("ABC"), 3426); + assertNull(res[1124].firstMatch("ABQ"), 3427); + assertToStringEquals("ABBBBC", res[1126].firstMatch("ABBBBC"), 3428); + assertToStringEquals("ABBBBC", res[1127].firstMatch("ABBBBC"), 3429); + assertToStringEquals("ABBBBC", res[1128].firstMatch("ABBBBC"), 3430); + assertToStringEquals("ABBBBC", res[1129].firstMatch("ABBBBC"), 3431); + assertNull(res[1130].firstMatch("*** Failers"), 3432); + assertNull(res[1130].firstMatch("ABQ"), 3433); + assertNull(res[1130].firstMatch("ABBBBC"), 3434); + assertToStringEquals("ABBC", res[1131].firstMatch("ABBC"), 3435); + assertToStringEquals("ABC", res[1131].firstMatch("ABC"), 3436); + assertToStringEquals("ABC", res[1132].firstMatch("ABC"), 3437); + assertToStringEquals("ABC", res[1134].firstMatch("ABC"), 3438); + assertToStringEquals("ABC", res[1135].firstMatch("ABC"), 3439); + assertToStringEquals("ABC", res[1136].firstMatch("ABC"), 3440); + assertNull(res[1136].firstMatch("*** Failers"), 3441); + assertNull(res[1136].firstMatch("ABBBBC"), 3442); + assertNull(res[1136].firstMatch("ABCC"), 3443); + assertToStringEquals("ABC", res[1137].firstMatch("ABCC"), 3444); + assertToStringEquals("ABC", res[1139].firstMatch("AABC"), 3445); + assertToStringEquals("", res[1140].firstMatch("ABC"), 3446); + assertToStringEquals("", res[1141].firstMatch("ABC"), 3447); + assertToStringEquals("ABC", res[1142].firstMatch("ABC"), 3448); + assertToStringEquals("AXC", res[1142].firstMatch("AXC"), 3449); + assertToStringEquals("AXYZC", res[1143].firstMatch("AXYZC"), 3450); + assertNull(res[1144].firstMatch("*** Failers"), 3451); + assertToStringEquals("AABC", res[1144].firstMatch("AABC"), 3452); + assertNull(res[1144].firstMatch("AXYZD"), 3453); + assertToStringEquals("ABD", res[1145].firstMatch("ABD"), 3454); + assertToStringEquals("ACE", res[1146].firstMatch("ACE"), 3455); + assertNull(res[1146].firstMatch("*** Failers"), 3456); + assertNull(res[1146].firstMatch("ABC"), 3457); + assertNull(res[1146].firstMatch("ABD"), 3458); + assertToStringEquals("AC", res[1147].firstMatch("AAC"), 3459); + assertToStringEquals("A-", res[1148].firstMatch("A-"), 3460); + assertToStringEquals("A-", res[1149].firstMatch("A-"), 3461); + assertToStringEquals("A]", res[1150].firstMatch("A]"), 3462); + assertNull(res[1151].firstMatch("A]B"), 3463); + assertToStringEquals("AED", res[1152].firstMatch("AED"), 3464); + assertToStringEquals("ADC", res[1153].firstMatch("ADC"), 3465); + assertNull(res[1153].firstMatch("*** Failers"), 3466); + assertNull(res[1153].firstMatch("ABD"), 3467); + assertNull(res[1153].firstMatch("A-C"), 3468); + assertNull(res[1154].firstMatch("ADC"), 3469); + assertToStringEquals("AB", res[1155].firstMatch("ABC"), 3470); + assertToStringEquals("AB", res[1155].firstMatch("ABCD"), 3471); + assertToStringEquals("EF,", res[1156].firstMatch("DEF"), 3472); + assertNull(res[1157].firstMatch("*** Failers"), 3473); + assertNull(res[1157].firstMatch("A]C"), 3474); + assertNull(res[1157].firstMatch("B"), 3475); + assertToStringEquals("A(B", res[1158].firstMatch("A(B"), 3476); + assertNull(res[1158].firstMatch("AB"), 3477); + assertNull(res[1158].firstMatch("A((B"), 3478); + assertNull(res[1159].firstMatch("AB"), 3479); + assertToStringEquals("A,A,A", res[1160].firstMatch("ABC"), 3480); + assertToStringEquals("ABC,A,C", res[1161].firstMatch("ABC"), 3481); + assertToStringEquals("ABC", res[1162].firstMatch("AABBABC"), 3482); + assertToStringEquals("ABC", res[1163].firstMatch("AABBABC"), 3483); + assertToStringEquals("ABC", res[1164].firstMatch("ABCABC"), 3484); + assertToStringEquals("ABC", res[1165].firstMatch("ABCABC"), 3485); + assertToStringEquals("ABC", res[1166].firstMatch("ABCABC"), 3486); + assertToStringEquals("AB,B", res[1167].firstMatch("AB"), 3487); + assertToStringEquals("AB,B", res[1168].firstMatch("AB"), 3488); + assertToStringEquals("AB,B", res[1169].firstMatch("AB"), 3489); + assertToStringEquals("AB,B", res[1170].firstMatch("AB"), 3490); + assertToStringEquals("A,A", res[1171].firstMatch("AB"), 3491); + assertToStringEquals("A,A", res[1172].firstMatch("AB"), 3492); + assertToStringEquals(",", res[1173].firstMatch("AB"), 3493); + assertToStringEquals("CDE", res[1174].firstMatch("CDE"), 3494); + assertToStringEquals("ABBBCD,C", res[1177].firstMatch("ABBBCD"), 3495); + assertToStringEquals("ABCD,A", res[1178].firstMatch("ABCD"), 3496); + assertToStringEquals("E", res[1179].firstMatch("E"), 3497); + assertToStringEquals("EF,E", res[1180].firstMatch("EF"), 3498); + assertToStringEquals("ABCDEFG", res[1181].firstMatch("ABCDEFG"), 3499); + assertToStringEquals("AB", res[1182].firstMatch("XABYABBBZ"), 3500); + assertToStringEquals("A", res[1182].firstMatch("XAYABBBZ"), 3501); + assertToStringEquals("CDE,CD", res[1183].firstMatch("ABCDE"), 3502); + assertToStringEquals("HIJ", res[1184].firstMatch("HIJ"), 3503); + assertNull(res[1185].firstMatch("ABCDE"), 3504); + assertToStringEquals("EF,", res[1186].firstMatch("ABCDEF"), 3505); + assertToStringEquals("BCD,B", res[1187].firstMatch("ABCD"), 3506); + assertToStringEquals("ABC,A", res[1188].firstMatch("ABC"), 3507); + assertToStringEquals("ABC,BC", res[1189].firstMatch("ABC"), 3508); + assertToStringEquals("ABCD,BC,D", res[1190].firstMatch("ABCD"), 3509); + assertToStringEquals("ABCD,BC,D", res[1191].firstMatch("ABCD"), 3510); + assertToStringEquals("ABCD,B,CD", res[1192].firstMatch("ABCD"), 3511); + assertToStringEquals("ADCDCDE", res[1193].firstMatch("ADCDCDE"), 3512); + assertToStringEquals("ABC,AB", res[1195].firstMatch("ABC"), 3513); + assertToStringEquals("ABCD,ABC,A,B,D", res[1196].firstMatch("ABCD"), 3514); + assertToStringEquals("ALPHA", res[1197].firstMatch("ALPHA"), 3515); + assertToStringEquals("BH,", res[1198].firstMatch("ABH"), 3516); + assertToStringEquals("EFFGZ,EFFGZ,", res[1199].firstMatch("EFFGZ"), 3517); + assertToStringEquals("IJ,IJ,J", res[1199].firstMatch("IJ"), 3518); + assertToStringEquals("EFFGZ,EFFGZ,", res[1199].firstMatch("REFFGZ"), 3519); + assertNull(res[1199].firstMatch("*** Failers"), 3520); + assertNull(res[1199].firstMatch("ADCDCDE"), 3521); + assertNull(res[1199].firstMatch("EFFG"), 3522); + assertNull(res[1199].firstMatch("BCDD"), 3523); + assertToStringEquals( + "A,A,A,A,A,A,A,A,A,A,A", res[1200].firstMatch("A"), 3524); + assertToStringEquals("A,A,A,A,A,A,A,A,A,A", res[1201].firstMatch("A"), 3525); + assertToStringEquals("A,A", res[1202].firstMatch("A"), 3526); + assertToStringEquals("C,C", res[1203].firstMatch("C"), 3527); + assertNull(res[1204].firstMatch("*** Failers"), 3528); + assertNull(res[1204].firstMatch("AA"), 3529); + assertNull(res[1204].firstMatch("UH-UH"), 3530); + assertToStringEquals( + "MULTIPLE WORDS", res[1205].firstMatch("MULTIPLE WORDS, YEAH"), 3531); + assertToStringEquals("ABCDE,AB,DE", res[1206].firstMatch("ABCDE"), 3532); + assertToStringEquals("(A, B),A,B", res[1207].firstMatch("(A, B)"), 3533); + assertToStringEquals("ABCD", res[1209].firstMatch("ABCD"), 3534); + assertToStringEquals("ABCD,BC", res[1210].firstMatch("ABCD"), 3535); + assertToStringEquals("AC", res[1211].firstMatch("AC"), 3536); + assertToStringEquals("ad", res[1212].firstMatch("abad"), 3537); + assertToStringEquals("ad", res[1213].firstMatch("abad"), 3538); + assertToStringEquals("ad", res[1214].firstMatch("abad"), 3539); + assertToStringEquals("ace,e", res[1215].firstMatch("ace"), 3540); + assertToStringEquals("ace,e", res[1216].firstMatch("ace"), 3541); + assertToStringEquals("ace,e", res[1217].firstMatch("ace"), 3542); + assertToStringEquals("acd,d", res[1217].firstMatch("acdbcdbe"), 3543); + assertToStringEquals("acdbcdbe,e", res[1218].firstMatch("acdbcdbe"), 3544); + assertToStringEquals("acdb,b", res[1219].firstMatch("acdbcdbe"), 3545); + assertToStringEquals("acdbcdb,b", res[1220].firstMatch("acdbcdbe"), 3546); + assertToStringEquals("acdbcd,d", res[1221].firstMatch("acdbcdbe"), 3547); + assertToStringEquals("foobar,bar,,bar", res[1222].firstMatch("foobar"), 3548); + assertToStringEquals("acdbcdbe,e", res[1223].firstMatch("acdbcdbe"), 3549); + assertToStringEquals("acdbcdbe,e", res[1224].firstMatch("acdbcdbe"), 3550); + assertToStringEquals("acdbcdbe,e", res[1225].firstMatch("acdbcdbe"), 3551); + assertToStringEquals("acdbcdb,b", res[1226].firstMatch("acdbcdbe"), 3552); + assertToStringEquals("acdbcdbe,e", res[1227].firstMatch("acdbcdbe"), 3553); + assertToStringEquals("acdbcdb,b", res[1228].firstMatch("acdbcdbe"), 3554); + assertToStringEquals("ace,c,e", res[1229].firstMatch("ace"), 3555); + assertToStringEquals("AB,A", res[1230].firstMatch("AB"), 3556); + assertToStringEquals(".,.,", res[1231].firstMatch("."), 3557); + assertToStringEquals("<&", res[1232].firstMatch("<&OUT"), 3558); + assertToStringEquals("foobar,,,,b,a,r", res[1233].firstMatch("foobar"), 3559); + assertToStringEquals(",,,,,,", res[1233].firstMatch("ab"), 3560); + assertToStringEquals(",,,,,,", res[1233].firstMatch("*** Failers"), 3561); + assertToStringEquals(",,,,,,", res[1233].firstMatch("cb"), 3562); + assertToStringEquals(",,,,,,", res[1233].firstMatch("b"), 3563); + assertToStringEquals(",,,,,,", res[1233].firstMatch("ab"), 3564); + assertToStringEquals(",,,,,,", res[1233].firstMatch("b"), 3565); + assertToStringEquals(",,,,,,", res[1233].firstMatch("b"), 3566); + assertToStringEquals("aba", res[1234].firstMatch("aba"), 3567); + assertToStringEquals("a", res[1235].firstMatch("aba"), 3568); + assertToStringEquals(",", res[1236].firstMatch("abc"), 3569); + assertToStringEquals("aax,a", res[1237].firstMatch("aax"), 3570); + assertToStringEquals("aax,a,a", res[1238].firstMatch("aax"), 3571); + assertToStringEquals("aax,a,a", res[1239].firstMatch("aax"), 3572); + assertToStringEquals("ab,", res[1240].firstMatch("cab"), 3573); + assertToStringEquals("ab,", res[1241].firstMatch("cab"), 3574); + assertToStringEquals("ab,", res[1241].firstMatch("ab"), 3575); + assertToStringEquals("ab,", res[1241].firstMatch("ab"), 3576); + assertNull(res[1241].firstMatch("Ab"), 3577); + assertNull(res[1241].firstMatch("Ab"), 3578); + assertNull(res[1241].firstMatch("*** Failers"), 3579); + assertNull(res[1241].firstMatch("cb"), 3580); + assertNull(res[1241].firstMatch("aB"), 3581); + assertToStringEquals("ab,", res[1241].firstMatch("ab"), 3582); + assertToStringEquals("ab,", res[1241].firstMatch("ab"), 3583); + assertNull(res[1241].firstMatch("Ab"), 3584); + assertNull(res[1241].firstMatch("Ab"), 3585); + assertNull(res[1241].firstMatch("*** Failers"), 3586); + assertNull(res[1241].firstMatch("aB"), 3587); + assertNull(res[1241].firstMatch("aB"), 3588); + assertToStringEquals("ab,", res[1241].firstMatch("ab"), 3589); + assertToStringEquals("ab,", res[1241].firstMatch("ab"), 3590); + assertNull(res[1241].firstMatch("aB"), 3591); + assertNull(res[1241].firstMatch("aB"), 3592); + assertNull(res[1241].firstMatch("*** Failers"), 3593); + assertNull(res[1241].firstMatch("aB"), 3594); + assertNull(res[1241].firstMatch("Ab"), 3595); + assertNull(res[1241].firstMatch("aB"), 3596); + assertNull(res[1241].firstMatch("aB"), 3597); + assertNull(res[1241].firstMatch("*** Failers"), 3598); + assertNull(res[1241].firstMatch("Ab"), 3599); + assertNull(res[1241].firstMatch("AB"), 3600); + assertToStringEquals("ab,", res[1241].firstMatch("ab"), 3601); + assertToStringEquals("ab,", res[1241].firstMatch("ab"), 3602); + assertNull(res[1241].firstMatch("aB"), 3603); + assertNull(res[1241].firstMatch("aB"), 3604); + assertNull(res[1241].firstMatch("*** Failers"), 3605); + assertNull(res[1241].firstMatch("AB"), 3606); + assertNull(res[1241].firstMatch("Ab"), 3607); + assertNull(res[1241].firstMatch("aB"), 3608); + assertNull(res[1241].firstMatch("aB"), 3609); + assertNull(res[1241].firstMatch("*** Failers"), 3610); + assertNull(res[1241].firstMatch("Ab"), 3611); + assertNull(res[1241].firstMatch("AB"), 3612); + assertNull(res[1241].firstMatch("*** Failers"), 3613); + assertNull(res[1241].firstMatch("AB"), 3614); + assertNull(res[1241].firstMatch("a\nB"), 3615); + assertNull(res[1241].firstMatch("a\nB"), 3616); + assertToStringEquals("cabbbb", res[1242].firstMatch("cabbbb"), 3617); + assertToStringEquals("caaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", + res[1243].firstMatch("caaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"), 3618); + assertToStringEquals( + "foobar1234baz", res[1244].firstMatch("foobar1234baz"), 3619); + assertToStringEquals("x~~,~~", res[1245].firstMatch("x~~"), 3620); + assertToStringEquals("aaac", res[1246].firstMatch("aaac"), 3621); + assertToStringEquals("aaac", res[1247].firstMatch("aaac"), 3622); + assertNull(res[1247].firstMatch("*** Failers"), 3623); + assertNull(res[1247].firstMatch("B\nB"), 3624); + assertNull(res[1247].firstMatch("dbcb"), 3625); + assertNull(res[1247].firstMatch("dbaacb"), 3626); + assertNull(res[1247].firstMatch("dbaacb"), 3627); + assertNull(res[1247].firstMatch("cdaccb"), 3628); + assertNull(res[1248].firstMatch("*** Failers"), 3629); + assertNull(res[1248].firstMatch("dbcb"), 3630); + assertNull(res[1248].firstMatch("a--"), 3631); + assertNull(res[1248].firstMatch("a\nb\nc\n"), 3632); + assertNull(res[1248].firstMatch("a\nb\nc\n"), 3633); + assertNull(res[1248].firstMatch("a\nb\n"), 3634); + assertNull(res[1248].firstMatch("a\nb\n"), 3635); + assertNull(res[1248].firstMatch("a\nb\n"), 3636); + assertNull(res[1248].firstMatch("a\nb\n"), 3637); + assertNull(res[1248].firstMatch("a\nb\nc\n"), 3638); + assertNull(res[1248].firstMatch("a\nb\nc\n"), 3639); + assertNull(res[1248].firstMatch("a\nb\nc\n"), 3640); + assertNull(res[1248].firstMatch("a\nb\nc\n"), 3641); + assertNull(res[1250].firstMatch("*** Failers"), 3642); + assertNull(res[1250].firstMatch("a\nb\nc\n"), 3643); + assertNull(res[1250].firstMatch("a\nb\nc\n"), 3644); + assertNull(res[1250].firstMatch("a\nb\nc\n"), 3645); + assertNull(res[1250].firstMatch("a"), 3646); + assertNull(res[1250].firstMatch("*** Failers"), 3647); + assertNull(res[1250].firstMatch("a"), 3648); + assertNull(res[1250].firstMatch("a"), 3649); + assertNull(res[1250].firstMatch("a"), 3650); + assertToStringEquals("one:,one:", res[1251].firstMatch("one:"), 3651); + assertNull(res[1251].firstMatch("a"), 3652); + assertToStringEquals("abcd,,abcd", res[1252].firstMatch("abcd"), 3653); + assertToStringEquals( + "xy:z:::abcd,xy:z:::,abcd", res[1252].firstMatch("xy:z:::abcd"), 3654); + assertToStringEquals("aexyc,c", res[1253].firstMatch("aexycd"), 3655); + assertToStringEquals("aab,aa", res[1254].firstMatch("caab"), 3656); + assertToStringEquals("abcd,,abcd", res[1255].firstMatch("abcd"), 3657); + assertToStringEquals( + "xy:z:::abcd,xy:z:::,abcd", res[1255].firstMatch("xy:z:::abcd"), 3658); + assertToStringEquals( + "Failers,,Failers", res[1255].firstMatch("*** Failers"), 3659); + assertNull(res[1255].firstMatch("abcd:"), 3660); + assertNull(res[1255].firstMatch("abcd:"), 3661); + assertToStringEquals("aexyc,c", res[1256].firstMatch("aexycd"), 3662); + assertNull(res[1257].firstMatch("aaab"), 3663); + assertToStringEquals(":[,:[", res[1258].firstMatch("a:[b]:"), 3664); + assertToStringEquals("=[,=[", res[1259].firstMatch("a=[b]="), 3665); + assertToStringEquals(".[,.[", res[1260].firstMatch("a.[b]."), 3666); + assertNull(res[1260].firstMatch("aaab"), 3667); + assertNull(res[1260].firstMatch("aaab"), 3668); + assertNull(res[1260].firstMatch("((abc(ade)ufh()()x"), 3669); + assertNull(res[1261].firstMatch("*** Failers"), 3670); + assertNull(res[1261].firstMatch("aaab"), 3671); + assertNull(res[1261].firstMatch("a\nb\n"), 3672); + assertNull(res[1262].firstMatch("a\nb\n"), 3673); + assertNull(res[1264].firstMatch("a\nb"), 3674); + assertNull(res[1265].firstMatch("a\nb"), 3675); + assertNull(res[1265].firstMatch("*** Failers"), 3676); + assertNull(res[1265].firstMatch("alphabetabcd"), 3677); + assertNull(res[1265].firstMatch("endingwxyz"), 3678); + assertNull(res[1265].firstMatch("*** Failers"), 3679); + assertNull( + res[1265] + .firstMatch("a rather long string that doesn't end with one of them"), + 3680); + assertNull( + res[1265].firstMatch( + "word cat dog elephant mussel cow horse canary baboon snake shark otherword"), + 3681); + assertNull( + res[1265].firstMatch( + "word cat dog elephant mussel cow horse canary baboon snake shark"), + 3682); + assertNull( + res[1265].firstMatch( + "word cat dog elephant mussel cow horse canary baboon snake shark the quick brown fox and the lazy dog and several other words getting close to thirty by now I hope"), + 3683); + assertNull(res[1265].firstMatch("999foo"), 3684); + assertNull(res[1265].firstMatch("123999foo "), 3685); + assertNull(res[1265].firstMatch("*** Failers"), 3686); + assertNull(res[1265].firstMatch("123abcfoo"), 3687); + assertNull(res[1265].firstMatch("999foo"), 3688); + assertNull(res[1265].firstMatch("123999foo "), 3689); + assertNull(res[1265].firstMatch("*** Failers"), 3690); + assertNull(res[1265].firstMatch("123abcfoo"), 3691); + assertNull(res[1265].firstMatch("123abcfoo"), 3692); + assertNull(res[1265].firstMatch("123456foo "), 3693); + assertNull(res[1265].firstMatch("*** Failers"), 3694); + assertNull(res[1265].firstMatch("123999foo "), 3695); + assertNull(res[1265].firstMatch("123abcfoo "), 3696); + assertNull(res[1265].firstMatch("123456foo "), 3697); + assertNull(res[1265].firstMatch("*** Failers"), 3698); + assertNull(res[1265].firstMatch("123999foo "), 3699); + assertToStringEquals("ZA,A,", res[1266].firstMatch("ZABCDEFG"), 3700); + assertToStringEquals("ZA,A,", res[1267].firstMatch("ZABCDEFG"), 3701); + assertToStringEquals("ZA,A,,", res[1268].firstMatch("ZABCDEFG"), 3702); + assertToStringEquals("ZA,A,,", res[1268].firstMatch("ZABCDEFG"), 3703); + assertToStringEquals("ZA,A,,", res[1268].firstMatch("ZABCDEFG"), 3704); + assertToStringEquals("a", res[1269].firstMatch("abbab"), 3705); + assertToStringEquals("a", res[1270].firstMatch("abcde"), 3711); + assertToStringEquals("-", res[1270].firstMatch("-things"), 3712); + assertToStringEquals("0", res[1270].firstMatch("0digit"), 3713); + assertNull(res[1270].firstMatch("*** Failers"), 3714); + assertNull(res[1270].firstMatch("bcdef "), 3715); + assertNull(res[1271].firstMatch("> \x09\n\x0c\x0d\x0b<"), 3716); + assertNull(res[1271].firstMatch(" "), 3717); + assertNull(res[1272].firstMatch("> \x09\n\x0c\x0d\x0b<"), 3718); + assertNull(res[1272].firstMatch(" "), 3719); + assertToStringEquals(" \x09\n\x0c\x0d\x0b", + res[1273].firstMatch("> \x09\n\x0c\x0d\x0b<"), 3720); + assertToStringEquals(" ", res[1273].firstMatch(" "), 3721); + assertToStringEquals(" \x09\n\x0c\x0d\x0b", + res[1274].firstMatch("> \x09\n\x0c\x0d\x0b<"), 3722); + assertToStringEquals(" ", res[1274].firstMatch(" "), 3723); + assertNull(res[1275].firstMatch("ab"), 3724); + assertNull(res[1278].firstMatch("abcabcabc"), 3725); + assertNull(res[1278].firstMatch("abc(*+|abc "), 3726); + assertNull(res[1279].firstMatch("abc abcabc"), 3727); + assertNull(res[1279].firstMatch("*** Failers"), 3728); + assertNull(res[1279].firstMatch("abcabcabc "), 3729); + assertNull(res[1280].firstMatch("abc#not comment\n literal "), 3730); + assertNull(res[1281].firstMatch("abc#not comment\n literal "), 3731); + assertNull(res[1282].firstMatch("abc#not comment\n literal "), 3732); + assertNull(res[1283].firstMatch("abc#not comment\n literal "), 3733); + assertNull(res[1284].firstMatch("abc\\\$xyz"), 3734); + assertNull(res[1285].firstMatch("abc\\\$xyz"), 3735); + assertNull(res[1286].firstMatch("abc"), 3736); + assertNull(res[1286].firstMatch("*** Failers"), 3737); + assertNull(res[1286].firstMatch("xyzabc "), 3738); + assertNull(res[1287].firstMatch("abc1abc2xyzabc3"), 3739); + assertToStringEquals("abc1", res[1288].firstMatch("abc1abc2xyzabc3 "), 3740); + assertNull(res[1288].firstMatch("*** Failers "), 3742); + assertNull(res[1288].firstMatch("Xa b c d Y "), 3743); + assertToStringEquals("abcY", res[1288].firstMatch("XabcY"), 3744); + assertNull(res[1288].firstMatch("AxyzB "), 3745); + assertNull(res[1288].firstMatch("XabCY"), 3746); + assertNull(res[1288].firstMatch("*** Failers"), 3747); + assertToStringEquals("abcY", res[1288].firstMatch("XabcY "), 3748); + assertNull(res[1288].firstMatch("abCE"), 3749); + assertNull(res[1288].firstMatch("DE"), 3750); + assertNull(res[1288].firstMatch("*** Failers"), 3751); + assertToStringEquals("abcE", res[1288].firstMatch("abcE"), 3752); + assertNull(res[1288].firstMatch("abCe "), 3753); + assertNull(res[1288].firstMatch("dE"), 3754); + assertNull(res[1288].firstMatch("De "), 3755); + assertNull(res[1289].firstMatch("z"), 3756); + assertNull(res[1289].firstMatch("a"), 3757); + assertNull(res[1289].firstMatch("-"), 3758); + assertNull(res[1289].firstMatch("d"), 3759); + assertNull(res[1289].firstMatch("] "), 3760); + assertNull(res[1289].firstMatch("*** Failers"), 3761); + assertNull(res[1289].firstMatch("b "), 3762); + assertToStringEquals("z", res[1290].firstMatch("z"), 3763); + assertToStringEquals("C", res[1290].firstMatch("C "), 3764); + assertToStringEquals("M", res[1291].firstMatch("M "), 3765); + assertNull(res[1292].firstMatch(""), 3766); + assertNull(res[1292].firstMatch("REGular"), 3767); + assertNull(res[1292].firstMatch("regulaer"), 3768); + assertNull(res[1292].firstMatch("Regex "), 3769); + assertNull(res[1292].firstMatch("regul\ufffdr "), 3770); + assertNull(res[1292].firstMatch("\ufffd\ufffd\ufffd\ufffd\ufffd"), 3771); + assertNull(res[1292].firstMatch("\ufffd\ufffd\ufffd\ufffd\ufffd"), 3772); + assertNull(res[1292].firstMatch("\ufffd\ufffd\ufffd\ufffd\ufffd"), 3773); + assertNull(res[1292].firstMatch("\ufffd\ufffd\ufffd\ufffd\ufffd"), 3774); + assertNull(res[1292].firstMatch("\x84XAZXB"), 3775); + assertNull(res[1292].firstMatch("123a"), 3776); + assertNull(res[1292].firstMatch("ac"), 3777); + assertToStringEquals("b,", res[1292].firstMatch("bbbbc"), 3778); + assertToStringEquals("ab,a", res[1292].firstMatch("abc"), 3779); + assertNull(res[1292].firstMatch("*** Failers"), 3780); + assertToStringEquals("b,", res[1292].firstMatch("bca"), 3781); + assertNull(res[1292].firstMatch(""), 3782); + assertToStringEquals("ab,a", res[1292].firstMatch("abc"), 3783); + assertNull(res[1292].firstMatch("*** Failers"), 3784); + assertToStringEquals("b,", res[1292].firstMatch("bca"), 3785); + assertToStringEquals("ab,a", res[1292].firstMatch("abc"), 3786); + assertNull(res[1292].firstMatch("*** Failers"), 3787); + assertNull(res[1292].firstMatch("def "), 3788); + assertNull(res[1292].firstMatch(""), 3789); + assertToStringEquals("ab,a", res[1292].firstMatch("abc"), 3790); + assertNull(res[1292].firstMatch("*** Failers"), 3791); + assertNull(res[1292].firstMatch("def "), 3792); + assertNull(res[1292].firstMatch(""), 3793); + assertToStringEquals( + "line\nbreak", res[1293].firstMatch("this is a line\nbreak"), 3794); + assertToStringEquals( + "line\nbreak", + res[1293] + .firstMatch("line one\nthis is a line\nbreak in the second line "), + 3795); + assertToStringEquals( + "line\nbreak", res[1294].firstMatch("this is a line\nbreak"), 3796); + assertNull(res[1294].firstMatch("** Failers "), 3797); + assertToStringEquals( + "line\nbreak", + res[1294] + .firstMatch("line one\nthis is a line\nbreak in the second line "), + 3798); + assertToStringEquals( + "line\nbreak", res[1295].firstMatch("this is a line\nbreak"), 3799); + assertNull(res[1295].firstMatch("** Failers "), 3800); + assertToStringEquals( + "line\nbreak", + res[1295] + .firstMatch("line one\nthis is a line\nbreak in the second line "), + 3801); + assertNull(res[1296].firstMatch("123P"), 3802); + assertNull(res[1296].firstMatch("a4PR"), 3803); + assertNull(res[1297].firstMatch("123P"), 3804); + assertNull(res[1297].firstMatch("4PR"), 3805); + assertToStringEquals("", res[1298].firstMatch("a\nb\nc\n"), 3806); + assertToStringEquals("", res[1298].firstMatch(" "), 3807); + assertToStringEquals("", res[1298].firstMatch("A\nC\nC\n "), 3808); + assertToStringEquals("", res[1298].firstMatch("AB"), 3809); + assertToStringEquals("", res[1298].firstMatch("aB "), 3810); + assertToStringEquals("", res[1298].firstMatch("AB"), 3811); + assertToStringEquals("", res[1298].firstMatch("aB "), 3812); + assertToStringEquals("", res[1298].firstMatch("AB"), 3813); + assertToStringEquals("", res[1298].firstMatch("aB "), 3814); + assertToStringEquals("", res[1298].firstMatch("AB"), 3815); + assertToStringEquals("", res[1298].firstMatch("aB "), 3816); + assertToStringEquals("Content-Type:xxxxxyyy ", + res[1299].firstMatch("Content-Type:xxxxxyyy "), 3817); + assertToStringEquals("Content-Type:xxxxxyyyz", + res[1300].firstMatch("Content-Type:xxxxxyyyz"), 3818); + assertToStringEquals("Content-Type:xxxyyy ", + res[1301].firstMatch("Content-Type:xxxyyy "), 3819); + assertToStringEquals("Content-Type:xxxyyyz", + res[1302].firstMatch("Content-Type:xxxyyyz"), 3820); + assertToStringEquals("abc", res[1303].firstMatch("xyz\nabc"), 3821); + assertToStringEquals("abc", res[1303].firstMatch("xyz\nabc"), 3822); + assertToStringEquals("abc", res[1303].firstMatch("xyz\x0d\nabc"), 3823); + assertToStringEquals("abc", res[1303].firstMatch("xyz\x0dabc"), 3824); + assertToStringEquals("abc", res[1303].firstMatch("xyz\x0d\nabc"), 3825); + assertNull(res[1303].firstMatch("** Failers "), 3826); + assertToStringEquals("abc", res[1303].firstMatch("xyz\nabc"), 3827); + assertToStringEquals("abc", res[1303].firstMatch("xyz\x0d\nabc"), 3828); + assertToStringEquals("abc", res[1303].firstMatch("xyz\nabc"), 3829); + assertToStringEquals("abc", res[1303].firstMatch("xyz\x0dabc"), 3830); + assertToStringEquals("abc", res[1303].firstMatch("xyz\x0dabc"), 3831); + assertToStringEquals("abc", res[1304].firstMatch("xyzabc"), 3832); + assertToStringEquals("abc", res[1304].firstMatch("xyzabc\n "), 3833); + assertToStringEquals("abc", res[1304].firstMatch("xyzabc\npqr "), 3834); + assertToStringEquals("abc", res[1304].firstMatch("xyzabc\x0d "), 3835); + assertToStringEquals("abc", res[1304].firstMatch("xyzabc\x0dpqr "), 3836); + assertToStringEquals( + "abc", res[1304].firstMatch("xyzabc\x0d\n "), 3837); + assertToStringEquals( + "abc", res[1304].firstMatch("xyzabc\x0d\npqr "), 3838); + assertNull(res[1304].firstMatch("** Failers"), 3839); + assertToStringEquals("abc", res[1304].firstMatch("xyzabc\x0d "), 3840); + assertToStringEquals("abc", res[1304].firstMatch("xyzabc\x0dpqr "), 3841); + assertToStringEquals("abc", res[1304].firstMatch("xyzabc\x0d\n "), 3842); + assertToStringEquals("abc", res[1304].firstMatch("xyzabc\x0d\npqr "), 3843); + assertToStringEquals("abc", res[1305].firstMatch("xyz\x0dabcdef"), 3844); + assertToStringEquals("abc", res[1305].firstMatch("xyz\nabcdef"), 3845); + assertNull(res[1305].firstMatch("** Failers "), 3846); + assertToStringEquals("abc", res[1305].firstMatch("xyz\nabcdef"), 3847); + assertNull(res[1305].firstMatch(" "), 3848); + assertToStringEquals("abc", res[1306].firstMatch("xyz\nabcdef"), 3849); + assertToStringEquals("abc", res[1306].firstMatch("xyz\x0dabcdef"), 3850); + assertNull(res[1306].firstMatch("** Failers "), 3851); + assertToStringEquals("abc", res[1306].firstMatch("xyz\x0dabcdef"), 3852); + assertNull(res[1306].firstMatch(" "), 3853); + assertToStringEquals("abc", res[1307].firstMatch("xyz\x0d\nabcdef"), 3854); + assertToStringEquals("abc", res[1307].firstMatch("xyz\x0dabcdef"), 3855); + assertNull(res[1307].firstMatch("** Failers "), 3856); + assertToStringEquals("abc", res[1307].firstMatch("xyz\x0dabcdef"), 3857); + assertToStringEquals("abc", res[1308].firstMatch("abc\ndef"), 3858); + assertToStringEquals("abc", res[1308].firstMatch("abc\x0ddef"), 3859); + assertToStringEquals("abc", res[1308].firstMatch("abc\x0d\ndef"), 3860); + assertToStringEquals("abc", res[1308].firstMatch("abc\ndef"), 3861); + assertToStringEquals("abc", res[1308].firstMatch("abc\x0ddef"), 3862); + assertToStringEquals( + "abc", res[1308].firstMatch("abc\x0d\ndef"), 3863); + assertToStringEquals( + "abc", res[1308].firstMatch("abc\ndef"), 3864); + assertToStringEquals( + "abc", res[1308].firstMatch("abc\x0ddef"), 3865); + assertToStringEquals( + "abc", res[1308].firstMatch("abc\x0d\ndef"), 3866); + assertNull(res[1309].firstMatch("abc\ndef"), 3867); + assertNull(res[1309].firstMatch("abc\x0ddef"), 3868); + assertNull(res[1309].firstMatch("abc\x0d\ndef"), 3869); + assertToStringEquals( + "abc=xyz\\,", res[1310].firstMatch("abc=xyz\\\npqr"), 3870); + assertToStringEquals("aaaa,a,", res[1311].firstMatch("aaaa"), 3871); + assertToStringEquals("aaaa", res[1312].firstMatch("aaaa"), 3872); + assertToStringEquals("aaaa,a,", res[1313].firstMatch("aaaa"), 3873); + assertToStringEquals("aaaa", res[1314].firstMatch("aaaa"), 3874); + assertNull(res[1317].firstMatch("a\x0db"), 3875); + assertNull(res[1317].firstMatch("a\nb "), 3876); + assertNull(res[1317].firstMatch("** Failers"), 3877); + assertNull(res[1317].firstMatch("a\nb"), 3878); + assertNull(res[1317].firstMatch("a\nb"), 3879); + assertNull(res[1317].firstMatch("a\x0db "), 3880); + assertNull(res[1317].firstMatch("a\x0db "), 3881); + assertToStringEquals( + "abc1", + res[1318].firstMatch( + "abc1 \nabc2 \x0babc3xx \x0cabc4 \x0dabc5xx \x0d\nabc6 \x85abc7 JUNK"), + 3882); + assertToStringEquals( + "abc1", + res[1319].firstMatch( + "abc1\n abc2\x0b abc3\x0c abc4\x0d abc5\x0d\n abc6\x85 abc9"), + 3883); + assertNull(res[1320].firstMatch("a\nb"), 3884); + assertNull(res[1320].firstMatch("a\x0db"), 3885); + assertNull(res[1320].firstMatch("a\x0d\nb"), 3886); + assertNull(res[1320].firstMatch("a\x0bb"), 3887); + assertNull(res[1320].firstMatch("a\x0cb"), 3888); + assertNull(res[1320].firstMatch("a\x85b "), 3889); + assertNull(res[1320].firstMatch("** Failers"), 3890); + assertNull(res[1320].firstMatch("a\n\x0db "), 3891); + assertToStringEquals("ab", res[1321].firstMatch("ab"), 3892); + assertNull(res[1321].firstMatch("a\nb"), 3893); + assertNull(res[1321].firstMatch("a\x0db"), 3894); + assertNull(res[1321].firstMatch("a\x0d\nb"), 3895); + assertNull(res[1321].firstMatch("a\x0bb"), 3896); + assertNull(res[1321].firstMatch("a\x0cb"), 3897); + assertNull(res[1321].firstMatch("a\x85b "), 3898); + assertNull(res[1321].firstMatch("a\n\x0db "), 3899); + assertNull(res[1321].firstMatch("a\n\x0d\x85\x0cb "), 3900); + assertNull(res[1322].firstMatch("a\nb"), 3901); + assertNull(res[1322].firstMatch("a\x0db"), 3902); + assertNull(res[1322].firstMatch("a\x0d\nb"), 3903); + assertNull(res[1322].firstMatch("a\x0bb"), 3904); + assertNull(res[1322].firstMatch("a\x0cb"), 3905); + assertNull(res[1322].firstMatch("a\x85b "), 3906); + assertNull(res[1322].firstMatch("a\n\x0db "), 3907); + assertNull(res[1322].firstMatch("a\n\x0d\x85\x0cb "), 3908); + assertNull(res[1322].firstMatch("** Failers"), 3909); + assertNull(res[1322].firstMatch("ab "), 3910); + assertNull(res[1323].firstMatch("a\nb"), 3911); + assertNull(res[1323].firstMatch("a\n\x0db"), 3912); + assertNull(res[1323].firstMatch("a\n\x0d\x85b"), 3913); + assertNull(res[1323].firstMatch("a\x0d\n\x0d\nb "), 3914); + assertNull(res[1323].firstMatch("a\x0d\n\x0d\n\x0d\nb "), 3915); + assertNull(res[1323].firstMatch("a\n\x0d\n\x0db"), 3916); + assertNull(res[1323].firstMatch("a\n\n\x0d\nb "), 3917); + assertNull(res[1323].firstMatch("** Failers"), 3918); + assertNull(res[1323].firstMatch("a\n\n\n\x0db"), 3919); + assertNull(res[1323].firstMatch("a\x0d"), 3920); + assertToStringEquals("aRb", res[1324].firstMatch("aRb"), 3921); + assertNull(res[1324].firstMatch("** Failers"), 3922); + assertNull(res[1324].firstMatch("a\nb "), 3923); + assertToStringEquals("afoo", res[1325].firstMatch("afoo"), 3924); + assertNull(res[1325].firstMatch("** Failers "), 3925); + assertNull(res[1325].firstMatch("\x0d\nfoo "), 3926); + assertNull(res[1325].firstMatch("\nfoo "), 3927); + assertToStringEquals("afoo", res[1326].firstMatch("afoo"), 3928); + assertNull(res[1326].firstMatch("\nfoo "), 3929); + assertNull(res[1326].firstMatch("** Failers "), 3930); + assertNull(res[1326].firstMatch("\x0d\nfoo "), 3931); + assertToStringEquals("afoo", res[1327].firstMatch("afoo"), 3932); + assertNull(res[1327].firstMatch("** Failers "), 3933); + assertNull(res[1327].firstMatch("\nfoo "), 3934); + assertNull(res[1327].firstMatch("\x0d\nfoo "), 3935); + assertToStringEquals("afoo", res[1328].firstMatch("afoo"), 3936); + assertNull(res[1328].firstMatch("\x0d\nfoo "), 3937); + assertNull(res[1328].firstMatch("\nfoo "), 3938); + assertToStringEquals("", res[1329].firstMatch("abc\x0d\x0dxyz"), 3939); + assertToStringEquals("", res[1329].firstMatch("abc\n\x0dxyz "), 3940); + assertNull(res[1329].firstMatch("** Failers "), 3941); + assertToStringEquals("", res[1329].firstMatch("abc\x0d\nxyz"), 3942); + assertToStringEquals("X", res[1330].firstMatch("XABC"), 3943); + assertNull(res[1330].firstMatch("** Failers "), 3944); + assertToStringEquals("X", res[1330].firstMatch("XABCB"), 3945); + assertNull(res[1330].firstMatch("abc\x0d\n\x0d\n"), 3946); + assertNull(res[1330].firstMatch("abc\x0d\n\x0d\n"), 3947); + assertNull(res[1330].firstMatch("abc\x0d\n\x0d\n"), 3948); + assertThrows(() => new RegExp(r"(?|(abc)|(xyz))"), 3949); + assertThrows(() => new RegExp(r"(x)(?|(abc)|(xyz))(x)"), 3950); + assertNull(res[1330].firstMatch("xabcx"), 3951); + assertNull(res[1330].firstMatch("xxyzx "), 3952); + assertThrows(() => new RegExp(r"(x)(?|(abc)(pqr)|(xyz))(x)"), 3953); + assertNull(res[1330].firstMatch("xabcpqrx"), 3954); + assertNull(res[1330].firstMatch("xxyzx "), 3955); + assertNull(res[1330].firstMatch("abcabc"), 3956); + assertNull(res[1330].firstMatch("xyzabc "), 3957); + assertNull(res[1330].firstMatch("** Failers "), 3958); + assertNull(res[1330].firstMatch("xyzxyz "), 3959); + assertNull(res[1331].firstMatch("X X\n"), 3960); + assertNull(res[1331].firstMatch("X\x09X\x0b"), 3961); + assertNull(res[1331].firstMatch("** Failers"), 3962); + assertNull(res[1331].firstMatch("\xa0 X\n "), 3963); + assertNull(res[1332].firstMatch("\x09 \xa0X\n\x0b\x0c\x0d\n"), 3964); + assertNull(res[1332].firstMatch("\x09 \xa0\n\x0b\x0c\x0d\n"), 3965); + assertNull(res[1332].firstMatch("\x09 \xa0\n\x0b\x0c"), 3966); + assertNull(res[1332].firstMatch("** Failers "), 3967); + assertNull(res[1332].firstMatch("\x09 \xa0\n\x0b"), 3968); + assertNull(res[1332].firstMatch(" "), 3969); + assertNull(res[1333].firstMatch("XY ABCDE"), 3970); + assertNull(res[1333].firstMatch("XY PQR ST "), 3971); + assertNull(res[1334].firstMatch("XY AB PQRS"), 3972); + assertNull(res[1335].firstMatch(">XNNNYZ"), 3973); + assertNull(res[1335].firstMatch("> X NYQZ"), 3974); + assertNull(res[1335].firstMatch("** Failers"), 3975); + assertNull(res[1335].firstMatch(">XYZ "), 3976); + assertNull(res[1335].firstMatch("> X NY Z"), 3977); + assertNull(res[1336].firstMatch(">XY\nZ\nA\x0bNN\x0c"), 3978); + assertNull( + res[1336].firstMatch(">\n\x0dX\nY\n\x0bZZZ\nAAA\x0bNNN\x0c"), 3979); + assertNull(res[1337].firstMatch("\x0d\nA"), 3980); + assertToStringEquals("\nA", res[1338].firstMatch("\x0d\nA "), 3981); + assertToStringEquals("\nA", res[1339].firstMatch("\x0d\nA "), 3982); + assertToStringEquals("\nA,\n", res[1340].firstMatch("\x0d\nA "), 3983); + assertNull(res[1341].firstMatch("a\x0db"), 3984); + assertNull(res[1341].firstMatch("a\nb"), 3985); + assertNull(res[1341].firstMatch("a\x0d\nb"), 3986); + assertNull(res[1341].firstMatch("** Failers"), 3987); + assertNull(res[1341].firstMatch("a\x85b"), 3988); + assertNull(res[1341].firstMatch("a\x0bb "), 3989); + assertNull(res[1342].firstMatch("a\x0db"), 3990); + assertNull(res[1342].firstMatch("a\nb"), 3991); + assertNull(res[1342].firstMatch("a\x0d\nb"), 3992); + assertNull(res[1342].firstMatch("a\x85b"), 3993); + assertNull(res[1342].firstMatch("a\x0bb "), 3994); + assertNull(res[1342].firstMatch("** Failers "), 3995); + assertNull(res[1342].firstMatch("a\x85b"), 3996); + assertNull(res[1342].firstMatch("a\x0bb"), 3997); + assertNull(res[1343].firstMatch("a\x0db"), 3998); + assertNull(res[1343].firstMatch("a\nb"), 3999); + assertNull(res[1343].firstMatch("a\x0d\nb"), 4000); + assertNull(res[1343].firstMatch("** Failers"), 4001); + assertNull(res[1343].firstMatch("a\x85b"), 4002); + assertNull(res[1343].firstMatch("a\x0bb "), 4003); + assertNull(res[1344].firstMatch("a\x0db"), 4004); + assertNull(res[1344].firstMatch("a\nb"), 4005); + assertNull(res[1344].firstMatch("a\x0d\nb"), 4006); + assertNull(res[1344].firstMatch("a\x85b"), 4007); + assertNull(res[1344].firstMatch("a\x0bb "), 4008); + assertNull(res[1344].firstMatch("** Failers "), 4009); + assertNull(res[1344].firstMatch("a\x85b"), 4010); + assertNull(res[1344].firstMatch("a\x0bb"), 4011); + assertNull(res[1345].firstMatch("a\x0d\n\nb"), 4012); + assertNull(res[1345].firstMatch("a\n\x0d\x0db"), 4013); + assertNull(res[1345].firstMatch("a\x0d\n\x0d\n\x0d\n\x0d\nb"), 4014); + assertNull(res[1345].firstMatch("** Failers"), 4015); + assertNull(res[1345].firstMatch("a\x8585b"), 4016); + assertNull(res[1345].firstMatch("a\x0b\x00bb "), 4017); + assertNull(res[1346].firstMatch("a\x0d\x0db"), 4018); + assertNull(res[1346].firstMatch("a\n\n\nb"), 4019); + assertNull(res[1346].firstMatch("a\x0d\n\n\x0d\x0db"), 4020); + assertNull(res[1346].firstMatch("a\x8585b"), 4021); + assertNull(res[1346].firstMatch("a\x0b\x00bb "), 4022); + assertNull(res[1346].firstMatch("** Failers "), 4023); + assertNull(res[1346].firstMatch("a\x0d\x0d\x0d\x0d\x0db "), 4024); + assertNull(res[1346].firstMatch("a\x8585b"), 4025); + assertNull(res[1346].firstMatch("a\x0b\x00bb"), 4026); + assertToStringEquals("abc", res[1347].firstMatch("abc "), 4027); + assertNull(res[1348].firstMatch("** Failers"), 4028); + assertNull(res[1348].firstMatch("ab"), 4029); + assertNull(res[1349].firstMatch("** Failers"), 4030); + assertNull(res[1349].firstMatch("ab "), 4031); + assertNull(res[1349].firstMatch("** Failers"), 4032); + assertNull(res[1349].firstMatch("ab "), 4033); + assertToStringEquals("aXb", res[1350].firstMatch("aXb"), 4034); + assertToStringEquals("a\nb", res[1350].firstMatch("a\nb "), 4035); + assertNull(res[1350].firstMatch("** Failers"), 4036); + assertNull(res[1350].firstMatch("ab "), 4037); + assertToStringEquals("aXb", res[1351].firstMatch("aXb"), 4038); + assertToStringEquals("a\nX\nXb", res[1351].firstMatch("a\nX\nXb "), 4039); + assertNull(res[1351].firstMatch("** Failers"), 4040); + assertNull(res[1351].firstMatch("ab "), 4041); + assertNull(res[1352].firstMatch("ab"), 4042); + assertNull(res[1352].firstMatch("ax{100}b "), 4043); + assertNull(res[1352].firstMatch("ax{100}x{100}b "), 4044); + assertNull(res[1352].firstMatch("ax{100}b "), 4045); + assertNull(res[1352].firstMatch("ax{100}x{100}b "), 4046); + assertNull(res[1352].firstMatch("*** Failers "), 4047); + assertNull(res[1352].firstMatch("ab"), 4048); + assertNull(res[1352].firstMatch(" "), 4049); + assertToStringEquals("X", res[1353].firstMatch("Xoanon"), 4050); + assertToStringEquals("X", res[1353].firstMatch("+Xoanon"), 4051); + assertToStringEquals("X", res[1353].firstMatch("x{300}Xoanon "), 4052); + assertNull(res[1353].firstMatch("*** Failers "), 4053); + assertNull(res[1353].firstMatch("YXoanon "), 4054); + assertToStringEquals("X", res[1354].firstMatch("YXoanon"), 4055); + assertNull(res[1354].firstMatch("*** Failers"), 4056); + assertNull(res[1354].firstMatch("Xoanon"), 4057); + assertNull(res[1354].firstMatch("+Xoanon "), 4058); + assertNull(res[1354].firstMatch("x{300}Xoanon "), 4059); + assertToStringEquals("X", res[1355].firstMatch("X+oanon"), 4060); + assertNull(res[1355].firstMatch("ZXx{300}oanon "), 4061); + assertToStringEquals("X", res[1355].firstMatch("FAX "), 4062); + assertNull(res[1355].firstMatch("*** Failers "), 4063); + assertNull(res[1355].firstMatch("Xoanon "), 4064); + assertToStringEquals("X", res[1356].firstMatch("Xoanon "), 4065); + assertNull(res[1356].firstMatch("*** Failers"), 4066); + assertNull(res[1356].firstMatch("X+oanon"), 4067); + assertToStringEquals("X", res[1356].firstMatch("ZXx{300}oanon "), 4068); + assertNull(res[1356].firstMatch("FAX "), 4069); + assertToStringEquals("b", res[1357].firstMatch("abcd"), 4070); + assertToStringEquals("x", res[1357].firstMatch("ax{100} "), 4071); + assertToStringEquals("b", res[1357].firstMatch("ab99"), 4072); + assertToStringEquals("x", res[1357].firstMatch("x{123}x{123}45"), 4073); + assertToStringEquals( + "x", res[1357].firstMatch("x{400}x{401}x{402}6 "), 4074); + assertToStringEquals("*", res[1357].firstMatch("*** Failers"), 4075); + assertToStringEquals("d", res[1357].firstMatch("d99"), 4076); + assertToStringEquals("x", res[1357].firstMatch("x{123}x{122}4 "), 4077); + assertToStringEquals("x", res[1357].firstMatch("x{400}x{403}6 "), 4078); + assertToStringEquals( + "x", res[1357].firstMatch("x{400}x{401}x{402}x{402}6 "), 4079); + assertNull(res[1358].firstMatch("\ufffd]"), 4080); + assertNull(res[1358].firstMatch("\ufffd"), 4081); + assertNull(res[1358].firstMatch("\ufffd\ufffd\ufffd"), 4082); + assertNull(res[1358].firstMatch("\ufffd\ufffd\ufffd?"), 4083); + assertToStringEquals("acb", res[1359].firstMatch("acb"), 4084); + assertToStringEquals("ab", res[1359].firstMatch("ab"), 4085); + assertNull(res[1359].firstMatch("ax{100}b "), 4086); + assertNull(res[1359].firstMatch("*** Failers"), 4087); + assertNull(res[1359].firstMatch("a\nb "), 4088); + assertNull(res[1360].firstMatch("ax{4000}xyb "), 4089); + assertNull(res[1360].firstMatch("ax{4000}yb "), 4090); + assertNull(res[1360].firstMatch("ax{4000}x{100}yb "), 4091); + assertNull(res[1360].firstMatch("*** Failers"), 4092); + assertNull(res[1360].firstMatch("ax{4000}b "), 4093); + assertNull(res[1360].firstMatch("ac\ncb "), 4094); + assertToStringEquals("a\xc0,,\xc0", res[1361].firstMatch("a\xc0\x88b"), 4095); + assertToStringEquals("ax,,x", res[1362].firstMatch("ax{100}b"), 4096); + assertToStringEquals( + "a\xc0\x88b,\xc0\x88,b", res[1363].firstMatch("a\xc0\x88b"), 4097); + assertToStringEquals( + "ax{100}b,x{100},b", res[1364].firstMatch("ax{100}b"), 4098); + assertToStringEquals( + "a\xc0\x92,\xc0,\x92", res[1365].firstMatch("a\xc0\x92bcd"), 4099); + assertToStringEquals("ax{,x,{", res[1366].firstMatch("ax{240}bcd"), 4100); + assertToStringEquals( + "a\xc0\x92,\xc0,\x92", res[1367].firstMatch("a\xc0\x92bcd"), 4101); + assertToStringEquals("ax{,x,{", res[1368].firstMatch("ax{240}bcd"), 4102); + assertToStringEquals( + "a\xc0,,\xc0", res[1369].firstMatch("a\xc0\x92bcd"), 4103); + assertToStringEquals("ax,,x", res[1370].firstMatch("ax{240}bcd"), 4104); + assertNull(res[1371].firstMatch("ax{1234}xyb "), 4105); + assertNull(res[1371].firstMatch("ax{1234}x{4321}yb "), 4106); + assertNull(res[1371].firstMatch("ax{1234}x{4321}x{3412}b "), 4107); + assertNull(res[1371].firstMatch("*** Failers"), 4108); + assertNull(res[1371].firstMatch("ax{1234}b "), 4109); + assertNull(res[1371].firstMatch("ac\ncb "), 4110); + assertToStringEquals( + "ax{1234}xyb,x{1234}xy", res[1372].firstMatch("ax{1234}xyb "), 4111); + assertToStringEquals("ax{1234}x{4321}yb,x{1234}x{4321}y", + res[1372].firstMatch("ax{1234}x{4321}yb "), 4112); + assertToStringEquals("ax{1234}x{4321}x{3412}b,x{1234}x{4321}x{3412}", + res[1372].firstMatch("ax{1234}x{4321}x{3412}b "), 4113); + assertToStringEquals("axxxxbcdefghijb,xxxxbcdefghij", + res[1372].firstMatch("axxxxbcdefghijb "), 4114); + assertToStringEquals( + "ax{1234}x{4321}x{3412}x{3421}b,x{1234}x{4321}x{3412}x{3421}", + res[1372].firstMatch("ax{1234}x{4321}x{3412}x{3421}b "), + 4115); + assertNull(res[1372].firstMatch("*** Failers"), 4116); + assertToStringEquals( + "ax{1234}b,x{1234}", res[1372].firstMatch("ax{1234}b "), 4117); + assertToStringEquals( + "ax{1234}xyb,x{1234}xy", res[1373].firstMatch("ax{1234}xyb "), 4118); + assertToStringEquals("ax{1234}x{4321}yb,x{1234}x{4321}y", + res[1373].firstMatch("ax{1234}x{4321}yb "), 4119); + assertToStringEquals("ax{1234}x{4321}x{3412}b,x{1234}x{4321}x{3412}", + res[1373].firstMatch("ax{1234}x{4321}x{3412}b "), 4120); + assertToStringEquals( + "axxxxb,xxxx", res[1373].firstMatch("axxxxbcdefghijb "), 4121); + assertToStringEquals( + "ax{1234}x{4321}x{3412}x{3421}b,x{1234}x{4321}x{3412}x{3421}", + res[1373].firstMatch("ax{1234}x{4321}x{3412}x{3421}b "), + 4122); + assertNull(res[1373].firstMatch("*** Failers"), 4123); + assertToStringEquals( + "ax{1234}b,x{1234}", res[1373].firstMatch("ax{1234}b "), 4124); + assertNull(res[1374].firstMatch("ax{1234}xyb "), 4125); + assertNull(res[1374].firstMatch("ax{1234}x{4321}yb "), 4126); + assertNull(res[1374].firstMatch("ax{1234}x{4321}x{3412}b "), 4127); + assertToStringEquals( + "axxxxb,xxxx", res[1374].firstMatch("axxxxbcdefghijb "), 4128); + assertNull(res[1374].firstMatch("ax{1234}x{4321}x{3412}x{3421}b "), 4129); + assertToStringEquals( + "axbxxb,xbxx", res[1374].firstMatch("axbxxbcdefghijb "), 4130); + assertToStringEquals( + "axxxxxb,xxxxx", res[1374].firstMatch("axxxxxbcdefghijb "), 4131); + assertNull(res[1374].firstMatch("*** Failers"), 4132); + assertNull(res[1374].firstMatch("ax{1234}b "), 4133); + assertNull(res[1374].firstMatch("axxxxxxbcdefghijb "), 4134); + assertNull(res[1375].firstMatch("ax{1234}xyb "), 4135); + assertNull(res[1375].firstMatch("ax{1234}x{4321}yb "), 4136); + assertNull(res[1375].firstMatch("ax{1234}x{4321}x{3412}b "), 4137); + assertToStringEquals( + "axxxxb,xxxx", res[1375].firstMatch("axxxxbcdefghijb "), 4138); + assertNull(res[1375].firstMatch("ax{1234}x{4321}x{3412}x{3421}b "), 4139); + assertToStringEquals( + "axbxxb,xbxx", res[1375].firstMatch("axbxxbcdefghijb "), 4140); + assertToStringEquals( + "axxxxxb,xxxxx", res[1375].firstMatch("axxxxxbcdefghijb "), 4141); + assertNull(res[1375].firstMatch("*** Failers"), 4142); + assertNull(res[1375].firstMatch("ax{1234}b "), 4143); + assertNull(res[1375].firstMatch("axxxxxxbcdefghijb "), 4144); + assertNull(res[1375].firstMatch("*** Failers"), 4145); + assertNull(res[1375].firstMatch("x{100}"), 4146); + assertNull(res[1375].firstMatch("aXbcd"), 4147); + assertNull(res[1375].firstMatch("ax{100}bcd"), 4148); + assertNull(res[1375].firstMatch("ax{100000}bcd"), 4149); + assertNull(res[1375].firstMatch("x{100}x{100}x{100}b"), 4150); + assertNull(res[1375].firstMatch("*** Failers "), 4151); + assertNull(res[1375].firstMatch("x{100}x{100}b"), 4152); + assertNull(res[1375].firstMatch("x{ab} "), 4153); + assertNull(res[1375].firstMatch("\xc2\xab"), 4154); + assertNull(res[1375].firstMatch("*** Failers "), 4155); + assertNull(res[1375].firstMatch("\x00{ab}"), 4156); + assertNull(res[1375].firstMatch("WXYZ"), 4157); + assertNull(res[1375].firstMatch("x{256}XYZ "), 4158); + assertNull(res[1375].firstMatch("*** Failers"), 4159); + assertNull(res[1375].firstMatch("XYZ "), 4160); + assertToStringEquals("bcd", res[1376].firstMatch("bcd"), 4161); + assertToStringEquals("x{", res[1377].firstMatch("x{100}bc"), 4163); + assertToStringEquals("x{100}bcA", res[1378].firstMatch("x{100}bcAa"), 4164); + assertToStringEquals("x{", res[1379].firstMatch("x{100}bca"), 4165); + assertToStringEquals("bcd", res[1380].firstMatch("bcd"), 4166); + assertToStringEquals("x{", res[1381].firstMatch("x{100}bc"), 4168); + assertToStringEquals("x{100}bc", res[1382].firstMatch("x{100}bcAa"), 4169); + assertToStringEquals("x{", res[1383].firstMatch("x{100}bca"), 4170); + assertNull(res[1383].firstMatch("abcd"), 4171); + assertNull(res[1383].firstMatch("abcd"), 4172); + assertToStringEquals("x{", res[1383].firstMatch("x{100}x{100} "), 4173); + assertToStringEquals("x{", res[1383].firstMatch("x{100}x{100} "), 4174); + assertToStringEquals( + "x{", res[1383].firstMatch("x{100}x{100}x{100}x{100} "), 4175); + assertNull(res[1383].firstMatch("abce"), 4176); + assertToStringEquals( + "x{", res[1383].firstMatch("x{100}x{100}x{100}x{100} "), 4177); + assertNull(res[1383].firstMatch("abcdx{100}x{100}x{100}x{100} "), 4178); + assertNull(res[1383].firstMatch("abcdx{100}x{100}x{100}x{100} "), 4179); + assertNull(res[1383].firstMatch("abcdx{100}x{100}x{100}x{100} "), 4180); + assertNull(res[1383].firstMatch("abcdx{100}x{100}x{100}XX"), 4181); + assertNull( + res[1383].firstMatch("abcdx{100}x{100}x{100}x{100}x{100}x{100}x{100}XX"), + 4182); + assertNull( + res[1383].firstMatch("abcdx{100}x{100}x{100}x{100}x{100}x{100}x{100}XX"), + 4183); + assertToStringEquals( + "Xy", res[1383].firstMatch("Xyyyax{100}x{100}bXzzz"), 4184); + assertToStringEquals("X", res[1386].firstMatch("1X2"), 4185); + assertToStringEquals("x", res[1386].firstMatch("1x{100}2 "), 4186); + assertToStringEquals(">X", res[1387].firstMatch("> >X Y"), 4187); + assertToStringEquals(">x", res[1387].firstMatch("> >x{100} Y"), 4188); + assertToStringEquals("1", res[1388].firstMatch("x{100}3"), 4189); + assertToStringEquals(" ", res[1389].firstMatch("x{100} X"), 4190); + assertToStringEquals("abcd", res[1390].firstMatch("12abcd34"), 4191); + assertToStringEquals( + "*** Failers", res[1390].firstMatch("*** Failers"), 4192); + assertToStringEquals(" ", res[1390].firstMatch("1234 "), 4193); + assertToStringEquals("abc", res[1391].firstMatch("12abcd34"), 4194); + assertToStringEquals("ab", res[1391].firstMatch("12ab34"), 4195); + assertToStringEquals("***", res[1391].firstMatch("*** Failers "), 4196); + assertNull(res[1391].firstMatch("1234"), 4197); + assertToStringEquals(" ", res[1391].firstMatch("12a34 "), 4198); + assertToStringEquals("ab", res[1392].firstMatch("12abcd34"), 4199); + assertToStringEquals("ab", res[1392].firstMatch("12ab34"), 4200); + assertToStringEquals("**", res[1392].firstMatch("*** Failers "), 4201); + assertNull(res[1392].firstMatch("1234"), 4202); + assertToStringEquals(" ", res[1392].firstMatch("12a34 "), 4203); + assertToStringEquals("12", res[1393].firstMatch("12abcd34"), 4204); + assertNull(res[1393].firstMatch("*** Failers"), 4205); + assertToStringEquals("12", res[1394].firstMatch("12abcd34"), 4206); + assertToStringEquals("123", res[1394].firstMatch("1234abcd"), 4207); + assertNull(res[1394].firstMatch("*** Failers "), 4208); + assertNull(res[1394].firstMatch("1.4 "), 4209); + assertToStringEquals("12", res[1395].firstMatch("12abcd34"), 4210); + assertToStringEquals("12", res[1395].firstMatch("1234abcd"), 4211); + assertNull(res[1395].firstMatch("*** Failers "), 4212); + assertNull(res[1395].firstMatch("1.4 "), 4213); + assertToStringEquals("12abcd34", res[1396].firstMatch("12abcd34"), 4214); + assertToStringEquals("***", res[1396].firstMatch("*** Failers"), 4215); + assertNull(res[1396].firstMatch(" "), 4216); + assertToStringEquals("12a", res[1397].firstMatch("12abcd34"), 4217); + assertToStringEquals("123", res[1397].firstMatch("1234abcd"), 4218); + assertToStringEquals("***", res[1397].firstMatch("*** Failers"), 4219); + assertNull(res[1397].firstMatch(" "), 4220); + assertToStringEquals("12", res[1398].firstMatch("12abcd34"), 4221); + assertToStringEquals("12", res[1398].firstMatch("1234abcd"), 4222); + assertToStringEquals("**", res[1398].firstMatch("*** Failers"), 4223); + assertNull(res[1398].firstMatch(" "), 4224); + assertToStringEquals("> <", res[1399].firstMatch("12> <34"), 4225); + assertNull(res[1399].firstMatch("*** Failers"), 4226); + assertToStringEquals("> <", res[1400].firstMatch("ab> <", res[1400].firstMatch("ab> <", res[1401].firstMatch("ab> <", res[1401].firstMatch("ab> \xff<"), 4303); + assertNull(res[1409].firstMatch(">x{ff}<"), 4304); + assertToStringEquals("X", res[1410].firstMatch("XYZ"), 4305); + assertToStringEquals("X", res[1411].firstMatch("XYZ"), 4306); + assertToStringEquals("x", res[1411].firstMatch("x{123} "), 4307); + assertToStringEquals(",", res[1416].firstMatch("catac"), 4308); + assertToStringEquals(",", res[1416].firstMatch("ax{256}a "), 4309); + assertToStringEquals(",", res[1416].firstMatch("x{85}"), 4310); + assertToStringEquals( + "abc1", + res[1417].firstMatch( + "abc1 \nabc2 \x0babc3xx \x0cabc4 \x0dabc5xx \x0d\nabc6 x{0085}abc7 x{2028}abc8 x{2029}abc9 JUNK"), + 4311); + assertToStringEquals( + "abc1", + res[1418].firstMatch( + "abc1\n abc2\x0b abc3\x0c abc4\x0d abc5\x0d\n abc6x{0085} abc7x{2028} abc8x{2029} abc9"), + 4312); + assertNull(res[1419].firstMatch("a\nb"), 4313); + assertNull(res[1419].firstMatch("a\x0db"), 4314); + assertNull(res[1419].firstMatch("a\x0d\nb"), 4315); + assertNull(res[1419].firstMatch("a\x0bb"), 4316); + assertNull(res[1419].firstMatch("a\x0cb"), 4317); + assertNull(res[1419].firstMatch("ax{85}b "), 4318); + assertNull(res[1419].firstMatch("ax{2028}b "), 4319); + assertNull(res[1419].firstMatch("ax{2029}b "), 4320); + assertNull(res[1419].firstMatch("** Failers"), 4321); + assertNull(res[1419].firstMatch("a\n\x0db "), 4322); + assertToStringEquals("ab", res[1420].firstMatch("ab"), 4323); + assertNull(res[1420].firstMatch("a\nb"), 4324); + assertNull(res[1420].firstMatch("a\x0db"), 4325); + assertNull(res[1420].firstMatch("a\x0d\nb"), 4326); + assertNull(res[1420].firstMatch("a\x0bb"), 4327); + assertNull(res[1420].firstMatch("a\x0cx{2028}x{2029}b"), 4328); + assertNull(res[1420].firstMatch("ax{85}b "), 4329); + assertNull(res[1420].firstMatch("a\n\x0db "), 4330); + assertNull(res[1420].firstMatch("a\n\x0dx{85}\x0cb "), 4331); + assertNull(res[1421].firstMatch("a\nb"), 4332); + assertNull(res[1421].firstMatch("a\x0db"), 4333); + assertNull(res[1421].firstMatch("a\x0d\nb"), 4334); + assertNull(res[1421].firstMatch("a\x0bb"), 4335); + assertNull(res[1421].firstMatch("a\x0cx{2028}x{2029}b"), 4336); + assertNull(res[1421].firstMatch("ax{85}b "), 4337); + assertNull(res[1421].firstMatch("a\n\x0db "), 4338); + assertNull(res[1421].firstMatch("a\n\x0dx{85}\x0cb "), 4339); + assertNull(res[1421].firstMatch("** Failers"), 4340); + assertNull(res[1421].firstMatch("ab "), 4341); + assertNull(res[1422].firstMatch("a\nb"), 4342); + assertNull(res[1422].firstMatch("a\n\x0db"), 4343); + assertNull(res[1422].firstMatch("a\n\x0dx{85}b"), 4344); + assertNull(res[1422].firstMatch("a\x0d\n\x0d\nb "), 4345); + assertNull(res[1422].firstMatch("a\x0d\n\x0d\n\x0d\nb "), 4346); + assertNull(res[1422].firstMatch("a\n\x0d\n\x0db"), 4347); + assertNull(res[1422].firstMatch("a\n\n\x0d\nb "), 4348); + assertNull(res[1422].firstMatch("** Failers"), 4349); + assertNull(res[1422].firstMatch("a\n\n\n\x0db"), 4350); + assertNull(res[1422].firstMatch("a\x0d"), 4351); + assertNull(res[1423].firstMatch("\x09 x{a0}X\n\x0b\x0c\x0d\n"), 4352); + assertNull(res[1424].firstMatch(" x{a0}X\n\x0b\x0c\x0d\n"), 4353); + assertNull(res[1425].firstMatch(">\x09 x{a0}X\n\n\n<"), 4354); + assertNull(res[1426].firstMatch(">\x09 x{a0}X\n\n\n<"), 4355); + assertNull(res[1427].firstMatch("X X\n"), 4356); + assertNull(res[1427].firstMatch("X\x09X\x0b"), 4357); + assertNull(res[1427].firstMatch("** Failers"), 4358); + assertNull(res[1427].firstMatch("x{a0} X\n "), 4359); + assertNull(res[1428].firstMatch("\x09 x{a0}X\n\x0b\x0c\x0d\n"), 4360); + assertNull(res[1428].firstMatch("\x09 x{a0}\n\x0b\x0c\x0d\n"), 4361); + assertNull(res[1428].firstMatch("\x09 x{a0}\n\x0b\x0c"), 4362); + assertNull(res[1428].firstMatch("** Failers "), 4363); + assertNull(res[1428].firstMatch("\x09 x{a0}\n\x0b"), 4364); + assertNull(res[1428].firstMatch(" "), 4365); + assertNull(res[1429].firstMatch("x{3001}x{3000}x{2030}x{2028}"), 4366); + assertNull(res[1429].firstMatch("Xx{180e}Xx{85}"), 4367); + assertNull(res[1429].firstMatch("** Failers"), 4368); + assertNull(res[1429].firstMatch("x{2009} X\n "), 4369); + assertNull( + res[1430].firstMatch("x{1680}x{180e}x{2007}Xx{2028}x{2029}\x0c\x0d\n"), + 4370); + assertNull( + res[1430].firstMatch("\x09x{205f}x{a0}\nx{2029}\x0cx{2028}\n"), 4371); + assertNull(res[1430].firstMatch("\x09 x{202f}\n\x0b\x0c"), 4372); + assertNull(res[1430].firstMatch("** Failers "), 4373); + assertNull(res[1430].firstMatch("\x09x{200a}x{a0}x{2028}\x0b"), 4374); + assertNull(res[1430].firstMatch(" "), 4375); + assertNull(res[1431].firstMatch("a\x0db"), 4376); + assertNull(res[1431].firstMatch("a\nb"), 4377); + assertNull(res[1431].firstMatch("a\x0d\nb"), 4378); + assertNull(res[1431].firstMatch("** Failers"), 4379); + assertNull(res[1431].firstMatch("ax{85}b"), 4380); + assertNull(res[1431].firstMatch("a\x0bb "), 4381); + assertNull(res[1432].firstMatch("a\x0db"), 4382); + assertNull(res[1432].firstMatch("a\nb"), 4383); + assertNull(res[1432].firstMatch("a\x0d\nb"), 4384); + assertNull(res[1432].firstMatch("ax{85}b"), 4385); + assertNull(res[1432].firstMatch("a\x0bb "), 4386); + assertNull(res[1432].firstMatch("** Failers "), 4387); + assertNull(res[1432].firstMatch("ax{85}b"), 4388); + assertNull(res[1432].firstMatch("a\x0bb"), 4389); + assertNull(res[1433].firstMatch("a\x0db"), 4390); + assertNull(res[1433].firstMatch("a\nb"), 4391); + assertNull(res[1433].firstMatch("a\x0d\nb"), 4392); + assertNull(res[1433].firstMatch("** Failers"), 4393); + assertNull(res[1433].firstMatch("ax{85}b"), 4394); + assertNull(res[1433].firstMatch("a\x0bb "), 4395); + assertNull(res[1434].firstMatch("a\x0db"), 4396); + assertNull(res[1434].firstMatch("a\nb"), 4397); + assertNull(res[1434].firstMatch("a\x0d\nb"), 4398); + assertNull(res[1434].firstMatch("ax{85}b"), 4399); + assertNull(res[1434].firstMatch("a\x0bb "), 4400); + assertNull(res[1434].firstMatch("** Failers "), 4401); + assertNull(res[1434].firstMatch("ax{85}b"), 4402); + assertNull(res[1434].firstMatch("a\x0bb"), 4403); + assertToStringEquals("X", res[1435].firstMatch("Ax{1ec5}ABCXYZ"), 4404); + assertNull(res[1437].firstMatch("AB"), 4405); + assertNull(res[1437].firstMatch("*** Failers"), 4406); + assertNull(res[1437].firstMatch("A0"), 4407); + assertNull(res[1437].firstMatch("00 "), 4408); + assertNull(res[1438].firstMatch("AB"), 4409); + assertNull(res[1438].firstMatch("Ax{300}BC "), 4410); + assertNull(res[1438].firstMatch("Ax{300}x{301}x{302}BC "), 4411); + assertNull(res[1438].firstMatch("*** Failers"), 4412); + assertNull(res[1438].firstMatch("x{300} "), 4413); + assertNull(res[1439].firstMatch("ABC"), 4414); + assertNull(res[1439].firstMatch("Ax{300}Bx{300}x{301}C "), 4415); + assertNull(res[1439].firstMatch("Ax{300}x{301}x{302}BC "), 4416); + assertNull(res[1439].firstMatch("*** Failers"), 4417); + assertNull(res[1439].firstMatch("x{300} "), 4418); + assertNull(res[1440].firstMatch("abcd"), 4419); + assertNull(res[1440].firstMatch("a "), 4420); + assertNull(res[1440].firstMatch("*** Failers "), 4421); + assertNull(res[1441].firstMatch("1234"), 4422); + assertNull(res[1441].firstMatch("= "), 4423); + assertNull(res[1441].firstMatch("*** Failers "), 4424); + assertNull(res[1441].firstMatch("abcd "), 4425); + assertNull(res[1442].firstMatch("abcdAx{300}x{301}x{302}"), 4426); + assertNull(res[1442].firstMatch("Ax{300}x{301}x{302}"), 4427); + assertNull( + res[1442].firstMatch("Ax{300}x{301}x{302}Ax{300}x{301}x{302}"), 4428); + assertNull(res[1442].firstMatch("a "), 4429); + assertNull(res[1442].firstMatch("*** Failers "), 4430); + assertNull(res[1442].firstMatch("x{300}x{301}x{302}"), 4431); + assertToStringEquals("abc", res[1443].firstMatch("abc"), 4432); + assertToStringEquals("abc", res[1443].firstMatch("Ax{300}abc"), 4433); + assertToStringEquals( + "abc", + res[1443].firstMatch("Ax{300}x{301}x{302}Ax{300}Ax{300}Ax{300}abcxyz"), + 4434); + assertToStringEquals("abc", res[1443].firstMatch("x{300}abc "), 4435); + assertNull(res[1443].firstMatch("*** Failers"), 4436); + assertToStringEquals("abc", res[1444].firstMatch("abc"), 4437); + assertNull(res[1444].firstMatch("Ax{300}abc"), 4438); + assertNull(res[1444].firstMatch("*** Failers"), 4439); + assertNull( + res[1444].firstMatch("Ax{300}x{301}x{302}Ax{300}Ax{300}Ax{300}abcxyz"), + 4440); + assertNull(res[1444].firstMatch("x{300}abc "), 4441); + assertToStringEquals("abc", res[1445].firstMatch("abc"), 4442); + assertToStringEquals("abc", res[1445].firstMatch("Ax{300}abc"), 4443); + assertToStringEquals( + "abc", + res[1445].firstMatch("Ax{300}x{301}x{302}Ax{300}Ax{300}Ax{300}abcxyz"), + 4444); + assertToStringEquals("abc", res[1445].firstMatch("x{300}abc "), 4445); + assertNull(res[1445].firstMatch("*** Failers"), 4446); + assertToStringEquals("abc", res[1446].firstMatch("abc"), 4447); + assertNull(res[1446].firstMatch("Ax{300}abc"), 4448); + assertNull( + res[1446].firstMatch("Ax{300}x{301}x{302}Ax{300}Ax{300}Ax{300}abcxyz"), + 4449); + assertNull(res[1446].firstMatch("*** Failers"), 4450); + assertNull(res[1446].firstMatch("x{300}abc "), 4451); + assertNull(res[1447].firstMatch("A=b"), 4452); + assertNull(res[1447].firstMatch("=c "), 4453); + assertNull(res[1447].firstMatch("*** Failers"), 4454); + assertNull(res[1447].firstMatch("1=2 "), 4455); + assertNull(res[1447].firstMatch("AAAA=b "), 4456); + assertNull(res[1448].firstMatch("AAAA=b"), 4457); + assertNull(res[1448].firstMatch("=c "), 4458); + assertNull(res[1448].firstMatch("*** Failers"), 4459); + assertNull(res[1448].firstMatch("1=2 "), 4460); + assertNull( + res[1449].firstMatch("Ax{300}x{301}x{302}Ax{300}x{301}x{302}X"), 4461); + assertNull( + res[1449].firstMatch( + "Ax{300}x{301}x{302}Ax{300}x{301}x{302}Ax{300}x{301}x{302}X "), + 4462); + assertNull(res[1449].firstMatch("*** Failers"), 4463); + assertNull(res[1449].firstMatch("X"), 4464); + assertNull(res[1449].firstMatch("Ax{300}x{301}x{302}X"), 4465); + assertNull( + res[1449].firstMatch( + "Ax{300}x{301}x{302}Ax{300}x{301}x{302}Ax{300}x{301}x{302}Ax{300}x{301}x{302}X"), + 4466); + assertNull( + res[1450].firstMatch("x{c0}x{30f}x{660}x{66c}x{f01}x{1680}<"), 4467); + assertNull(res[1450].firstMatch("\npx{300}9!\$ < "), 4468); + assertNull(res[1450].firstMatch("** Failers "), 4469); + assertNull(res[1450].firstMatch("apx{300}9!\$ < "), 4470); + assertNull(res[1451].firstMatch("X"), 4471); + assertNull(res[1451].firstMatch("** Failers "), 4472); + assertNull(res[1451].firstMatch(""), 4473); + assertNull(res[1452].firstMatch("9"), 4474); + assertNull(res[1452].firstMatch("** Failers "), 4475); + assertNull(res[1452].firstMatch("x{c0}"), 4476); + assertNull(res[1453].firstMatch("X"), 4477); + assertNull(res[1453].firstMatch("** Failers "), 4478); + assertNull(res[1453].firstMatch("x{30f}"), 4479); + assertNull(res[1454].firstMatch("X"), 4480); + assertNull(res[1454].firstMatch("** Failers "), 4481); + assertNull(res[1454].firstMatch("x{660}"), 4482); + assertNull(res[1455].firstMatch("X"), 4483); + assertNull(res[1455].firstMatch("** Failers "), 4484); + assertNull(res[1455].firstMatch("x{66c}"), 4485); + assertNull(res[1456].firstMatch("X"), 4486); + assertNull(res[1456].firstMatch("** Failers "), 4487); + assertNull(res[1456].firstMatch("x{f01}"), 4488); + assertNull(res[1457].firstMatch("X"), 4489); + assertNull(res[1457].firstMatch("** Failers "), 4490); + assertNull(res[1457].firstMatch("x{1680}"), 4491); + assertNull(res[1458].firstMatch("x{017}"), 4492); + assertNull(res[1458].firstMatch("x{09f} "), 4493); + assertNull(res[1458].firstMatch("** Failers"), 4494); + assertNull(res[1458].firstMatch("x{0600} "), 4495); + assertNull(res[1459].firstMatch("x{601}"), 4496); + assertNull(res[1459].firstMatch("** Failers"), 4497); + assertNull(res[1459].firstMatch("x{09f} "), 4498); + assertNull(res[1460].firstMatch("** Failers"), 4499); + assertNull(res[1460].firstMatch("x{09f} "), 4500); + assertNull(res[1461].firstMatch("x{f8ff}"), 4501); + assertNull(res[1461].firstMatch("** Failers"), 4502); + assertNull(res[1461].firstMatch("x{09f} "), 4503); + assertNull(res[1462].firstMatch("?x{dfff}"), 4504); + assertNull(res[1462].firstMatch("** Failers"), 4505); + assertNull(res[1462].firstMatch("x{09f} "), 4506); + assertNull(res[1463].firstMatch("a"), 4507); + assertNull(res[1463].firstMatch("** Failers "), 4508); + assertNull(res[1463].firstMatch("Z"), 4509); + assertNull(res[1463].firstMatch("x{e000} "), 4510); + assertNull(res[1464].firstMatch("x{2b0}"), 4511); + assertNull(res[1464].firstMatch("** Failers"), 4512); + assertNull(res[1464].firstMatch("a "), 4513); + assertNull(res[1465].firstMatch("x{1bb}"), 4514); + assertNull(res[1465].firstMatch("** Failers"), 4515); + assertNull(res[1465].firstMatch("a "), 4516); + assertNull(res[1465].firstMatch("x{2b0}"), 4517); + assertNull(res[1466].firstMatch("x{1c5}"), 4518); + assertNull(res[1466].firstMatch("** Failers"), 4519); + assertNull(res[1466].firstMatch("a "), 4520); + assertNull(res[1466].firstMatch("x{2b0}"), 4521); + assertNull(res[1467].firstMatch("A"), 4522); + assertNull(res[1467].firstMatch("** Failers"), 4523); + assertNull(res[1467].firstMatch("x{2b0}"), 4524); + assertNull(res[1468].firstMatch("x{903}"), 4525); + assertNull(res[1468].firstMatch("** Failers"), 4526); + assertNull(res[1468].firstMatch("X"), 4527); + assertNull(res[1468].firstMatch("x{300}"), 4528); + assertNull(res[1468].firstMatch(" "), 4529); + assertNull(res[1469].firstMatch("x{488}"), 4530); + assertNull(res[1469].firstMatch("** Failers"), 4531); + assertNull(res[1469].firstMatch("X"), 4532); + assertNull(res[1469].firstMatch("x{903}"), 4533); + assertNull(res[1469].firstMatch("x{300}"), 4534); + assertNull(res[1470].firstMatch("x{300}"), 4535); + assertNull(res[1470].firstMatch("** Failers"), 4536); + assertNull(res[1470].firstMatch("X"), 4537); + assertNull(res[1470].firstMatch("x{903}"), 4538); + assertNull( + res[1470].firstMatch( + "0123456789x{660}x{661}x{662}x{663}x{664}x{665}x{666}x{667}x{668}x{669}x{66a}"), + 4539); + assertNull( + res[1470].firstMatch( + "x{6f0}x{6f1}x{6f2}x{6f3}x{6f4}x{6f5}x{6f6}x{6f7}x{6f8}x{6f9}x{6fa}"), + 4540); + assertNull( + res[1470].firstMatch( + "x{966}x{967}x{968}x{969}x{96a}x{96b}x{96c}x{96d}x{96e}x{96f}x{970}"), + 4541); + assertNull(res[1470].firstMatch("** Failers"), 4542); + assertNull(res[1470].firstMatch("X"), 4543); + assertNull(res[1471].firstMatch("x{16ee}"), 4544); + assertNull(res[1471].firstMatch("** Failers"), 4545); + assertNull(res[1471].firstMatch("X"), 4546); + assertNull(res[1471].firstMatch("x{966}"), 4547); + assertNull(res[1472].firstMatch("x{b2}"), 4548); + assertNull(res[1472].firstMatch("x{b3}"), 4549); + assertNull(res[1472].firstMatch("** Failers"), 4550); + assertNull(res[1472].firstMatch("X"), 4551); + assertNull(res[1472].firstMatch("x{16ee}"), 4552); + assertNull(res[1473].firstMatch("_"), 4553); + assertNull(res[1473].firstMatch("x{203f}"), 4554); + assertNull(res[1473].firstMatch("** Failers"), 4555); + assertNull(res[1473].firstMatch("X"), 4556); + assertNull(res[1473].firstMatch("-"), 4557); + assertNull(res[1473].firstMatch("x{58a}"), 4558); + assertNull(res[1474].firstMatch("-"), 4559); + assertNull(res[1474].firstMatch("x{58a}"), 4560); + assertNull(res[1474].firstMatch("** Failers"), 4561); + assertNull(res[1474].firstMatch("X"), 4562); + assertNull(res[1474].firstMatch("x{203f}"), 4563); + assertNull(res[1475].firstMatch(")"), 4564); + assertNull(res[1475].firstMatch("]"), 4565); + assertNull(res[1475].firstMatch("}"), 4566); + assertNull(res[1475].firstMatch("x{f3b}"), 4567); + assertNull(res[1475].firstMatch("** Failers"), 4568); + assertNull(res[1475].firstMatch("X"), 4569); + assertNull(res[1475].firstMatch("x{203f}"), 4570); + assertNull(res[1475].firstMatch("("), 4571); + assertNull(res[1475].firstMatch("["), 4572); + assertNull(res[1475].firstMatch("{"), 4573); + assertNull(res[1475].firstMatch("x{f3c}"), 4574); + assertNull(res[1476].firstMatch("x{bb}"), 4575); + assertNull(res[1476].firstMatch("x{2019}"), 4576); + assertNull(res[1476].firstMatch("** Failers"), 4577); + assertNull(res[1476].firstMatch("X"), 4578); + assertNull(res[1476].firstMatch("x{203f}"), 4579); + assertNull(res[1477].firstMatch("x{ab}"), 4580); + assertNull(res[1477].firstMatch("x{2018}"), 4581); + assertNull(res[1477].firstMatch("** Failers"), 4582); + assertNull(res[1477].firstMatch("X"), 4583); + assertNull(res[1477].firstMatch("x{203f}"), 4584); + assertNull(res[1478].firstMatch("!"), 4585); + assertNull(res[1478].firstMatch("x{37e}"), 4586); + assertNull(res[1478].firstMatch("** Failers"), 4587); + assertNull(res[1478].firstMatch("X"), 4588); + assertNull(res[1478].firstMatch("x{203f}"), 4589); + assertNull(res[1479].firstMatch("("), 4590); + assertNull(res[1479].firstMatch("["), 4591); + assertNull(res[1479].firstMatch("{"), 4592); + assertNull(res[1479].firstMatch("x{f3c}"), 4593); + assertNull(res[1479].firstMatch("** Failers"), 4594); + assertNull(res[1479].firstMatch("X"), 4595); + assertNull(res[1479].firstMatch(")"), 4596); + assertNull(res[1479].firstMatch("]"), 4597); + assertNull(res[1479].firstMatch("}"), 4598); + assertNull(res[1479].firstMatch("x{f3b}"), 4599); + assertNull(res[1479].firstMatch("\$x{a2}x{a3}x{a4}x{a5}x{a6}"), 4600); + assertNull(res[1479].firstMatch("x{9f2}"), 4601); + assertNull(res[1479].firstMatch("** Failers"), 4602); + assertNull(res[1479].firstMatch("X"), 4603); + assertNull(res[1479].firstMatch("x{2c2}"), 4604); + assertNull(res[1480].firstMatch("x{2c2}"), 4605); + assertNull(res[1480].firstMatch("** Failers"), 4606); + assertNull(res[1480].firstMatch("X"), 4607); + assertNull(res[1480].firstMatch("x{9f2}"), 4608); + assertNull(res[1480].firstMatch("+<|~x{ac}x{2044}"), 4609); + assertNull(res[1480].firstMatch("** Failers"), 4610); + assertNull(res[1480].firstMatch("X"), 4611); + assertNull(res[1480].firstMatch("x{9f2}"), 4612); + assertNull(res[1481].firstMatch("x{a6}"), 4613); + assertNull(res[1481].firstMatch("x{482} "), 4614); + assertNull(res[1481].firstMatch("** Failers"), 4615); + assertNull(res[1481].firstMatch("X"), 4616); + assertNull(res[1481].firstMatch("x{9f2}"), 4617); + assertNull(res[1482].firstMatch("x{2028}"), 4618); + assertNull(res[1482].firstMatch("** Failers"), 4619); + assertNull(res[1482].firstMatch("X"), 4620); + assertNull(res[1482].firstMatch("x{2029}"), 4621); + assertNull(res[1483].firstMatch("x{2029}"), 4622); + assertNull(res[1483].firstMatch("** Failers"), 4623); + assertNull(res[1483].firstMatch("X"), 4624); + assertNull(res[1483].firstMatch("x{2028}"), 4625); + assertNull(res[1484].firstMatch("\\ \\"), 4626); + assertNull(res[1484].firstMatch("x{a0}"), 4627); + assertNull(res[1484].firstMatch("x{1680}"), 4628); + assertNull(res[1484].firstMatch("x{180e}"), 4629); + assertNull(res[1484].firstMatch("x{2000}"), 4630); + assertNull(res[1484].firstMatch("x{2001} "), 4631); + assertNull(res[1484].firstMatch("** Failers"), 4632); + assertNull(res[1484].firstMatch("x{2028}"), 4633); + assertNull(res[1484].firstMatch("x{200d} "), 4634); + assertNull(res[1484].firstMatch(" x{660}x{661}x{662}ABC"), 4635); + assertNull(res[1484].firstMatch(" x{660}x{661}x{662}ABC"), 4636); + assertNull(res[1485].firstMatch(" x{660}x{661}x{662}ABC"), 4637); + assertNull(res[1486].firstMatch(" x{660}x{661}x{662}ABC"), 4638); + assertNull(res[1487].firstMatch(" x{660}x{661}x{662}ABC"), 4639); + assertNull(res[1488].firstMatch(" x{660}x{661}x{662}ABC"), 4640); + assertNull(res[1489].firstMatch(" x{660}x{661}x{662}ABC"), 4641); + assertNull(res[1490].firstMatch(" x{660}x{661}x{662}ABC"), 4642); + assertNull(res[1491].firstMatch(" x{660}x{661}x{662}ABC"), 4643); + assertNull(res[1492].firstMatch(" x{660}x{661}x{662}ABC"), 4644); + assertNull(res[1493].firstMatch(" x{660}x{661}x{662}ABC"), 4645); + assertNull(res[1493].firstMatch(" x{660}x{661}x{662}ABC"), 4646); + assertNull(res[1493].firstMatch(" x{660}x{661}x{662}ABC"), 4647); + assertNull(res[1493].firstMatch(" ** Failers"), 4648); + assertNull(res[1493].firstMatch(" x{660}x{661}x{662}ABC"), 4649); + assertNull(res[1494].firstMatch("A"), 4650); + assertNull(res[1494].firstMatch("ax{10a0}B "), 4651); + assertNull(res[1494].firstMatch("** Failers "), 4652); + assertNull(res[1494].firstMatch("a"), 4653); + assertNull(res[1494].firstMatch("x{1d00} "), 4654); + assertNull(res[1495].firstMatch("1234"), 4655); + assertNull(res[1495].firstMatch("** Failers"), 4656); + assertNull(res[1495].firstMatch("ABC "), 4657); + assertNull(res[1496].firstMatch("1234"), 4658); + assertNull(res[1496].firstMatch("** Failers"), 4659); + assertNull(res[1496].firstMatch("ABC "), 4660); + assertNull(res[1496].firstMatch("A2XYZ"), 4661); + assertNull(res[1496].firstMatch("123A5XYZPQR"), 4662); + assertNull(res[1496].firstMatch("ABAx{660}XYZpqr"), 4663); + assertNull(res[1496].firstMatch("** Failers"), 4664); + assertNull(res[1496].firstMatch("AXYZ"), 4665); + assertNull(res[1496].firstMatch("XYZ "), 4666); + assertNull(res[1496].firstMatch("1XYZ"), 4667); + assertNull(res[1496].firstMatch("AB=XYZ.. "), 4668); + assertNull(res[1496].firstMatch("XYZ "), 4669); + assertNull(res[1496].firstMatch("** Failers"), 4670); + assertNull(res[1496].firstMatch("WXYZ "), 4671); + assertNull(res[1497].firstMatch("1234"), 4672); + assertNull(res[1497].firstMatch("1234"), 4673); + assertNull(res[1497].firstMatch("12-34"), 4674); + assertToStringEquals("{", res[1497].firstMatch("12+x{661}-34 "), 4675); + assertNull(res[1497].firstMatch("** Failers"), 4676); + assertToStringEquals("d", res[1497].firstMatch("abcd "), 4677); + assertToStringEquals("d", res[1498].firstMatch("abcd"), 4678); + assertNull(res[1498].firstMatch("** Failers"), 4679); + assertNull(res[1498].firstMatch("1234"), 4680); + assertNull( + res[1499].firstMatch( + "11111111111111111111111111111111111111111111111111111111111111111111111"), + 4681); + assertToStringEquals( + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + res[1499].firstMatch( + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + 4682); + assertToStringEquals(" ", res[1499].firstMatch(" "), 4683); + assertNull( + res[1499].firstMatch( + "11111111111111111111111111111111111111111111111111111111111111111111111"), + 4684); + assertToStringEquals( + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + res[1499].firstMatch( + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + 4685); + assertNull( + res[1500].firstMatch( + "11111111111111111111111111111111111111111111111111111111111111111111111"), + 4686); + assertToStringEquals( + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + res[1500].firstMatch( + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + 4687); + assertNull( + res[1501].firstMatch( + "11111111111111111111111111111111111111111111111111111111111111111111111"), + 4688); + assertNull( + res[1501].firstMatch( + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + 4689); + assertNull( + res[1502].firstMatch( + "11111111111111111111111111111111111111111111111111111111111111111111111"), + 4690); + assertToStringEquals( + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + res[1502].firstMatch( + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), + 4691); + assertNull(res[1503].firstMatch("a"), 4692); + assertNull(res[1503].firstMatch("A "), 4693); + assertNull(res[1504].firstMatch("a"), 4694); + assertNull(res[1504].firstMatch("A "), 4695); + assertNull(res[1505].firstMatch("A"), 4696); + assertNull(res[1505].firstMatch("aZ"), 4697); + assertNull(res[1505].firstMatch("** Failers"), 4698); + assertNull(res[1505].firstMatch("abc "), 4699); + assertNull(res[1506].firstMatch("A"), 4700); + assertNull(res[1506].firstMatch("aZ"), 4701); + assertNull(res[1506].firstMatch("** Failers"), 4702); + assertNull(res[1506].firstMatch("abc "), 4703); + assertNull(res[1507].firstMatch("a"), 4704); + assertNull(res[1507].firstMatch("Az"), 4705); + assertNull(res[1507].firstMatch("** Failers"), 4706); + assertNull(res[1507].firstMatch("ABC "), 4707); + assertNull(res[1508].firstMatch("a"), 4708); + assertNull(res[1508].firstMatch("Az"), 4709); + assertNull(res[1508].firstMatch("** Failers"), 4710); + assertNull(res[1508].firstMatch("ABC "), 4711); + assertNull(res[1508].firstMatch("x{c0}"), 4712); + assertNull(res[1508].firstMatch("x{e0} "), 4713); + assertNull(res[1508].firstMatch("x{c0}"), 4714); + assertNull(res[1508].firstMatch("x{e0} "), 4715); + assertNull(res[1508].firstMatch("Ax{391}x{10427}x{ff3a}x{1fb0}"), 4716); + assertNull(res[1508].firstMatch("** Failers"), 4717); + assertNull(res[1508].firstMatch("ax{391}x{10427}x{ff3a}x{1fb0} "), 4718); + assertNull(res[1508].firstMatch("Ax{3b1}x{10427}x{ff3a}x{1fb0}"), 4719); + assertNull(res[1508].firstMatch("Ax{391}x{1044F}x{ff3a}x{1fb0}"), 4720); + assertNull(res[1508].firstMatch("Ax{391}x{10427}x{ff5a}x{1fb0}"), 4721); + assertNull(res[1508].firstMatch("Ax{391}x{10427}x{ff3a}x{1fb8}"), 4722); + assertNull(res[1508].firstMatch("Ax{391}x{10427}x{ff3a}x{1fb0}"), 4723); + assertNull(res[1508].firstMatch("ax{391}x{10427}x{ff3a}x{1fb0} "), 4724); + assertNull(res[1508].firstMatch("Ax{3b1}x{10427}x{ff3a}x{1fb0}"), 4725); + assertNull(res[1508].firstMatch("Ax{391}x{1044F}x{ff3a}x{1fb0}"), 4726); + assertNull(res[1508].firstMatch("Ax{391}x{10427}x{ff5a}x{1fb0}"), 4727); + assertNull(res[1508].firstMatch("Ax{391}x{10427}x{ff3a}x{1fb8}"), 4728); + assertNull(res[1508].firstMatch("x{391}x{3b1}x{3b1}x{3b1}x{391}"), 4729); + assertNull(res[1508].firstMatch("x{391}x{3b1}x{3b1}x{3b1}x{391}X"), 4730); + assertNull(res[1508].firstMatch("x{391}x{3b1}x{3b1}x{3b1}x{391}X"), 4731); + assertNull(res[1508].firstMatch("x{391}"), 4732); + assertNull(res[1508].firstMatch("x{ff3a}"), 4733); + assertNull(res[1508].firstMatch("x{3b1}"), 4734); + assertNull(res[1508].firstMatch("x{ff5a} "), 4735); + assertNull(res[1508].firstMatch("x{c0}"), 4736); + assertNull(res[1508].firstMatch("x{e0} "), 4737); + assertNull(res[1508].firstMatch("x{104}"), 4738); + assertNull(res[1508].firstMatch("x{105}"), 4739); + assertNull(res[1508].firstMatch("x{109} "), 4740); + assertNull(res[1508].firstMatch("** Failers"), 4741); + assertNull(res[1508].firstMatch("x{100}"), 4742); + assertNull(res[1508].firstMatch("x{10a} "), 4743); + assertNull(res[1508].firstMatch("Z"), 4744); + assertNull(res[1508].firstMatch("z"), 4745); + assertNull(res[1508].firstMatch("x{39c}"), 4746); + assertNull(res[1508].firstMatch("x{178}"), 4747); + assertNull(res[1508].firstMatch("|"), 4748); + assertNull(res[1508].firstMatch("x{80}"), 4749); + assertNull(res[1508].firstMatch("x{ff}"), 4750); + assertNull(res[1508].firstMatch("x{100}"), 4751); + assertNull(res[1508].firstMatch("x{101} "), 4752); + assertNull(res[1508].firstMatch("** Failers"), 4753); + assertNull(res[1508].firstMatch("x{102}"), 4754); + assertNull(res[1508].firstMatch("Y"), 4755); + assertNull(res[1508].firstMatch("y "), 4756); + assertNull(res[1509].firstMatch("A"), 4757); + assertNull(res[1509].firstMatch("Ax{300}BC "), 4758); + assertNull(res[1509].firstMatch("Ax{300}x{301}x{302}BC "), 4759); + assertNull(res[1509].firstMatch("*** Failers"), 4760); + assertNull(res[1509].firstMatch("x{300} "), 4761); + assertToStringEquals("X", res[1510].firstMatch("X123"), 4762); + assertNull(res[1510].firstMatch("*** Failers"), 4763); + assertNull(res[1510].firstMatch("AXYZ"), 4764); + assertNull(res[1511].firstMatch("Ax{300}x{301}x{302}BCAx{300}x{301} "), 4765); + assertNull( + res[1511].firstMatch("Ax{300}x{301}x{302}BCAx{300}x{301}C "), 4766); + assertNull(res[1512].firstMatch("Ax{300}x{301}x{302}BCAx{300}x{301} "), 4767); + assertNull( + res[1512].firstMatch("Ax{300}x{301}x{302}BCAx{300}x{301}C "), 4768); + assertToStringEquals("A,,A", + res[1513].firstMatch("Ax{300}x{301}x{302}BCAx{300}x{301} "), 4769); + assertToStringEquals("A,,A", + res[1513].firstMatch("Ax{300}x{301}x{302}BCAx{300}x{301}C "), 4770); + assertToStringEquals("A,,A", + res[1514].firstMatch("Ax{300}x{301}x{302}BCAx{300}x{301} "), 4771); + assertToStringEquals("A,,A", + res[1514].firstMatch("Ax{300}x{301}x{302}BCAx{300}x{301}C "), 4772); + assertNull(res[1515].firstMatch("*** Failers"), 4773); + assertNull(res[1515].firstMatch("Ax{300}x{301}x{302}"), 4774); + assertNull(res[1516].firstMatch("Ax{300}x{301}Bx{300}X"), 4775); + assertNull(res[1516].firstMatch("Ax{300}x{301}Bx{300}Cx{300}x{301}"), 4776); + assertNull(res[1516].firstMatch("Ax{300}x{301}Bx{300}Cx{300}x{301}X"), 4777); + assertNull( + res[1516].firstMatch("Ax{300}x{301}Bx{300}Cx{300}x{301}DAx{300}X"), 4778); + assertNull(res[1517].firstMatch("Ax{300}x{301}Bx{300}X"), 4779); + assertNull(res[1517].firstMatch("Ax{300}x{301}Bx{300}Cx{300}x{301}"), 4780); + assertNull(res[1517].firstMatch("Ax{300}x{301}Bx{300}Cx{300}x{301}X"), 4781); + assertNull( + res[1517].firstMatch("Ax{300}x{301}Bx{300}Cx{300}x{301}DAx{300}X"), 4782); + assertNull(res[1518].firstMatch("12X"), 4783); + assertNull(res[1518].firstMatch("123X"), 4784); + assertNull(res[1518].firstMatch("*** Failers"), 4785); + assertNull(res[1518].firstMatch("X"), 4786); + assertNull(res[1518].firstMatch("1X"), 4787); + assertNull(res[1518].firstMatch("1234X "), 4788); + assertNull(res[1518].firstMatch("x{100} "), 4789); + assertNull(res[1518].firstMatch("x{101} "), 4790); + assertNull(res[1518].firstMatch("x{2e81}x{3007}x{2f804}x{31a0}"), 4791); + assertNull(res[1518].firstMatch("** Failers"), 4792); + assertNull(res[1518].firstMatch("x{2e7f} "), 4793); + assertNull(res[1518].firstMatch("x{3105}"), 4794); + assertNull(res[1518].firstMatch("** Failers"), 4795); + assertNull(res[1518].firstMatch("x{30ff} "), 4796); + assertNull(res[1519].firstMatch("x{06e9}"), 4797); + assertNull(res[1519].firstMatch("x{060b}"), 4798); + assertNull(res[1519].firstMatch("** Failers"), 4799); + assertNull(res[1519].firstMatch("Xx{06e9} "), 4800); + assertNull(res[1520].firstMatch("x{2f800}"), 4801); + assertNull(res[1520].firstMatch("** Failers"), 4802); + assertNull(res[1520].firstMatch("x{a014}"), 4803); + assertNull(res[1520].firstMatch("x{a4c6} "), 4804); + assertNull(res[1521].firstMatch("AXYZ"), 4805); + assertNull(res[1521].firstMatch("x{1234}XYZ "), 4806); + assertNull(res[1521].firstMatch("** Failers"), 4807); + assertNull(res[1521].firstMatch("X "), 4808); + assertNull(res[1522].firstMatch("** Failers"), 4809); + assertNull(res[1522].firstMatch("AX"), 4810); + assertNull(res[1523].firstMatch("XYZ"), 4811); + assertNull(res[1523].firstMatch("AXYZ"), 4812); + assertNull(res[1523].firstMatch("x{1234}XYZ "), 4813); + assertNull(res[1523].firstMatch("** Failers"), 4814); + assertNull(res[1523].firstMatch("ABXYZ "), 4815); + assertNull(res[1524].firstMatch("XYZ"), 4816); + assertNull(res[1524].firstMatch("** Failers"), 4817); + assertNull(res[1524].firstMatch("AXYZ"), 4818); + assertNull(res[1524].firstMatch("x{1234}XYZ "), 4819); + assertNull(res[1524].firstMatch("ABXYZ "), 4820); + assertNull(res[1524].firstMatch("AXYZ"), 4821); + assertNull(res[1524].firstMatch("x{1234}XYZ"), 4822); + assertNull(res[1524].firstMatch("Ax{1234}XYZ"), 4823); + assertNull(res[1524].firstMatch("** Failers"), 4824); + assertNull(res[1524].firstMatch("XYZ"), 4825); + assertNull(res[1524].firstMatch("** Failers"), 4826); + assertNull(res[1524].firstMatch("AXYZ"), 4827); + assertNull(res[1524].firstMatch("x{1234}XYZ"), 4828); + assertNull(res[1524].firstMatch("Ax{1234}XYZ"), 4829); + assertNull(res[1524].firstMatch("XYZ"), 4830); + assertNull(res[1525].firstMatch("XYZ"), 4831); + assertNull(res[1525].firstMatch("AXYZ"), 4832); + assertNull(res[1525].firstMatch("x{1234}XYZ"), 4833); + assertNull(res[1525].firstMatch("Ax{1234}XYZ"), 4834); + assertNull(res[1525].firstMatch("** Failers"), 4835); + assertNull(res[1526].firstMatch("XYZ"), 4836); + assertNull(res[1526].firstMatch("** Failers"), 4837); + assertNull(res[1526].firstMatch("AXYZ"), 4838); + assertNull(res[1526].firstMatch("x{1234}XYZ"), 4839); + assertNull(res[1526].firstMatch("Ax{1234}XYZ"), 4840); + assertToStringEquals("AX", res[1527].firstMatch("AXYZ"), 4841); + assertNull(res[1527].firstMatch("x{1234}XYZ "), 4842); + assertNull(res[1527].firstMatch("** Failers"), 4843); + assertNull(res[1527].firstMatch("X "), 4844); + assertNull(res[1528].firstMatch("** Failers"), 4845); + assertToStringEquals("AX", res[1528].firstMatch("AX"), 4846); + assertToStringEquals("X", res[1529].firstMatch("XYZ"), 4847); + assertToStringEquals("AX", res[1529].firstMatch("AXYZ"), 4848); + assertNull(res[1529].firstMatch("x{1234}XYZ "), 4849); + assertNull(res[1529].firstMatch("** Failers"), 4850); + assertNull(res[1529].firstMatch("ABXYZ "), 4851); + assertToStringEquals("X", res[1530].firstMatch("XYZ"), 4852); + assertNull(res[1530].firstMatch("** Failers"), 4853); + assertToStringEquals("AX", res[1530].firstMatch("AXYZ"), 4854); + assertNull(res[1530].firstMatch("x{1234}XYZ "), 4855); + assertNull(res[1530].firstMatch("ABXYZ "), 4856); + assertToStringEquals("AX", res[1531].firstMatch("AXYZ"), 4857); + assertNull(res[1531].firstMatch("x{1234}XYZ"), 4858); + assertNull(res[1531].firstMatch("Ax{1234}XYZ"), 4859); + assertNull(res[1531].firstMatch("** Failers"), 4860); + assertNull(res[1531].firstMatch("XYZ"), 4861); + assertNull(res[1532].firstMatch("** Failers"), 4862); + assertToStringEquals("AX", res[1532].firstMatch("AXYZ"), 4863); + assertNull(res[1532].firstMatch("x{1234}XYZ"), 4864); + assertNull(res[1532].firstMatch("Ax{1234}XYZ"), 4865); + assertNull(res[1532].firstMatch("XYZ"), 4866); + assertToStringEquals("X", res[1533].firstMatch("XYZ"), 4867); + assertToStringEquals("AX", res[1533].firstMatch("AXYZ"), 4868); + assertNull(res[1533].firstMatch("x{1234}XYZ"), 4869); + assertNull(res[1533].firstMatch("Ax{1234}XYZ"), 4870); + assertNull(res[1533].firstMatch("** Failers"), 4871); + assertToStringEquals("X", res[1534].firstMatch("XYZ"), 4872); + assertNull(res[1534].firstMatch("** Failers"), 4873); + assertToStringEquals("AX", res[1534].firstMatch("AXYZ"), 4874); + assertNull(res[1534].firstMatch("x{1234}XYZ"), 4875); + assertNull(res[1534].firstMatch("Ax{1234}XYZ"), 4876); + assertNull(res[1535].firstMatch("abcdefgh"), 4877); + assertNull(res[1535].firstMatch("x{1234}\n\x0dx{3456}xyz "), 4878); + assertNull(res[1536].firstMatch("abcdefgh"), 4879); + assertNull(res[1536].firstMatch("x{1234}\n\x0dx{3456}xyz "), 4880); + assertNull(res[1537].firstMatch("** Failers"), 4881); + assertNull(res[1537].firstMatch("abcdefgh"), 4882); + assertNull(res[1537].firstMatch("x{1234}\n\x0dx{3456}xyz "), 4883); + assertNull(res[1538].firstMatch(" AXY"), 4884); + assertNull(res[1538].firstMatch(" aXY"), 4885); + assertNull(res[1538].firstMatch(" x{1c5}XY"), 4886); + assertNull(res[1538].firstMatch(" ** Failers"), 4887); + assertNull(res[1538].firstMatch(" x{1bb}XY"), 4888); + assertNull(res[1538].firstMatch(" x{2b0}XY"), 4889); + assertNull(res[1538].firstMatch(" !XY "), 4890); + assertNull(res[1539].firstMatch(" AXY"), 4891); + assertNull(res[1539].firstMatch(" aXY"), 4892); + assertNull(res[1539].firstMatch(" x{1c5}XY"), 4893); + assertNull(res[1539].firstMatch(" ** Failers"), 4894); + assertNull(res[1539].firstMatch(" x{1bb}XY"), 4895); + assertNull(res[1539].firstMatch(" x{2b0}XY"), 4896); + assertNull(res[1539].firstMatch(" !XY "), 4897); + assertNull(res[1539].firstMatch(" AXY"), 4898); + assertNull(res[1539].firstMatch(" aXY"), 4899); + assertNull(res[1539].firstMatch(" AbcdeXyz "), 4900); + assertNull(res[1539].firstMatch(" x{1c5}AbXY"), 4901); + assertNull(res[1539].firstMatch(" abcDEXypqreXlmn "), 4902); + assertNull(res[1539].firstMatch(" ** Failers"), 4903); + assertNull(res[1539].firstMatch(" x{1bb}XY"), 4904); + assertNull(res[1539].firstMatch(" x{2b0}XY"), 4905); + assertNull(res[1539].firstMatch(" !XY "), 4906); + assertNull(res[1540].firstMatch(" AXY"), 4907); + assertNull(res[1540].firstMatch(" aXY"), 4908); + assertNull(res[1540].firstMatch(" AbcdeXyz "), 4909); + assertNull(res[1540].firstMatch(" x{1c5}AbXY"), 4910); + assertNull(res[1540].firstMatch(" abcDEXypqreXlmn "), 4911); + assertNull(res[1540].firstMatch(" ** Failers"), 4912); + assertNull(res[1540].firstMatch(" x{1bb}XY"), 4913); + assertNull(res[1540].firstMatch(" x{2b0}XY"), 4914); + assertNull(res[1540].firstMatch(" !XY "), 4915); + assertNull(res[1540].firstMatch(" AXY"), 4916); + assertNull(res[1540].firstMatch(" aXY"), 4917); + assertNull(res[1540].firstMatch(" AbcdeXyz "), 4918); + assertNull(res[1540].firstMatch(" x{1c5}AbXY"), 4919); + assertNull(res[1540].firstMatch(" abcDEXypqreXlmn "), 4920); + assertNull(res[1540].firstMatch(" ** Failers"), 4921); + assertNull(res[1540].firstMatch(" x{1bb}XY"), 4922); + assertNull(res[1540].firstMatch(" x{2b0}XY"), 4923); + assertNull(res[1540].firstMatch(" !XY "), 4924); + assertNull(res[1541].firstMatch(" AXY"), 4925); + assertNull(res[1541].firstMatch(" aXY"), 4926); + assertNull(res[1541].firstMatch(" AbcdeXyz "), 4927); + assertNull(res[1541].firstMatch(" x{1c5}AbXY"), 4928); + assertNull(res[1541].firstMatch(" abcDEXypqreXlmn "), 4929); + assertNull(res[1541].firstMatch(" ** Failers"), 4930); + assertNull(res[1541].firstMatch(" x{1bb}XY"), 4931); + assertNull(res[1541].firstMatch(" x{2b0}XY"), 4932); + assertNull(res[1541].firstMatch(" !XY "), 4933); + assertNull(res[1542].firstMatch(" !XY"), 4934); + assertNull(res[1542].firstMatch(" x{1bb}XY"), 4935); + assertNull(res[1542].firstMatch(" x{2b0}XY"), 4936); + assertNull(res[1542].firstMatch(" ** Failers"), 4937); + assertNull(res[1542].firstMatch(" x{1c5}XY"), 4938); + assertNull(res[1542].firstMatch(" AXY "), 4939); + assertNull(res[1543].firstMatch(" !XY"), 4940); + assertNull(res[1543].firstMatch(" x{1bb}XY"), 4941); + assertNull(res[1543].firstMatch(" x{2b0}XY"), 4942); + assertNull(res[1543].firstMatch(" ** Failers"), 4943); + assertNull(res[1543].firstMatch(" x{1c5}XY"), 4944); + assertNull(res[1543].firstMatch(" AXY "), 4945); + assertNull(res[1543].firstMatch("x{c0}x{e0}x{116}x{117}"), 4946); + assertNull(res[1543].firstMatch("x{c0}x{e0}x{116}x{117}"), 4947); + assertNull(res[1545].firstMatch("123abcdefg"), 4948); + assertNull(res[1545].firstMatch("123abc\xc4\xc5zz"), 4949); + assertNull( + res[1546].firstMatch( + "x{102A4}x{AA52}x{A91D}x{1C46}x{10283}x{1092E}x{1C6B}x{A93B}x{A8BF}x{1BA0}x{A50A}===="), + 4950); + assertNull(res[1546].firstMatch("x{a77d}x{1d79}"), 4951); + assertNull(res[1546].firstMatch("x{1d79}x{a77d} "), 4952); + assertNull(res[1546].firstMatch("x{a77d}x{1d79}"), 4953); + assertNull(res[1546].firstMatch("** Failers "), 4954); + assertNull(res[1546].firstMatch("x{1d79}x{a77d} "), 4955); + // Dart does not have RegExp literals and thus no translatation of the below. + // assertThrows("var re = //;", 4956); +} diff --git a/tests/corelib/regexp/quantified-assertions_test.dart b/tests/corelib/regexp/quantified-assertions_test.dart new file mode 100644 index 00000000000..43269fdd528 --- /dev/null +++ b/tests/corelib/regexp/quantified-assertions_test.dart @@ -0,0 +1,46 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + description("This page tests assertions followed by quantifiers."); + + var regexp; + + regexp = new RegExp(r"(?=a){0}", multiLine: true); + shouldBeTrue(regexp.hasMatch('a')); + + regexp = new RegExp(r"(?=a){1}", multiLine: true); + shouldBeTrue(regexp.hasMatch('a')); + + regexp = new RegExp(r"(?!a){0}", multiLine: true); + shouldBeTrue(regexp.hasMatch('b')); + + regexp = new RegExp(r"(?!a){1}", multiLine: true); + shouldBeTrue(regexp.hasMatch('b')); + + shouldBeTrue(new RegExp(r"^(?=a)?b$").hasMatch("b")); +} diff --git a/tests/corelib/regexp/range-bound-ffff_test.dart b/tests/corelib/regexp/range-bound-ffff_test.dart new file mode 100644 index 00000000000..c9d8c62d49b --- /dev/null +++ b/tests/corelib/regexp/range-bound-ffff_test.dart @@ -0,0 +1,35 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + description( + 'Test for rdar:/68455379, a case-insensitive regex containing a character class containing a range with an upper bound of \uFFFF can lead to an infinite-loop.'); + + shouldBe( + firstMatch("A", new RegExp(r"[\u0001-\uFFFF]", caseSensitive: false)), + ["A"]); +} diff --git a/tests/corelib/regexp/range-out-of-order_test.dart b/tests/corelib/regexp/range-out-of-order_test.dart new file mode 100644 index 00000000000..3535bdbbe67 --- /dev/null +++ b/tests/corelib/regexp/range-out-of-order_test.dart @@ -0,0 +1,33 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + description( + 'Test for bug 16129: REGRESSION (r27761-r27811): malloc error while visiting http://mysit.es (crashes release build).'); + + assertThrows(() => new RegExp(r"^[\s{-.\[\]\(\)]$")); +} diff --git a/tests/corelib/regexp/ranges-and-escaped-hyphens_test.dart b/tests/corelib/regexp/ranges-and-escaped-hyphens_test.dart new file mode 100644 index 00000000000..7c03503a077 --- /dev/null +++ b/tests/corelib/regexp/ranges-and-escaped-hyphens_test.dart @@ -0,0 +1,81 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + description( + 'Tests for bug #21232, and related range issues described in bug.'); + + // Basic test for ranges - one to three and five are in regexp, four is not, and '-' should not match + var regexp01 = new RegExp(r"[1-35]+").firstMatch("-12354"); + shouldBe(regexp01, ["1235"]); + // Tests inserting an escape character class into the above pattern - where the spaces fall within the + // range it is no longer a range - hyphens should now match, two should not. + var regexp01a = new RegExp(r"[\s1-35]+").firstMatch("-123 54"); + shouldBe(regexp01a, ["123 5"]); + + // These are invalid ranges, according to ECMA-262, but we allow them. + var regexp01b = new RegExp(r"[1\s-35]+").firstMatch("21-3 54"); + shouldBe(regexp01b, ["1-3 5"]); + var regexp01c = new RegExp(r"[1-\s35]+").firstMatch("21-3 54"); + shouldBe(regexp01c, ["1-3 5"]); + + var regexp01d = new RegExp(r"[1-3\s5]+").firstMatch("-123 54"); + shouldBe(regexp01d, ["123 5"]); + var regexp01e = new RegExp(r"[1-35\s5]+").firstMatch("-123 54"); + shouldBe(regexp01e, ["123 5"]); + // hyphens are normal characters if a range is not fully specified. + var regexp01f = new RegExp(r"[-3]+").firstMatch("2-34"); + shouldBe(regexp01f, ["-3"]); + var regexp01g = new RegExp(r"[2-]+").firstMatch("12-3"); + shouldBe(regexp01g, ["2-"]); + + // Similar to the above tests, but where the hyphen is escaped this is never a range. + var regexp02 = new RegExp(r"[1\-35]+").firstMatch("21-354"); + shouldBe(regexp02, ["1-35"]); + // As above. + var regexp02a = new RegExp(r"[\s1\-35]+").firstMatch("21-3 54"); + shouldBe(regexp02a, ["1-3 5"]); + var regexp02b = new RegExp(r"[1\s\-35]+").firstMatch("21-3 54"); + shouldBe(regexp02b, ["1-3 5"]); + var regexp02c = new RegExp(r"[1\-\s35]+").firstMatch("21-3 54"); + shouldBe(regexp02c, ["1-3 5"]); + var regexp02d = new RegExp(r"[1\-3\s5]+").firstMatch("21-3 54"); + shouldBe(regexp02d, ["1-3 5"]); + var regexp02e = new RegExp(r"[1\-35\s5]+").firstMatch("21-3 54"); + shouldBe(regexp02e, ["1-3 5"]); + + // Test that an escaped hyphen can be used as a bound on a range. + var regexp03a = new RegExp(r"[\--0]+").firstMatch(",-.01"); + shouldBe(regexp03a, ["-.0"]); + var regexp03b = new RegExp(r"[+-\-]+").firstMatch("*+,-."); + shouldBe(regexp03b, ["+,-"]); + + // The actual bug reported. + var bug21232 = + (new RegExp(r"^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$")).hasMatch('@'); + shouldBeFalse(bug21232); +} diff --git a/tests/corelib/regexp/regexp_kde_test.dart b/tests/corelib/regexp/regexp_kde_test.dart new file mode 100644 index 00000000000..71d5b9c8eaa --- /dev/null +++ b/tests/corelib/regexp/regexp_kde_test.dart @@ -0,0 +1,118 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + description("KDE JS Test"); + + var ri = new RegExp(r"a", caseSensitive: false); + var rm = new RegExp(r"a", multiLine: true); + var rg = new RegExp(r"a"); + + shouldBe(new RegExp(r"(b)c").firstMatch('abcd'), ["bc", "b"]); + + shouldBe(firstMatch('abcdefghi', new RegExp(r"(abc)def(ghi)")), + ['abcdefghi', 'abc', 'ghi']); + shouldBe(new RegExp(r"(abc)def(ghi)").firstMatch('abcdefghi'), + ['abcdefghi', 'abc', 'ghi']); + + shouldBe(firstMatch('abcdefghi', new RegExp(r"(a(b(c(d(e)f)g)h)i)")), + ['abcdefghi', 'abcdefghi', 'bcdefgh', 'cdefg', 'def', 'e']); + + shouldBe( + firstMatch('(100px 200px 150px 15px)', + new RegExp(r"\((\d+)(px)* (\d+)(px)* (\d+)(px)* (\d+)(px)*\)")), + [ + '(100px 200px 150px 15px)', + '100', + 'px', + '200', + 'px', + '150', + 'px', + '15', + 'px' + ]); + shouldBeNull(firstMatch( + '', new RegExp(r"\((\d+)(px)* (\d+)(px)* (\d+)(px)* (\d+)(px)*\)"))); + + var invalidChars = new RegExp(r"[^@\.\w]"); // #47092 + shouldBeTrue(firstMatch('faure@kde.org', invalidChars) == null); + shouldBeFalse(firstMatch('faure-kde@kde.org', invalidChars) == null); + + assertEquals('test1test2'.replaceAll('test', 'X'), 'X1X2'); + assertEquals('test1test2'.replaceAll(new RegExp(r"\d"), 'X'), 'testXtestX'); + assertEquals('1test2test3'.replaceAll(new RegExp(r"\d"), ''), 'testtest'); + assertEquals('test1test2'.replaceAll(new RegExp(r"test"), 'X'), 'X1X2'); + assertEquals('1test2test3'.replaceAll(new RegExp(r"\d"), ''), 'testtest'); + assertEquals('1test2test3'.replaceAll(new RegExp(r"x"), ''), '1test2test3'); + assertEquals( + 'test1test2'.replaceAllMapped( + new RegExp(r"(te)(st)"), (m) => "${m.group(2)}${m.group(1)}"), + 'stte1stte2'); + assertEquals('foo+bar'.replaceAll(new RegExp(r"\+"), '%2B'), 'foo%2Bbar'); + var caught = false; + try { + new RegExp("+"); + } catch (e) { + caught = true; + } + shouldBeTrue(caught); // #40435 + assertEquals('foo'.replaceAll(new RegExp(r"z?"), 'x'), 'xfxoxox'); + assertEquals( + 'test test'.replaceAll(new RegExp(r"\s*"), ''), 'testtest'); // #50985 + assertEquals( + 'abc\$%@'.replaceAll(new RegExp(r"[^0-9a-z]*", caseSensitive: false), ''), + 'abc'); // #50848 + assertEquals( + 'ab'.replaceAll(new RegExp(r"[^\d\.]*", caseSensitive: false), ''), + ''); // #75292 + assertEquals( + '1ab'.replaceAll(new RegExp(r"[^\d\.]*", caseSensitive: false), ''), + '1'); // #75292 + + Expect.listEquals( + '1test2test3blah'.split(new RegExp(r"test")), ['1', '2', '3blah']); + var reg = new RegExp(r"(\d\d )"); + var str = '98 76 blah'; + shouldBe(reg.firstMatch(str), ['98 ', '98 ']); + + str = "For more information, see Chapter 3.4.5.1"; + var re = new RegExp(r"(chapter \d+(\.\d)*)", caseSensitive: false); + // This returns the array containing Chapter 3.4.5.1,Chapter 3.4.5.1,.1 + // 'Chapter 3.4.5.1' is the first match and the first value remembered from (Chapter \d+(\.\d)*). + // '.1' is the second value remembered from (\.\d) + shouldBe(firstMatch(str, re), ['Chapter 3.4.5.1', 'Chapter 3.4.5.1', '.1']); + + str = "abcDdcba"; + // The returned array contains D, d. + re = new RegExp(r"d", caseSensitive: false); + var matches = re.allMatches(str); + Expect.listEquals(matches.map((m) => m.group(0)).toList(), ['D', 'd']); + + // unicode escape sequence + shouldBe(firstMatch('abc', new RegExp(r"\u0062")), ['b']); +} diff --git a/tests/corelib/regexp/regexp_test.dart b/tests/corelib/regexp/regexp_test.dart new file mode 100644 index 00000000000..aeea9c5c454 --- /dev/null +++ b/tests/corelib/regexp/regexp_test.dart @@ -0,0 +1,622 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2012 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import "package:expect/expect.dart"; + +void testEscape(str, regex) { + assertEquals("foo:bar:baz", str.split(regex).join(":")); +} + +void assertEquals(actual, expected, [message]) => + Expect.equals(actual, expected, message); +void assertTrue(actual, [message]) => Expect.isTrue(actual, message); +void assertFalse(actual, [message]) => Expect.isFalse(actual, message); +void assertThrows(fn) => Expect.throws(fn); + +void main() { + testEscape("foo\nbar\nbaz", new RegExp(r"\n")); + testEscape("foo bar baz", new RegExp(r"\s")); + testEscape("foo\tbar\tbaz", new RegExp(r"\s")); + testEscape("foo-bar-baz", new RegExp(r"\u002D")); + + // Test containing null char in regexp. + var s = '[' + new String.fromCharCode(0) + ']'; + var re = new RegExp(s); + assertEquals(re.allMatches(s).length, 1); + assertEquals(re.stringMatch(s), new String.fromCharCode(0)); + + final _vmFrame = new RegExp(r'^#\d+\s+(\S.*) \((.+?):(\d+)(?::(\d+))?\)$'); + final _traceLine = + "#0 Trace.Trace.parse (package:stack_trace/src/trace.dart:130:7)"; + Expect.equals(_vmFrame.firstMatch(_traceLine).group(0), _traceLine); + + // Test the UTF16 case insensitive comparison. + re = new RegExp(r"x(a)\1x", caseSensitive: false); + Expect.equals(re.firstMatch("xaAx\u1234").group(0), "xaAx"); + + // Test strings containing all line separators + s = 'aA\nbB\rcC\r\ndD\u2028eE\u2029fF'; + // any non-newline character at the beginning of a line + re = new RegExp(r"^.", multiLine: true); + var result = re.allMatches(s).toList(); + assertEquals(result.length, 6); + assertEquals(result[0][0], 'a'); + assertEquals(result[1][0], 'b'); + assertEquals(result[2][0], 'c'); + assertEquals(result[3][0], 'd'); + assertEquals(result[4][0], 'e'); + assertEquals(result[5][0], 'f'); + + // any non-newline character at the end of a line + re = new RegExp(r".$", multiLine: true); + result = re.allMatches(s).toList(); + assertEquals(result.length, 6); + assertEquals(result[0][0], 'A'); + assertEquals(result[1][0], 'B'); + assertEquals(result[2][0], 'C'); + assertEquals(result[3][0], 'D'); + assertEquals(result[4][0], 'E'); + assertEquals(result[5][0], 'F'); + + // *any* character at the beginning of a line + re = new RegExp(r"^[^]", multiLine: true); + result = re.allMatches(s).toList(); + assertEquals(result.length, 7); + assertEquals(result[0][0], 'a'); + assertEquals(result[1][0], 'b'); + assertEquals(result[2][0], 'c'); + assertEquals(result[3][0], '\n'); + assertEquals(result[4][0], 'd'); + assertEquals(result[5][0], 'e'); + assertEquals(result[6][0], 'f'); + + // *any* character at the end of a line + re = new RegExp(r"[^]$", multiLine: true); + result = re.allMatches(s).toList(); + assertEquals(result.length, 7); + assertEquals(result[0][0], 'A'); + assertEquals(result[1][0], 'B'); + assertEquals(result[2][0], 'C'); + assertEquals(result[3][0], '\r'); + assertEquals(result[4][0], 'D'); + assertEquals(result[5][0], 'E'); + assertEquals(result[6][0], 'F'); + + // Some tests from the Mozilla tests, where our behavior used to differ + // from SpiderMonkey. + // From ecma_3/RegExp/regress-334158.js + assertTrue("\x01".contains(new RegExp(r"\ca"))); + assertFalse("\\ca".contains(new RegExp(r"\ca"))); + assertFalse("ca".contains(new RegExp(r"\ca"))); + assertTrue("\\ca".contains(new RegExp(r"\c[a/]"))); + assertTrue("\\c/".contains(new RegExp(r"\c[a/]"))); + + // Test \c in character class + re = r"^[\cM]$"; + assertTrue("\r".contains(new RegExp(re))); + assertFalse("M".contains(new RegExp(re))); + assertFalse("c".contains(new RegExp(re))); + assertFalse("\\".contains(new RegExp(re))); + assertFalse("\x03".contains(new RegExp(re))); // I.e., read as \cc + + re = r"^[\c]]$"; + assertTrue("c]".contains(new RegExp(re))); + assertTrue("\\]".contains(new RegExp(re))); + assertFalse("\x1d".contains(new RegExp(re))); // ']' & 0x1f + assertFalse("\x03]".contains(new RegExp(re))); // I.e., read as \cc + + // Digit control characters are masked in character classes. + re = r"^[\c1]$"; + assertTrue("\x11".contains(new RegExp(re))); + assertFalse("\\".contains(new RegExp(re))); + assertFalse("c".contains(new RegExp(re))); + assertFalse("1".contains(new RegExp(re))); + + // Underscore control character is masked in character classes. + re = r"^[\c_]$"; + assertTrue("\x1f".contains(new RegExp(re))); + assertFalse("\\".contains(new RegExp(re))); + assertFalse("c".contains(new RegExp(re))); + assertFalse("_".contains(new RegExp(re))); + + re = r"^[\c$]$"; // Other characters are interpreted literally. + assertFalse("\x04".contains(new RegExp(re))); + assertTrue("\\".contains(new RegExp(re))); + assertTrue("c".contains(new RegExp(re))); + assertTrue(r"$".contains(new RegExp(re))); + + assertTrue("Z[\\cde".contains(new RegExp(r"^[Z-\c-e]*$"))); + + // Test that we handle \s and \S correctly on special Unicode characters. + re = r"\s"; + assertTrue("\u2028".contains(new RegExp(re))); + assertTrue("\u2029".contains(new RegExp(re))); + assertTrue("\uFEFF".contains(new RegExp(re))); + + re = r"\S"; + assertFalse("\u2028".contains(new RegExp(re))); + assertFalse("\u2029".contains(new RegExp(re))); + assertFalse("\uFEFF".contains(new RegExp(re))); + + // Test that we handle \s and \S correctly inside some bizarre + // character classes. + re = r"[\s-:]"; + assertTrue('-'.contains(new RegExp(re))); + assertTrue(':'.contains(new RegExp(re))); + assertTrue(' '.contains(new RegExp(re))); + assertTrue('\t'.contains(new RegExp(re))); + assertTrue('\n'.contains(new RegExp(re))); + assertFalse('a'.contains(new RegExp(re))); + assertFalse('Z'.contains(new RegExp(re))); + + re = r"[\S-:]"; + assertTrue('-'.contains(new RegExp(re))); + assertTrue(':'.contains(new RegExp(re))); + assertFalse(' '.contains(new RegExp(re))); + assertFalse('\t'.contains(new RegExp(re))); + assertFalse('\n'.contains(new RegExp(re))); + assertTrue('a'.contains(new RegExp(re))); + assertTrue('Z'.contains(new RegExp(re))); + + re = r"[^\s-:]"; + assertFalse('-'.contains(new RegExp(re))); + assertFalse(':'.contains(new RegExp(re))); + assertFalse(' '.contains(new RegExp(re))); + assertFalse('\t'.contains(new RegExp(re))); + assertFalse('\n'.contains(new RegExp(re))); + assertTrue('a'.contains(new RegExp(re))); + assertTrue('Z'.contains(new RegExp(re))); + + re = r"[^\S-:]"; + assertFalse('-'.contains(new RegExp(re))); + assertFalse(':'.contains(new RegExp(re))); + assertTrue(' '.contains(new RegExp(re))); + assertTrue('\t'.contains(new RegExp(re))); + assertTrue('\n'.contains(new RegExp(re))); + assertFalse('a'.contains(new RegExp(re))); + assertFalse('Z'.contains(new RegExp(re))); + + re = r"[\s]"; + assertFalse('-'.contains(new RegExp(re))); + assertFalse(':'.contains(new RegExp(re))); + assertTrue(' '.contains(new RegExp(re))); + assertTrue('\t'.contains(new RegExp(re))); + assertTrue('\n'.contains(new RegExp(re))); + assertFalse('a'.contains(new RegExp(re))); + assertFalse('Z'.contains(new RegExp(re))); + + re = r"[^\s]"; + assertTrue('-'.contains(new RegExp(re))); + assertTrue(':'.contains(new RegExp(re))); + assertFalse(' '.contains(new RegExp(re))); + assertFalse('\t'.contains(new RegExp(re))); + assertFalse('\n'.contains(new RegExp(re))); + assertTrue('a'.contains(new RegExp(re))); + assertTrue('Z'.contains(new RegExp(re))); + + re = r"[\S]"; + assertTrue('-'.contains(new RegExp(re))); + assertTrue(':'.contains(new RegExp(re))); + assertFalse(' '.contains(new RegExp(re))); + assertFalse('\t'.contains(new RegExp(re))); + assertFalse('\n'.contains(new RegExp(re))); + assertTrue('a'.contains(new RegExp(re))); + assertTrue('Z'.contains(new RegExp(re))); + + re = r"[^\S]"; + assertFalse('-'.contains(new RegExp(re))); + assertFalse(':'.contains(new RegExp(re))); + assertTrue(' '.contains(new RegExp(re))); + assertTrue('\t'.contains(new RegExp(re))); + assertTrue('\n'.contains(new RegExp(re))); + assertFalse('a'.contains(new RegExp(re))); + assertFalse('Z'.contains(new RegExp(re))); + + re = r"[\s\S]"; + assertTrue('-'.contains(new RegExp(re))); + assertTrue(':'.contains(new RegExp(re))); + assertTrue(' '.contains(new RegExp(re))); + assertTrue('\t'.contains(new RegExp(re))); + assertTrue('\n'.contains(new RegExp(re))); + assertTrue('a'.contains(new RegExp(re))); + assertTrue('Z'.contains(new RegExp(re))); + + re = r"[^\s\S]"; + assertFalse('-'.contains(new RegExp(re))); + assertFalse(':'.contains(new RegExp(re))); + assertFalse(' '.contains(new RegExp(re))); + assertFalse('\t'.contains(new RegExp(re))); + assertFalse('\n'.contains(new RegExp(re))); + assertFalse('a'.contains(new RegExp(re))); + assertFalse('Z'.contains(new RegExp(re))); + + // First - is treated as range operator, second as literal minus. + // This follows the specification in parsing, but doesn't throw on + // the \s at the beginning of the range. + re = r"[\s-0-9]"; + assertTrue(' '.contains(new RegExp(re))); + assertTrue('\xA0'.contains(new RegExp(re))); + assertTrue('-'.contains(new RegExp(re))); + assertTrue('0'.contains(new RegExp(re))); + assertTrue('9'.contains(new RegExp(re))); + assertFalse('1'.contains(new RegExp(re))); + + // Test beginning and end of line assertions with or without the + // multiline flag. + re = r"^\d+"; + assertFalse("asdf\n123".contains(new RegExp(re))); + re = new RegExp(r"^\d+", multiLine: true); + assertTrue("asdf\n123".contains(re)); + + re = r"\d+$"; + assertFalse("123\nasdf".contains(new RegExp(re))); + re = new RegExp(r"\d+$", multiLine: true); + assertTrue("123\nasdf".contains(re)); + + // Test that empty matches are handled correctly for multiline global + // regexps. + re = new RegExp(r"^(.*)", multiLine: true); + assertEquals(3, re.allMatches("a\n\rb").length); + assertEquals("*a\n*b\r*c\n*\r*d\r*\n*e", + "a\nb\rc\n\rd\r\ne".replaceAllMapped(re, (Match m) => "*${m.group(1)}")); + + // Test that empty matches advance one character + re = new RegExp(""); + assertEquals("xAx", "A".replaceAll(re, "x")); + assertEquals(3, new String.fromCharCode(161).replaceAll(re, "x").length); + + // Check for lazy RegExp literal creation + lazyLiteral(doit) { + if (doit) + return "".replaceAll(new RegExp(r"foo(", caseSensitive: false), ""); + return true; + } + + assertTrue(lazyLiteral(false)); + assertThrows(() => lazyLiteral(true)); + + // Check $01 and $10 + re = new RegExp("(.)(.)(.)(.)(.)(.)(.)(.)(.)(.)"); + assertEquals( + "t", "123456789t".replaceAllMapped(re, (Match m) => m.group(10))); + assertEquals( + "15", "123456789t".replaceAllMapped(re, (Match m) => "${m.group(1)}5")); + assertEquals("1", "123456789t".replaceAllMapped(re, (Match m) => m.group(1))); + + assertFalse("football".contains(new RegExp(r"()foo$\1")), "football1"); + assertFalse("football".contains(new RegExp(r"foo$(?=ball)")), "football2"); + assertFalse("football".contains(new RegExp(r"foo$(?!bar)")), "football3"); + assertTrue("foo".contains(new RegExp(r"()foo$\1")), "football4"); + assertTrue("foo".contains(new RegExp(r"foo$(?=(ball)?)")), "football5"); + assertTrue("foo".contains(new RegExp(r"()foo$(?!bar)")), "football6"); + assertFalse("football".contains(new RegExp(r"(x?)foo$\1")), "football7"); + assertFalse("football".contains(new RegExp(r"foo$(?=ball)")), "football8"); + assertFalse("football".contains(new RegExp(r"foo$(?!bar)")), "football9"); + assertTrue("foo".contains(new RegExp(r"(x?)foo$\1")), "football10"); + assertTrue("foo".contains(new RegExp(r"foo$(?=(ball)?)")), "football11"); + assertTrue("foo".contains(new RegExp(r"foo$(?!bar)")), "football12"); + + // Check that the back reference has two successors. See + // BackReferenceNode::PropagateForward. + assertFalse('foo'.contains(new RegExp(r"f(o)\b\1"))); + assertTrue('foo'.contains(new RegExp(r"f(o)\B\1"))); + + // Back-reference, ignore case: + // ASCII + assertEquals( + "a", + new RegExp(r"x(a)\1x", caseSensitive: false).firstMatch("xaAx").group(1), + "backref-ASCII"); + assertFalse("xaaaaa".contains(new RegExp(r"x(...)\1", caseSensitive: false)), + "backref-ASCII-short"); + assertTrue("xx".contains(new RegExp(r"x((?:))\1\1x", caseSensitive: false)), + "backref-ASCII-empty"); + assertTrue( + "xabcx".contains(new RegExp(r"x(?:...|(...))\1x", caseSensitive: false)), + "backref-ASCII-uncaptured"); + assertTrue( + "xabcABCx" + .contains(new RegExp(r"x(?:...|(...))\1x", caseSensitive: false)), + "backref-ASCII-backtrack"); + assertEquals( + "aBc", + new RegExp(r"x(...)\1\1x", caseSensitive: false) + .firstMatch("xaBcAbCABCx") + .group(1), + "backref-ASCII-twice"); + + for (var i = 0; i < 128; i++) { + var testName = "backref-ASCII-char-$i,,${i^0x20}"; + var test = new String.fromCharCodes([i, i ^ 0x20]) + .contains(new RegExp(r"^(.)\1$", caseSensitive: false)); + if (('A'.codeUnitAt(0) <= i && i <= 'Z'.codeUnitAt(0)) || + ('a'.codeUnitAt(0) <= i && i <= 'z'.codeUnitAt(0))) { + assertTrue(test, testName); + } else { + assertFalse(test, testName); + } + } + + assertFalse('foo'.contains(new RegExp(r"f(o)$\1")), "backref detects at_end"); + + // Check decimal escapes doesn't overflow. + // (Note: \214 is interpreted as octal). + assertEquals( + "\x8c7483648", + new RegExp(r"\2147483648").firstMatch("\x8c7483648").group(0), + "Overflow decimal escape"); + + // Check numbers in quantifiers doesn't overflow and doesn't throw on + // too large numbers. + assertFalse( + 'b'.contains( + new RegExp(r"a{111111111111111111111111111111111111111111111}")), + "overlarge1"); + assertFalse( + 'b'.contains( + new RegExp(r"a{999999999999999999999999999999999999999999999}")), + "overlarge2"); + assertFalse( + 'b'.contains( + new RegExp(r"a{1,111111111111111111111111111111111111111111111}")), + "overlarge3"); + assertFalse( + 'b'.contains( + new RegExp(r"a{1,999999999999999999999999999999999999999999999}")), + "overlarge4"); + assertFalse('b'.contains(new RegExp(r"a{2147483648}")), "overlarge5"); + assertFalse('b'.contains(new RegExp(r"a{21474836471}")), "overlarge6"); + assertFalse('b'.contains(new RegExp(r"a{1,2147483648}")), "overlarge7"); + assertFalse('b'.contains(new RegExp(r"a{1,21474836471}")), "overlarge8"); + assertFalse( + 'b'.contains(new RegExp(r"a{2147483648,2147483648}")), "overlarge9"); + assertFalse( + 'b'.contains(new RegExp(r"a{21474836471,21474836471}")), "overlarge10"); + assertFalse('b'.contains(new RegExp(r"a{2147483647}")), "overlarge11"); + assertFalse('b'.contains(new RegExp(r"a{1,2147483647}")), "overlarge12"); + assertTrue('a'.contains(new RegExp(r"a{1,2147483647}")), "overlarge13"); + assertFalse( + 'a'.contains(new RegExp(r"a{2147483647,2147483647}")), "overlarge14"); + + // Check that we don't read past the end of the string. + assertFalse('b'.contains(new RegExp(r"f"))); + assertFalse('x'.contains(new RegExp(r"[abc]f"))); + assertFalse('xa'.contains(new RegExp(r"[abc]f"))); + assertFalse('x'.contains(new RegExp(r"[abc]<"))); + assertFalse('xa'.contains(new RegExp(r"[abc]<"))); + assertFalse('b'.contains(new RegExp(r"f", caseSensitive: false))); + assertFalse('x'.contains(new RegExp(r"[abc]f", caseSensitive: false))); + assertFalse('xa'.contains(new RegExp(r"[abc]f", caseSensitive: false))); + assertFalse('x'.contains(new RegExp(r"[abc]<", caseSensitive: false))); + assertFalse('xa'.contains(new RegExp(r"[abc]<", caseSensitive: false))); + assertFalse('x'.contains(new RegExp(r"f[abc]"))); + assertFalse('xa'.contains(new RegExp(r"f[abc]"))); + assertFalse('x'.contains(new RegExp(r"<[abc]"))); + assertFalse('xa'.contains(new RegExp(r"<[abc]"))); + assertFalse('x'.contains(new RegExp(r"f[abc]", caseSensitive: false))); + assertFalse('xa'.contains(new RegExp(r"f[abc]", caseSensitive: false))); + assertFalse('x'.contains(new RegExp(r"<[abc]", caseSensitive: false))); + assertFalse('xa'.contains(new RegExp(r"<[abc]", caseSensitive: false))); + + // Test that merging of quick test masks gets it right. + assertFalse('x7%%y'.contains(new RegExp(r"x([0-7]%%x|[0-6]%%y)")), 'qt'); + assertFalse( + 'xy7%%%y' + .contains(new RegExp(r"()x\1(y([0-7]%%%x|[0-6]%%%y)|dkjasldkas)")), + 'qt2'); + assertFalse( + 'xy%%%y' + .contains(new RegExp(r"()x\1(y([0-7]%%%x|[0-6]%%%y)|dkjasldkas)")), + 'qt3'); + assertFalse( + 'xy7%%%y'.contains(new RegExp(r"()x\1y([0-7]%%%x|[0-6]%%%y)")), 'qt4'); + assertFalse( + 'xy%%%y' + .contains(new RegExp(r"()x\1(y([0-7]%%%x|[0-6]%%%y)|dkjasldkas)")), + 'qt5'); + assertFalse( + 'xy7%%%y'.contains(new RegExp(r"()x\1y([0-7]%%%x|[0-6]%%%y)")), 'qt6'); + assertFalse( + 'xy7%%%y'.contains(new RegExp(r"xy([0-7]%%%x|[0-6]%%%y)")), 'qt7'); + assertFalse('x7%%%y'.contains(new RegExp(r"x([0-7]%%%x|[0-6]%%%y)")), 'qt8'); + + // Don't hang on this one. + "".contains(new RegExp(r"[^\xfe-\xff]*")); + + var longbuffer = new StringBuffer("a"); + for (var i = 0; i < 100000; i++) { + longbuffer.write("a?"); + } + var long = longbuffer.toString(); + + // Don't crash on this one, but maybe throw an exception. + try { + new RegExp(long).allMatches("a"); + } catch (e) { + assertTrue(e.toString().indexOf("Stack overflow") >= 0, "overflow"); + } + + // Test boundary-checks. + void assertRegExpTest(re, input, test) { + assertEquals( + test, input.contains(new RegExp(re)), "test:" + re + ":" + input); + } + + assertRegExpTest(r"b\b", "b", true); + assertRegExpTest(r"b\b$", "b", true); + assertRegExpTest(r"\bb", "b", true); + assertRegExpTest(r"^\bb", "b", true); + assertRegExpTest(r",\b", ",", false); + assertRegExpTest(r",\b$", ",", false); + assertRegExpTest(r"\b,", ",", false); + assertRegExpTest(r"^\b,", ",", false); + + assertRegExpTest(r"b\B", "b", false); + assertRegExpTest(r"b\B$", "b", false); + assertRegExpTest(r"\Bb", "b", false); + assertRegExpTest(r"^\Bb", "b", false); + assertRegExpTest(r",\B", ",", true); + assertRegExpTest(r",\B$", ",", true); + assertRegExpTest(r"\B,", ",", true); + assertRegExpTest(r"^\B,", ",", true); + + assertRegExpTest(r"b\b", "b,", true); + assertRegExpTest(r"b\b", "ba", false); + assertRegExpTest(r"b\B", "b,", false); + assertRegExpTest(r"b\B", "ba", true); + + assertRegExpTest(r"b\Bb", "bb", true); + assertRegExpTest(r"b\bb", "bb", false); + + assertRegExpTest(r"b\b[,b]", "bb", false); + assertRegExpTest(r"b\B[,b]", "bb", true); + assertRegExpTest(r"b\b[,b]", "b,", true); + assertRegExpTest(r"b\B[,b]", "b,", false); + + assertRegExpTest(r"[,b]\bb", "bb", false); + assertRegExpTest(r"[,b]\Bb", "bb", true); + assertRegExpTest(r"[,b]\bb", ",b", true); + assertRegExpTest(r"[,b]\Bb", ",b", false); + + assertRegExpTest(r"[,b]\b[,b]", "bb", false); + assertRegExpTest(r"[,b]\B[,b]", "bb", true); + assertRegExpTest(r"[,b]\b[,b]", ",b", true); + assertRegExpTest(r"[,b]\B[,b]", ",b", false); + assertRegExpTest(r"[,b]\b[,b]", "b,", true); + assertRegExpTest(r"[,b]\B[,b]", "b,", false); + + // Skipped tests from V8: + + // Test that caching of result doesn't share result objects. + // More iterations increases the chance of hitting a GC. + + // Test that we perform the spec required conversions in the correct order. + + // Check that properties of RegExp have the correct permissions. + + // Check that end-anchored regexps are optimized correctly. + re = r"(?:a|bc)g$"; + assertTrue("ag".contains(new RegExp(re))); + assertTrue("bcg".contains(new RegExp(re))); + assertTrue("abcg".contains(new RegExp(re))); + assertTrue("zimbag".contains(new RegExp(re))); + assertTrue("zimbcg".contains(new RegExp(re))); + + assertFalse("g".contains(new RegExp(re))); + assertFalse("".contains(new RegExp(re))); + + // Global regexp (non-zero start). + re = r"(?:a|bc)g$"; + assertTrue("ag".contains(new RegExp(re))); + // Near start of string. + assertTrue(new RegExp(re).allMatches("zimbag", 1).isNotEmpty); + // At end of string. + assertTrue(new RegExp(re).allMatches("zimbag", 6).isEmpty); + // Near end of string. + assertTrue(new RegExp(re).allMatches("zimbag", 5).isEmpty); + assertTrue(new RegExp(re).allMatches("zimbag", 4).isNotEmpty); + + // Anchored at both ends. + re = r"^(?:a|bc)g$"; + assertTrue("ag".contains(new RegExp(re))); + assertTrue(new RegExp(re).allMatches("ag", 1).isEmpty); + assertTrue(new RegExp(re).allMatches("zag", 1).isEmpty); + + // Long max_length of RegExp. + re = r"VeryLongRegExp!{1,1000}$"; + assertTrue("BahoolaVeryLongRegExp!!!!!!".contains(new RegExp(re))); + assertFalse("VeryLongRegExp".contains(new RegExp(re))); + assertFalse("!".contains(new RegExp(re))); + + // End anchor inside disjunction. + re = r"(?:a$|bc$)"; + assertTrue("a".contains(new RegExp(re))); + assertTrue("bc".contains(new RegExp(re))); + assertTrue("abc".contains(new RegExp(re))); + assertTrue("zimzamzumba".contains(new RegExp(re))); + assertTrue("zimzamzumbc".contains(new RegExp(re))); + assertFalse("c".contains(new RegExp(re))); + assertFalse("".contains(new RegExp(re))); + + // Only partially anchored. + re = r"(?:a|bc$)"; + assertTrue("a".contains(new RegExp(re))); + assertTrue("bc".contains(new RegExp(re))); + assertEquals("a", new RegExp(re).firstMatch("abc").group(0)); + assertEquals(4, new RegExp(re).firstMatch("zimzamzumba").start); + assertEquals("bc", new RegExp(re).firstMatch("zimzomzumbc").group(0)); + assertFalse("c".contains(new RegExp(re))); + assertFalse("".contains(new RegExp(re))); + + // Valid syntax in ES5. + re = new RegExp("(?:x)*"); + re = new RegExp("(x)*"); + + // Syntax extension relative to ES5, for matching JSC (and ES3). + // Shouldn't throw. + re = new RegExp("(?=x)*"); + re = new RegExp("(?!x)*"); + + // Should throw. Shouldn't hit asserts in debug mode. + assertThrows(() => new RegExp('(*)')); + assertThrows(() => new RegExp('(?:*)')); + assertThrows(() => new RegExp('(?=*)')); + assertThrows(() => new RegExp('(?!*)')); + + // Test trimmed regular expression for RegExp.test(). + assertTrue("abc".contains(new RegExp(r".*abc"))); + assertFalse("q".contains(new RegExp(r".*\d+"))); + + // Tests skipped from V8: + // Test that RegExp.prototype.toString() throws TypeError for + // incompatible receivers (ES5 section 15.10.6 and 15.10.6.4). + + testSticky(); +} + +testSticky() { + var re = new RegExp(r"foo.bar"); + Expect.isNotNull(re.matchAsPrefix("foo_bar", 0)); + Expect.isNull(re.matchAsPrefix("..foo_bar", 0)); + Expect.isNotNull(re.matchAsPrefix("..foo_bar", 2)); + + re = new RegExp(r"^foo"); + Expect.isNotNull(re.matchAsPrefix("foobar", 0)); + Expect.isNull(re.matchAsPrefix("..foo", 0)); + Expect.isNull(re.matchAsPrefix("..foo", 2)); + + re = new RegExp(r"^foo", multiLine: true); + Expect.isNotNull(re.matchAsPrefix("foobar", 0)); + Expect.isNull(re.matchAsPrefix("..\nfoo", 0)); + Expect.isNotNull(re.matchAsPrefix("..\nfoo", 3)); + Expect.isNull(re.matchAsPrefix("..\nfoofoo", 6)); + + re = new RegExp(r"bar$"); + Expect.isNull(re.matchAsPrefix("foobar", 0)); + Expect.isNotNull(re.matchAsPrefix("foobar", 3)); +} diff --git a/tests/corelib/regexp/regress-6-9-regexp_test.dart b/tests/corelib/regexp/regress-6-9-regexp_test.dart new file mode 100644 index 00000000000..3fbef870137 --- /dev/null +++ b/tests/corelib/regexp/regress-6-9-regexp_test.dart @@ -0,0 +1,36 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2009 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + // Check that the perfect mask check isn't overly optimistic. + + assertFalse(new RegExp(r"[6-9]").hasMatch('2')); +} diff --git a/tests/corelib/regexp/regress-regexp-codeflush_test.dart b/tests/corelib/regexp/regress-regexp-codeflush_test.dart new file mode 100644 index 00000000000..03b0804e1dd --- /dev/null +++ b/tests/corelib/regexp/regress-regexp-codeflush_test.dart @@ -0,0 +1,61 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + // Flags: --gc_global + + // Regression test for regexp that has multiple matches and which + // internally calls RegExpImpl::IrregexpExecOnce more than once without + // ensuring that the regexp is compiled. + // This can create a crash if the code was exchanged with the sweep + // generation (for code flushing support) in GC during the matching. + + var re = new RegExp('(s)'); + + dynamic foo(Match m) { + return "42"; + } + + // Run enough times to get a number of GC's (all mark sweep because of the + // --gc_global) flag. + for (var i = 0; i < 10; i++) { + // Make a long string with plenty of matches for re. + var x = "s foo s bar s foo s bar s"; + x = x + x; + x = x + x; + x = x + x; + x = x + x; + x = x + x; + x = x + x; + x = x + x; + x.replaceAllMapped(re, foo); + } +} diff --git a/tests/corelib/regexp/regress-regexp-construct-result_test.dart b/tests/corelib/regexp/regress-regexp-construct-result_test.dart new file mode 100644 index 00000000000..ac9c032073b --- /dev/null +++ b/tests/corelib/regexp/regress-regexp-construct-result_test.dart @@ -0,0 +1,50 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + // Create a huge regexp with many alternative capture groups, most of + // which do not capture anything, but the corresponding capture slot + // in the result object has to exist, even though filled with null. + // Having a large result array helps stressing GC. + + var num_captures = 1000; + var regexp_string = "(a)"; + for (var i = 0; i < num_captures - 1; i++) { + regexp_string += "|(b)"; + } + var regexp = new RegExp(regexp_string); + + for (var i = 0; i < 10; i++) { + var matches = regexp.firstMatch("a"); + var count = 0; + assertEquals(num_captures + 1, matches.groupCount + 1); + } +} diff --git a/tests/corelib/regexp/repeat-match-waldemar_test.dart b/tests/corelib/regexp/repeat-match-waldemar_test.dart new file mode 100644 index 00000000000..3adc775f4b7 --- /dev/null +++ b/tests/corelib/regexp/repeat-match-waldemar_test.dart @@ -0,0 +1,59 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + // "Some test cases identified by Waldemar Horwat in response to this bug: + // https:new RegExp(r"/bugs.webkit.org")show_bug.cgi?id=48101" + + shouldBe(new RegExp(r"(?:a*?){2,}").firstMatch("aa"), ["aa"]); + shouldBe(new RegExp(r"(?:a*?){2,}").firstMatch("a"), ["a"]); + shouldBe(new RegExp(r"(?:a*?){2,}").firstMatch(""), [""]); + + shouldBe(new RegExp(r"(?:a*?)").firstMatch("aa"), [""]); + shouldBe(new RegExp(r"(?:a*?)").firstMatch("a"), [""]); + shouldBe(new RegExp(r"(?:a*?)").firstMatch(""), [""]); + + shouldBe(new RegExp(r"(?:a*?)(?:a*?)(?:a*?)").firstMatch("aa"), [""]); + shouldBe(new RegExp(r"(?:a*?)(?:a*?)(?:a*?)").firstMatch("a"), [""]); + shouldBe(new RegExp(r"(?:a*?)(?:a*?)(?:a*?)").firstMatch(""), [""]); + + shouldBe(new RegExp(r"(?:a*?){2}").firstMatch("aa"), [""]); + shouldBe(new RegExp(r"(?:a*?){2}").firstMatch("a"), [""]); + shouldBe(new RegExp(r"(?:a*?){2}").firstMatch(""), [""]); + + shouldBe(new RegExp(r"(?:a*?){2,3}").firstMatch("aa"), ["a"]); + shouldBe(new RegExp(r"(?:a*?){2,3}").firstMatch("a"), ["a"]); + shouldBe(new RegExp(r"(?:a*?){2,3}").firstMatch(""), [""]); + + shouldBe(new RegExp(r"(?:a*?)?").firstMatch("aa"), ["a"]); + shouldBe(new RegExp(r"(?:a*?)?").firstMatch("a"), ["a"]); + shouldBe(new RegExp(r"(?:a*?)?").firstMatch(""), [""]); + + shouldBe(new RegExp(r"(?:a*?)*").firstMatch("aa"), ["aa"]); + shouldBe(new RegExp(r"(?:a*?)*").firstMatch("a"), ["a"]); + shouldBe(new RegExp(r"(?:a*?)*").firstMatch(""), [""]); +} diff --git a/tests/corelib/regexp/results-cache_test.dart b/tests/corelib/regexp/results-cache_test.dart new file mode 100644 index 00000000000..0ef0f40a19b --- /dev/null +++ b/tests/corelib/regexp/results-cache_test.dart @@ -0,0 +1,81 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2012 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + // Long string to trigger caching. + var string = """Friends, Romans, countrymen, lend me your ears! + I come to bury Caesar, not to praise him. + The evil that men do lives after them, + The good is oft interred with their bones; + So let it be with Caesar. The noble Brutus + Hath told you Caesar was ambitious; + If it were so, it was a grievous fault, + And grievously hath Caesar answer'd it. + Here, under leave of Brutus and the rest- + For Brutus is an honorable man; + So are they all, all honorable men- + Come I to speak in Caesar's funeral. + He was my friend, faithful and just to me; + But Brutus says he was ambitious, + And Brutus is an honorable man. + He hath brought many captives home to Rome, + Whose ransoms did the general coffers fill. + Did this in Caesar seem ambitious? + When that the poor have cried, Caesar hath wept; + Ambition should be made of sterner stuff: + Yet Brutus says he was ambitious, + And Brutus is an honorable man. + You all did see that on the Lupercal + I thrice presented him a kingly crown, + Which he did thrice refuse. Was this ambition? + Yet Brutus says he was ambitious, + And sure he is an honorable man. + I speak not to disprove what Brutus spoke, + But here I am to speak what I do know. + You all did love him once, not without cause; + What cause withholds you then to mourn for him? + O judgement, thou art fled to brutish beasts, + And men have lost their reason. Bear with me; + My heart is in the coffin there with Caesar, + And I must pause till it come back to me."""; + + var replaced = string.replaceAll(new RegExp(r"\b\w+\b"), "foo"); + for (var i = 0; i < 3; i++) { + assertEquals(replaced, string.replaceAll(new RegExp(r"\b\w+\b"), "foo")); + } + + // Check that the result is in a COW array. + var words = string.split(" "); + assertEquals("Friends,", words[0]); + words[0] = "Enemies,"; + words = string.split(" "); + assertEquals("Friends,", words[0]); +} diff --git a/tests/corelib/regexp/stack-overflow2_test.dart b/tests/corelib/regexp/stack-overflow2_test.dart new file mode 100644 index 00000000000..9b617095c79 --- /dev/null +++ b/tests/corelib/regexp/stack-overflow2_test.dart @@ -0,0 +1,21 @@ +// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +// Failing tests extracted from pcre_test.dart. Large generated functions +// cause a stack overflow in DiscoverBlocks(). + +void main() { + var res149 = new RegExp( + r"(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\w+)\s+(\270)", + caseSensitive: false); + + assertToStringEquals( + "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 ABC ABC,1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10 ,11 ,12 ,13 ,14 ,15 ,16 ,17 ,18 ,19 ,20 ,21 ,22 ,23 ,24 ,25 ,26 ,27 ,28 ,29 ,30 ,31 ,32 ,33 ,34 ,35 ,36 ,37 ,38 ,39 ,40 ,41 ,42 ,43 ,44 ,45 ,46 ,47 ,48 ,49 ,50 ,51 ,52 ,53 ,54 ,55 ,56 ,57 ,58 ,59 ,60 ,61 ,62 ,63 ,64 ,65 ,66 ,67 ,68 ,69 ,70 ,71 ,72 ,73 ,74 ,75 ,76 ,77 ,78 ,79 ,80 ,81 ,82 ,83 ,84 ,85 ,86 ,87 ,88 ,89 ,90 ,91 ,92 ,93 ,94 ,95 ,96 ,97 ,98 ,99 ,100 ,101 ,102 ,103 ,104 ,105 ,106 ,107 ,108 ,109 ,110 ,111 ,112 ,113 ,114 ,115 ,116 ,117 ,118 ,119 ,120 ,121 ,122 ,123 ,124 ,125 ,126 ,127 ,128 ,129 ,130 ,131 ,132 ,133 ,134 ,135 ,136 ,137 ,138 ,139 ,140 ,141 ,142 ,143 ,144 ,145 ,146 ,147 ,148 ,149 ,150 ,151 ,152 ,153 ,154 ,155 ,156 ,157 ,158 ,159 ,160 ,161 ,162 ,163 ,164 ,165 ,166 ,167 ,168 ,169 ,170 ,171 ,172 ,173 ,174 ,175 ,176 ,177 ,178 ,179 ,180 ,181 ,182 ,183 ,184 ,185 ,186 ,187 ,188 ,189 ,190 ,191 ,192 ,193 ,194 ,195 ,196 ,197 ,198 ,199 ,200 ,201 ,202 ,203 ,204 ,205 ,206 ,207 ,208 ,209 ,210 ,211 ,212 ,213 ,214 ,215 ,216 ,217 ,218 ,219 ,220 ,221 ,222 ,223 ,224 ,225 ,226 ,227 ,228 ,229 ,230 ,231 ,232 ,233 ,234 ,235 ,236 ,237 ,238 ,239 ,240 ,241 ,242 ,243 ,244 ,245 ,246 ,247 ,248 ,249 ,250 ,251 ,252 ,253 ,254 ,255 ,256 ,257 ,258 ,259 ,260 ,261 ,262 ,263 ,264 ,265 ,266 ,267 ,268 ,269 ,ABC,ABC", + res149.firstMatch( + "O900 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 ABC ABC"), + 242); +} diff --git a/tests/corelib/regexp/stack-overflow_test.dart b/tests/corelib/regexp/stack-overflow_test.dart new file mode 100644 index 00000000000..e00466f0680 --- /dev/null +++ b/tests/corelib/regexp/stack-overflow_test.dart @@ -0,0 +1,39 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + description( + 'Test for bug 8870: Crash typing in Yahoo auto-complete widget.'); + + var re = new RegExp( + r'^(\s+|[,:{}\[\]]|"(\\["\\\/bfnrtu]|[^\u0000-\u001f"\\]+)*"|-?\d+(\.\d*)?([eE][+-]?\d+)?|true|false|null)+$'); + + var result = re.firstMatch( + '{"ResultSet":{"totalResultsAvailable":"101000000","totalResultsReturned":100,"firstResultPosition":1,"Result":[{"Title":"Solar Eclipses of Saros 132","Summary":"Solar Eclipses of Saros 132 Solar Eclipses of Saros 132 The periodicity and recurrence of solar (and lunar) eclipses is governed by the Saros cycle, a period of approximately 6,585. 3 days (18 years 11 days 8 hours). When two eclipses are ...","Url":"http:\\/\\/sunearth.gsfc.nasa.gov\\/eclipse\\/SEsaros\\/SEsaros132.html","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBUBzdmMwF;_ylu=X3oDMTB2cXVjNTM5BGNvbG8DdwRsA1dTMQRwb3MDMQRzZWMDc3IEdnRpZAM-\\/SIG=19ip3vo9u\\/EXP=1147592336\\/**http%3a\\/\\/rdrw1.yahoo.com\\/click%3fu=http%3a\\/\\/sunearth.gsfc.nasa.gov\\/eclipse\\/SEsaros\\/SEsaros132.html%26y=0405DC60F30D6DD673%26i=482%26c=15685%26q=02%255ESSHPM%255BL7.,-6%26e=utf-8%26r=0%26d=wow%7eWBSV-en-us%26n=3O6KG7JU5PIK8T7I%26s=6%26t=%26m=44658D10%26x=05A6B5FDC2F29725CD6EE467684E0FE76D","ModificationDate":1146207600,"MimeType":"text\\/html"},{"Title":"Psalms 132 -Matthew Henry\'s Commentary - Bible Software by johnhurt.com","Summary":"Psalms 132 - Matthew Henry Commentary - Bible Software by johnhurt.com ... Henry\'s Psalms 131. Psalms 132. Outline of Psalms 132. David\'s care for the ark ...","Url":"http:\\/\\/www.htmlbible.com\\/kjv30\\/henry\\/H19C132.htm","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBVhzdmMwF;_ylu=X3oDMTB2ZjQ4dDExBGNvbG8DdwRsA1dTMQRwb3MDMgRzZWMDc3IEdnRpZAM-\\/SIG=1246fjpfq\\/EXP=1147592336\\/**http%3a\\/\\/www.htmlbible.com\\/kjv30\\/henry\\/H19C132.htm","ModificationDate":1015660800,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBWxzdmMwF;_ylu=X3oDMTBwZG5hOWwzBGNvbG8DdwRwb3MDMgRzZWMDc3IEdnRpZAM-\\/SIG=16llm3b1a\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.htmlbible.com\\/kjv30\\/henry\\/H19C132.htm%26w=132%26d=XlIIG0aqMlsm%26icp=1%26.intl=us","Size":"4160"}},{"Title":"General requirements. - 1910.132","Summary":"General%20requirements.%20-%201910.132 ... Regulations (Standards - 29 CFR) General requirements. - 1910.132 ... of any part of the body through absorption, inhalation or physical contact. 1910.132(b) Employee-owned equipment ...","Url":"http:\\/\\/www.osha.gov\\/pls\\/oshaweb\\/owadisp.show_document?p_table=STANDARDS&p_id=9777","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBXRzdmMwF;_ylu=X3oDMTB2M3MzdmZoBGNvbG8DdwRsA1dTMQRwb3MDMwRzZWMDc3IEdnRpZAM-\\/SIG=13916ebti\\/EXP=1147592336\\/**http%3a\\/\\/www.osha.gov\\/pls\\/oshaweb\\/owadisp.show_document%3fp_table=STANDARDS%26p_id=9777","ModificationDate":1147330800,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBYhzdmMwF;_ylu=X3oDMTBwZ2dpZ2ZkBGNvbG8DdwRwb3MDMwRzZWMDc3IEdnRpZAM-\\/SIG=186osem1n\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.osha.gov\\/pls\\/oshaweb\\/owadisp.show_document%253Fp_table%253DSTANDARDS%2526p_id%253D9777%26w=132%26d=Ujn5sEaqMw88%26icp=1%26.intl=us","Size":"29922"}},{"Title":"USCCB - NAB - Psalm 132","Summary":"Chapter 132. 1. 1 A song of ascents. 2 LORD, remember David and all his anxious care; 2. 3 How he swore an oath to the LORD, vowed to the Mighty One of Jacob: 3. \\"I will not enter the house where I live, nor lie on the couch where I sleep; ... 1 [Psalm 132] A song for a liturgical ceremony in which the ark, the throne of Israel\'s God, was carried in ...","Url":"http:\\/\\/www.usccb.org\\/nab\\/bible\\/psalms\\/psalm132.htm","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBZBzdmMwF;_ylu=X3oDMTB2OWM1MXQ5BGNvbG8DdwRsA1dTMQRwb3MDNARzZWMDc3IEdnRpZAM-\\/SIG=126n03p75\\/EXP=1147592336\\/**http%3a\\/\\/www.usccb.org\\/nab\\/bible\\/psalms\\/psalm132.htm","ModificationDate":1054623600,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBaRzdmMwF;_ylu=X3oDMTBwYzFnNmkxBGNvbG8DdwRwb3MDNARzZWMDc3IEdnRpZAM-\\/SIG=16nvcm74b\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.usccb.org\\/nab\\/bible\\/psalms\\/psalm132.htm%26w=132%26d=FMBGyUaqMh-a%26icp=1%26.intl=us","Size":"8840"}},{"Title":"* City of Lost Dreams Mod *","Summary":"Mafia game modification","Url":"http:\\/\\/www.citizen-132.com\\/","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBaxzdmMwF;_ylu=X3oDMTB2NW50aG1hBGNvbG8DdwRsA1dTMQRwb3MDNQRzZWMDc3IEdnRpZAM-\\/SIG=11fnqlf31\\/EXP=1147592336\\/**http%3a\\/\\/www.citizen-132.com\\/","ModificationDate":1107676800,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBcBzdmMwF;_ylu=X3oDMTBwdDJ0dDBoBGNvbG8DdwRwb3MDNQRzZWMDc3IEdnRpZAM-\\/SIG=160jdk4g3\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.citizen-132.com\\/%26w=132%26d=ZiSHAkaqMuny%26icp=1%26.intl=us","Size":"6861"}},{"Title":"BibleGateway.com: Search for a Bible passage in over 35 languages and 50 versions.","Summary":"English (EN) Espa\\u00f1ol (ES) Passage results ... Footnotes: Psalm 132:6 That is, Kiriath Jearim. Psalm 132:6 Or heard of it in ...","Url":"http:\\/\\/www.biblegateway.com\\/passage\\/?book_id=23&chapter=132&version=31","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBchzdmMwF;_ylu=X3oDMTB2azJrdmpwBGNvbG8DdwRsA1dTMQRwb3MDNgRzZWMDc3IEdnRpZAM-\\/SIG=1300p6cfh\\/EXP=1147592336\\/**http%3a\\/\\/www.biblegateway.com\\/passage\\/%3fbook_id=23%26chapter=132%26version=31","ModificationDate":1147158000,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBdxzdmMwF;_ylu=X3oDMTBwYmwxdWo4BGNvbG8DdwRwb3MDNgRzZWMDc3IEdnRpZAM-\\/SIG=183q9adk2\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.biblegateway.com\\/passage\\/%253Fbook_id%253D23%2526chapter%253D132%2526version%253D31%26w=132%26d=XUM-1kaqMwKY%26icp=1%26.intl=us","Size":"27373"}},{"Title":"132 - Wikipedia, the free encyclopedia","Summary":"From Wikipedia, the free encyclopedia. This article is about the year. For other uses, see 132 (number). Events. Roman Empire. The Olympeion in Athens is completed ... Your continued donations keep Wikipedia running! 132. From Wikipedia, the free encyclopedia ... For other uses, see 132 (number). Years: 128 129 130 131 - 132 - 133 134 135 136 ...","Url":"http:\\/\\/en.wikipedia.org\\/wiki\\/132","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBeRzdmMwF;_ylu=X3oDMTB2bDEyNXM5BGNvbG8DdwRsA1dTMQRwb3MDNwRzZWMDc3IEdnRpZAM-\\/SIG=11k81281i\\/EXP=1147592336\\/**http%3a\\/\\/en.wikipedia.org\\/wiki\\/132","ModificationDate":1145862000,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBfhzdmMwF;_ylu=X3oDMTBwMTB0ZWFoBGNvbG8DdwRwb3MDNwRzZWMDc3IEdnRpZAM-\\/SIG=165kmnv8l\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=en.wikipedia.org\\/wiki\\/132%26w=132%26d=OcxF4UaqMuf2%26icp=1%26.intl=us","Size":"15956"}},{"Title":"BBC SPORT | Football | Internationals","Summary":"Visit BBC Sport for all the action as it happens - up-to-the-minute news, results, breaking news, video, audio and feature stories. BBC Sport covers the major events and all the professional football clubs in the UK, plus cricket, rugby, golf, ...","Url":"http:\\/\\/news.bbc.co.uk\\/sport1\\/hi\\/football\\/internationals\\/default.stm","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBgBzdmMwF;_ylu=X3oDMTB2bTU4Zm85BGNvbG8DdwRsA1dTMQRwb3MDOARzZWMDc3IEdnRpZAM-\\/SIG=12n3aafin\\/EXP=1147592336\\/**http%3a\\/\\/news.bbc.co.uk\\/sport1\\/hi\\/football\\/internationals\\/default.stm","ModificationDate":1147417200,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBhRzdmMwF;_ylu=X3oDMTBwYTZ1aGtmBGNvbG8DdwRwb3MDOARzZWMDc3IEdnRpZAM-\\/SIG=178rplb9d\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=news.bbc.co.uk\\/sport1\\/hi\\/football\\/internationals\\/default.stm%26w=132%26d=PmSx-kaqMw8o%26icp=1%26.intl=us","Size":"52634"}},{"Title":"Metro Route 132 Timetable, Weekday","Summary":"... Custom Print Help. 132. Weekday: Feb. 11 thru June 2, 2006 ...","Url":"http:\\/\\/transit.metrokc.gov\\/tops\\/bus\\/schedules\\/s132_0_.html","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBhxzdmMwF;_ylu=X3oDMTB2dW8yNmN0BGNvbG8DdwRsA1dTMQRwb3MDOQRzZWMDc3IEdnRpZAM-\\/SIG=12eusl28m\\/EXP=1147592336\\/**http%3a\\/\\/transit.metrokc.gov\\/tops\\/bus\\/schedules\\/s132_0_.html","ModificationDate":1146553200,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBjBzdmMwF;_ylu=X3oDMTBwOTRzYmZlBGNvbG8DdwRwb3MDOQRzZWMDc3IEdnRpZAM-\\/SIG=16vd4gkvv\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=transit.metrokc.gov\\/tops\\/bus\\/schedules\\/s132_0_.html%26w=132%26d=Nvq_ekaqMulb%26icp=1%26.intl=us","Size":"27482"}},{"Title":"BBC NEWS | Politics | Bush arrives for state visit","Summary":"George Bush arrives in the UK for the first state visit by a US president amid some of the tightest security London has seen.","Url":"http:\\/\\/news.bbc.co.uk\\/1\\/hi\\/uk_politics\\/3279179.stm","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBjhzdmMwF;_ylu=X3oDMTEwc3RuNTk4BGNvbG8DdwRsA1dTMQRwb3MDMTAEc2VjA3NyBHZ0aWQD\\/SIG=126am8694\\/EXP=1147592336\\/**http%3a\\/\\/news.bbc.co.uk\\/1\\/hi\\/uk_politics\\/3279179.stm","ModificationDate":1147417200,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBkxzdmMwF;_ylu=X3oDMTBxNTUzbTg4BGNvbG8DdwRwb3MDMTAEc2VjA3NyBHZ0aWQD\\/SIG=16nt5u57o\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=news.bbc.co.uk\\/1\\/hi\\/uk_politics\\/3279179.stm%26w=132%26d=CxDE2UaqMw8U%26icp=1%26.intl=us","Size":"43537"}},{"Title":"132 (number) - Wikipedia, the free encyclopedia","Summary":"... you can make from 132, you get 132: 12 + 13 + 21 + 23 + 31 + 32 = 132. 132 is the smallest number ...","Url":"http:\\/\\/en.wikipedia.org\\/wiki\\/132_(number)","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBlRzdmMwF;_ylu=X3oDMTEwNXN0b3YwBGNvbG8DdwRsA1dTMQRwb3MDMTEEc2VjA3NyBHZ0aWQD\\/SIG=11thbnu67\\/EXP=1147592336\\/**http%3a\\/\\/en.wikipedia.org\\/wiki\\/132_(number)","ModificationDate":1145430000,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBmhzdmMwF;_ylu=X3oDMTBxYnA3amlzBGNvbG8DdwRwb3MDMTEEc2VjA3NyBHZ0aWQD\\/SIG=16m4qjjlq\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=en.wikipedia.org\\/wiki\\/132_%2528number%2529%26w=132%26d=Ygdh6EaqMsBb%26icp=1%26.intl=us","Size":"13154"}},{"Title":"Psalms, Chapter 132","Summary":"King James Reference Suite - Bible Software by johnhurt.com ... Chapter 132. 1. Lord, remember David, and all his afflictions ... Notes on Chapter 132. 1. 2. 3 ...","Url":"http:\\/\\/www.htmlbible.com\\/kjv30\\/B19C132.htm","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBnBzdmMwF;_ylu=X3oDMTEwNmgxNTZoBGNvbG8DdwRsA1dTMQRwb3MDMTIEc2VjA3NyBHZ0aWQD\\/SIG=11uujk8hq\\/EXP=1147592336\\/**http%3a\\/\\/www.htmlbible.com\\/kjv30\\/B19C132.htm","ModificationDate":1079942400,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBoRzdmMwF;_ylu=X3oDMTBxN2cybDkwBGNvbG8DdwRwb3MDMTIEc2VjA3NyBHZ0aWQD\\/SIG=16fpgk3vj\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.htmlbible.com\\/kjv30\\/B19C132.htm%26w=132%26d=TaFtBUaqMwcr%26icp=1%26.intl=us","Size":"8721"}},{"Title":"SPACE.com -- Privately Funded SpaceShipOne Breaks Sound Barrier","Summary":"A privately financed passenger-carrying sub-orbital rocket plane screamed its way through the sound barrier today, the 100th anniversary of the Wright Brothers historic 12-second flight over Kitty Hawk, North Carolina.","Url":"http:\\/\\/www.space.com\\/businesstechnology\\/technology\\/rutan_update_031217.html","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBoxzdmMwF;_ylu=X3oDMTEwNHRmcnV0BGNvbG8DdwRsA1dTMQRwb3MDMTMEc2VjA3NyBHZ0aWQD\\/SIG=12vltjpcd\\/EXP=1147592336\\/**http%3a\\/\\/www.space.com\\/businesstechnology\\/technology\\/rutan_update_031217.html","ModificationDate":1147330800,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBqBzdmMwF;_ylu=X3oDMTBxajcxM3AwBGNvbG8DdwRwb3MDMTMEc2VjA3NyBHZ0aWQD\\/SIG=17g6i6br5\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.space.com\\/businesstechnology\\/technology\\/rutan_update_031217.html%26w=132%26d=CklT2kaqMwqb%26icp=1%26.intl=us","Size":"39319"}},{"Title":"D&C 132","Summary":"THE DOCTRINE AND COVENANTS. SECTION 132 ... LDS HomeScriptures Doctrine and Covenants Sections Section 132. Prev | Next ... SECTION 132. Revelation given through Joseph Smith the Prophet, at Nauvoo, Illinois, recorded July 12, 1843 ...","Url":"http:\\/\\/scriptures.lds.org\\/dc\\/132","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBqhzdmMwF;_ylu=X3oDMTEwamo4ZjVjBGNvbG8DdwRsA1dTMQRwb3MDMTQEc2VjA3NyBHZ0aWQD\\/SIG=11k67f7oi\\/EXP=1147592336\\/**http%3a\\/\\/scriptures.lds.org\\/dc\\/132","ModificationDate":1146985200,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBrxzdmMwF;_ylu=X3oDMTBxcDhuOXFrBGNvbG8DdwRwb3MDMTQEc2VjA3NyBHZ0aWQD\\/SIG=165qbp40u\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=scriptures.lds.org\\/dc\\/132%26w=132%26d=KIW1S0aqMwF3%26icp=1%26.intl=us","Size":"51549"}},{"Title":"State Representative District 132","Summary":"State Representative District 132. State Representative District 132 is shaded area. SACO. BIDDEFORD. 127. 132. 133. 136. OLD ORCHARD BEACH. SACO","Url":"http:\\/\\/mainegov-images.informe.org\\/sos\\/cec\\/elec\\/apport\\/House\\/h132.pdf","ClickUrl":"http:\\/\\/mainegov-images.informe.org\\/sos\\/cec\\/elec\\/apport\\/House\\/h132.pdf#search=\'\'","ModificationDate":1075968000,"MimeType":"application\\/pdf","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBtBzdmMwF;_ylu=X3oDMTBxbnZxbGc1BGNvbG8DdwRwb3MDMTUEc2VjA3NyBHZ0aWQD\\/SIG=17at7erej\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=mainegov-images.informe.org\\/sos\\/cec\\/elec\\/apport\\/House\\/h132.pdf%26w=132%26d=DsRim0aqMiIQ%26icp=1%26.intl=us","Size":"129767"}},{"Title":"BLB Psa 132","Summary":"We apologize, but the page layout is not visible because you are using an older browser. We recommend upgrading to a standards-compliant browser. Without such, this page will remain viewable, though unformatted.","Url":"http:\\/\\/www.blueletterbible.org\\/kjv\\/Psa\\/Psa132.html","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBthzdmMwF;_ylu=X3oDMTEwdXRzN2p1BGNvbG8DdwRsA1dTMQRwb3MDMTYEc2VjA3NyBHZ0aWQD\\/SIG=126nkscdr\\/EXP=1147592336\\/**http%3a\\/\\/www.blueletterbible.org\\/kjv\\/Psa\\/Psa132.html","ModificationDate":1146985200,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBuxzdmMwF;_ylu=X3oDMTBxdWpsMnAxBGNvbG8DdwRwb3MDMTYEc2VjA3NyBHZ0aWQD\\/SIG=16nmo95in\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.blueletterbible.org\\/kjv\\/Psa\\/Psa132.html%26w=132%26d=RzXlkkaqMwDE%26icp=1%26.intl=us","Size":"40835"}},{"Title":"ADL Found Guilty Of Spying By California Court","Summary":"ADL Found Guilty Of Spying. By California Court. By Barbara Ferguson. Arab News Correspondent. 4-27-2","Url":"http:\\/\\/www.rense.com\\/general24\\/adl.htm","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBvRzdmMwF;_ylu=X3oDMTEwcm5pb3BuBGNvbG8DdwRsA1dTMQRwb3MDMTcEc2VjA3NyBHZ0aWQD\\/SIG=11qjguns4\\/EXP=1147592336\\/**http%3a\\/\\/www.rense.com\\/general24\\/adl.htm","ModificationDate":1019890800,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBwhzdmMwF;_ylu=X3oDMTBxN2RrOGV1BGNvbG8DdwRwb3MDMTcEc2VjA3NyBHZ0aWQD\\/SIG=16bnmcrht\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.rense.com\\/general24\\/adl.htm%26w=132%26d=Xkre4EaqMuwO%26icp=1%26.intl=us","Size":"5916"}},{"Title":"FindLaw for Legal Professionals - Case Law, Federal and State Resources, Forms, and Code","Summary":"FindLaw for Legal Professionals is a free resource for attorneys that includes online case law, free state codes, free federal codes, free legal forms, and a directory of products and services for lawyers. This online legal Web site also includes...","Url":"http:\\/\\/caselaw.lp.findlaw.com\\/cgi-bin\\/getcase.pl?court=US&vol=391&invol=936","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBxBzdmMwF;_ylu=X3oDMTEwa2drb20xBGNvbG8DdwRsA1dTMQRwb3MDMTgEc2VjA3NyBHZ0aWQD\\/SIG=135rsl3q8\\/EXP=1147592336\\/**http%3a\\/\\/caselaw.lp.findlaw.com\\/cgi-bin\\/getcase.pl%3fcourt=US%26vol=391%26invol=936","ModificationDate":1147330800,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcByRzdmMwF;_ylu=X3oDMTBxZGJndmNzBGNvbG8DdwRwb3MDMTgEc2VjA3NyBHZ0aWQD\\/SIG=188s7bq1v\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=caselaw.lp.findlaw.com\\/cgi-bin\\/getcase.pl%253Fcourt%253DUS%2526vol%253D391%2526invol%253D936%26w=132%26d=GCWYIUaqMwZK%26icp=1%26.intl=us","Size":"57332"}},{"Title":"Chapter 132","Summary":"... Public Records. \\u00a7 132\\u20101. \\" Public records\\" defined ... Public records, as defined in G.S. 132\\u20101, shall not include written communications (and copies thereof) to any public ...","Url":"http:\\/\\/www.ncleg.net\\/EnactedLegislation\\/Statutes\\/HTML\\/ByChapter\\/Chapter_132.html","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcByxzdmMwF;_ylu=X3oDMTEwdjV0NWw0BGNvbG8DdwRsA1dTMQRwb3MDMTkEc2VjA3NyBHZ0aWQD\\/SIG=1349nldcc\\/EXP=1147592336\\/**http%3a\\/\\/www.ncleg.net\\/EnactedLegislation\\/Statutes\\/HTML\\/ByChapter\\/Chapter_132.html","ModificationDate":1141027200,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcB0BzdmMwF;_ylu=X3oDMTBxdDJjbXM4BGNvbG8DdwRwb3MDMTkEc2VjA3NyBHZ0aWQD\\/SIG=17lgm2hmb\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.ncleg.net\\/EnactedLegislation\\/Statutes\\/HTML\\/ByChapter\\/Chapter_132.html%26w=132%26d=akl3I0aqMt5y%26icp=1%26.intl=us","Size":"76411"}},{"Title":"oremus Bible Browser : Psalm 132","Summary":"Psalm 132. A Song of Ascents. 1O Lord, remember in David\'s favour. all the hardships he endured; 2how he swore to the Lord. and vowed to the Mighty One of Jacob, 3 I will not enter my house. or get into my bed;","Url":"http:\\/\\/bible.oremus.org\\/?passage=Psalm+132","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcB0hzdmMwF;_ylu=X3oDMTEwcDU0bmdlBGNvbG8DdwRsA1dTMQRwb3MDMjAEc2VjA3NyBHZ0aWQD\\/SIG=122hghelb\\/EXP=1147592336\\/**http%3a\\/\\/bible.oremus.org\\/%3fpassage=Psalm%2b132","ModificationDate":1138003200,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcB1xzdmMwF;_ylu=X3oDMTBxbjVuNnZxBGNvbG8DdwRwb3MDMjAEc2VjA3NyBHZ0aWQD\\/SIG=16ppk73gi\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=bible.oremus.org\\/%253Fpassage%253DPsalm%2b132%26w=132%26d=MBPBT0aqMkLR%26icp=1%26.intl=us","Size":"6083"}},{"Title":"Electronic Code of Federal Regulations:","Summary":"... Application of part 132 requirements in Great Lakes States and Tribes ... Appendix A to Part 132 --Great Lakes Water Quality Initiative Methodologies for Development of Aquatic Life ...","Url":"http:\\/\\/ecfr.gpoaccess.gov\\/cgi\\/t\\/text\\/text-idx?c=ecfr&tpl=\\/ecfrbrowse\\/Title40\\/40cfr132_main_02.tpl","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcB2RzdmMwF;_ylu=X3oDMTEwMGRnbnZ2BGNvbG8DdwRsA1dTMQRwb3MDMjEEc2VjA3NyBHZ0aWQD\\/SIG=13p811gl2\\/EXP=1147592336\\/**http%3a\\/\\/ecfr.gpoaccess.gov\\/cgi\\/t\\/text\\/text-idx%3fc=ecfr%26tpl=\\/ecfrbrowse\\/Title40\\/40cfr132_main_02.tpl","ModificationDate":1147244400,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcB3hzdmMwF;_ylu=X3oDMTBxb2QzaXJsBGNvbG8DdwRwb3MDMjEEc2VjA3NyBHZ0aWQD\\/SIG=18m524f9v\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=ecfr.gpoaccess.gov\\/cgi\\/t\\/text\\/text-idx%253Fc%253Decfr%2526tpl%253D\\/ecfrbrowse\\/Title40\\/40cfr132_main_02.tpl%26w=132%26d=OC6Oa0aqMwQa%26icp=1%26.intl=us","Size":"24321"}},{"Title":"BibleGateway.com - Passage Lookup: Psalms 132;","Summary":"English (EN) Espa\\u00f1ol (ES) Passage results ... View commentary related to this passage : Psalm 132. Psalm 132 (Amplified Bible ...","Url":"http:\\/\\/www.biblegateway.com\\/passage?search=Psalms+132;&version=45;","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcB4BzdmMwF;_ylu=X3oDMTEwMmJvNjYwBGNvbG8DdwRsA1dTMQRwb3MDMjIEc2VjA3NyBHZ0aWQD\\/SIG=12s5v8a5i\\/EXP=1147592336\\/**http%3a\\/\\/www.biblegateway.com\\/passage%3fsearch=Psalms%2b132;%26version=45;","ModificationDate":1139990400,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcB5RzdmMwF;_ylu=X3oDMTBxOTdwc3RpBGNvbG8DdwRwb3MDMjIEc2VjA3NyBHZ0aWQD\\/SIG=1810cufkn\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.biblegateway.com\\/passage%253Fsearch%253DPsalms%2b132%253B%2526version%253D45%253B%26w=132%26d=KJ4R3EaqMjLm%26icp=1%26.intl=us","Size":"27611"}},{"Title":"N-132: Wu-ftpd Buffer Overflow Vulnerability","Summary":"INFORMATION BULLETIN. N-132: Wu-ftpd Buffer Overflow Vulnerability. [Red Hat Security Advisory RHSA-2003:245-15] July 31, 2003 18:00 GMT. [Revised 13 Aug 2003] [Revised 14 Aug 2003] [Revised 5 Sept 2003] [Revised 8 Oct 2003]","Url":"http:\\/\\/www.ciac.org\\/ciac\\/bulletins\\/n-132.shtml","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcB5xzdmMwF;_ylu=X3oDMTEwZXVqN2J0BGNvbG8DdwRsA1dTMQRwb3MDMjMEc2VjA3NyBHZ0aWQD\\/SIG=122msf6uh\\/EXP=1147592336\\/**http%3a\\/\\/www.ciac.org\\/ciac\\/bulletins\\/n-132.shtml","ModificationDate":1146812400,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcB7BzdmMwF;_ylu=X3oDMTBxbm8wZ2ZmBGNvbG8DdwRwb3MDMjMEc2VjA3NyBHZ0aWQD\\/SIG=16jq98ra6\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.ciac.org\\/ciac\\/bulletins\\/n-132.shtml%26w=132%26d=cBzeO0aqMu2t%26icp=1%26.intl=us","Size":"12337"}},{"Title":"Bumpy Objects","Summary":"Bumpy Objects","Url":"http:\\/\\/acm.uva.es\\/p\\/v1\\/132.html","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcB7hzdmMwF;_ylu=X3oDMTEwZmNyM2VjBGNvbG8DdwRsA1dTMQRwb3MDMjQEc2VjA3NyBHZ0aWQD\\/SIG=11j1o5t64\\/EXP=1147592336\\/**http%3a\\/\\/acm.uva.es\\/p\\/v1\\/132.html","ModificationDate":1057820400,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcB8xzdmMwF;_ylu=X3oDMTBxNWw4M3FvBGNvbG8DdwRwb3MDMjQEc2VjA3NyBHZ0aWQD\\/SIG=164vlv52k\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=acm.uva.es\\/p\\/v1\\/132.html%26w=132%26d=ZSctVkaqMvQs%26icp=1%26.intl=us","Size":"2803"}},{"Title":"The Hayes memo is important\\u2014but bogus. By Daniel Benjamin","Summary":"When they published their \\" Case Closed\\" cover story three weeks ago on the relationship between Saddam Hussein\'s Iraq and al-Qaida, the editors of the Weekly Standard aimed to set off a bomb. The article was centered on a sizable leak\\u2014a gusher...","Url":"http:\\/\\/www.slate.com\\/id\\/2092180\\/","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcB9RzdmMwF;_ylu=X3oDMTEwamxzbHY1BGNvbG8DdwRsA1dTMQRwb3MDMjUEc2VjA3NyBHZ0aWQD\\/SIG=11kj0d4q1\\/EXP=1147592336\\/**http%3a\\/\\/www.slate.com\\/id\\/2092180\\/","ModificationDate":1147071600,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcB.hzdmMwF;_ylu=X3oDMTBxdGc1MmltBGNvbG8DdwRwb3MDMjUEc2VjA3NyBHZ0aWQD\\/SIG=16507c1iu\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=slate.msn.com\\/id\\/2092180\\/%26w=132%26d=bWigBUaqMvyd%26icp=1%26.intl=us","Size":"40222"}},{"Title":"FNMOC WXMAP: North America","Summary":"UNCLASSIFIED. FNMOC WXMAP. Model: NOGAPS. Area: North America. DTG: 2006050500. UNCLASSIFIED","Url":"https:\\/\\/www.fnmoc.navy.mil\\/CGI\\/PUBLIC\\/wxmap_single.cgi?area=ngp_namer&prod=850&tau=132","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcB_BzdmMwF;_ylu=X3oDMTEwNDNwbjA5BGNvbG8DdwRsA1dTMQRwb3MDMjYEc2VjA3NyBHZ0aWQD\\/SIG=13g43sejj\\/EXP=1147592336\\/**https%3a\\/\\/www.fnmoc.navy.mil\\/CGI\\/PUBLIC\\/wxmap_single.cgi%3farea=ngp_namer%26prod=850%26tau=132","ModificationDate":1146812400,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBAR3dmMwF;_ylu=X3oDMTBxN2ZrcnVrBGNvbG8DdwRwb3MDMjYEc2VjA3NyBHZ0aWQD\\/SIG=18s7gc72v\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=https%3a\\/\\/www.fnmoc.navy.mil\\/CGI\\/PUBLIC\\/wxmap_single.cgi%253Farea%253Dngp_namer%2526prod%253D850%2526tau%253D132%26w=132%26d=KiW5fUaqMvIm%26icp=1%26.intl=us","Size":"9048"}},{"Title":"O-132: BEA WebLogic Server and Express Certificate Spoofing Vulnerability","Summary":"INFORMATION BULLETIN. O-132: BEA WebLogic Server and Express Certificate Spoofing Vulnerability. [BEA Security Advisory: BEA04-54.00] April 30, 2004 20:00 GMT. PROBLEM:","Url":"http:\\/\\/ciac.llnl.gov\\/ciac\\/bulletins\\/o-132.shtml","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBAx3dmMwF;_ylu=X3oDMTEwb2lhN21nBGNvbG8DdwRsA1dTMQRwb3MDMjcEc2VjA3NyBHZ0aWQD\\/SIG=1231gt787\\/EXP=1147592336\\/**http%3a\\/\\/ciac.llnl.gov\\/ciac\\/bulletins\\/o-132.shtml","ModificationDate":1142064000,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBCB3dmMwF;_ylu=X3oDMTBxaGVsMDBlBGNvbG8DdwRwb3MDMjcEc2VjA3NyBHZ0aWQD\\/SIG=16k4puak0\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=ciac.llnl.gov\\/ciac\\/bulletins\\/o-132.shtml%26w=132%26d=ZZgzx0aqMjzn%26icp=1%26.intl=us","Size":"10701"}},{"Title":"NET Bible\\u00ae - Psalms 132","Summary":"... Psalms 132. Psalm 1321. A song of ascents.2. 132:1 O Lord, for David\'s sake remember ...","Url":"http:\\/\\/www.bible.org\\/netbible\\/psa132.htm","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBCh3dmMwF;_ylu=X3oDMTEwYjBiNjdsBGNvbG8DdwRsA1dTMQRwb3MDMjgEc2VjA3NyBHZ0aWQD\\/SIG=11sp4034c\\/EXP=1147592336\\/**http%3a\\/\\/www.bible.org\\/netbible\\/psa132.htm","ModificationDate":1133769600,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBDx3dmMwF;_ylu=X3oDMTBxOWNtc2JjBGNvbG8DdwRwb3MDMjgEc2VjA3NyBHZ0aWQD\\/SIG=16duuokm4\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.bible.org\\/netbible\\/psa132.htm%26w=132%26d=aVzzT0aqMwNl%26icp=1%26.intl=us","Size":"6048"}},{"Title":"HoustonChronicle.com - Sports: Fran Blinebury","Summary":"06, 2006. Column archive 2002. [an error occurred while processing this directive]","Url":"http:\\/\\/www.chron.com\\/content\\/chronicle\\/sports\\/blinebury\\/home","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBER3dmMwF;_ylu=X3oDMTEwcmlvNjMyBGNvbG8DdwRsA1dTMQRwb3MDMjkEc2VjA3NyBHZ0aWQD\\/SIG=12gac009r\\/EXP=1147592336\\/**http%3a\\/\\/www.chron.com\\/content\\/chronicle\\/sports\\/blinebury\\/home","ModificationDate":1146898800,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBFh3dmMwF;_ylu=X3oDMTBxNTVsY25mBGNvbG8DdwRwb3MDMjkEc2VjA3NyBHZ0aWQD\\/SIG=171sgehbh\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.chron.com\\/content\\/chronicle\\/sports\\/blinebury\\/home%26w=132%26d=I3QMYEaqMuxa%26icp=1%26.intl=us","Size":"27335"}},{"Title":"FNMOC WXMAP: North America","Summary":"UNCLASSIFIED. FNMOC WXMAP. Model: NOGAPS. Area: North America. DTG: 2006050512. UNCLASSIFIED","Url":"https:\\/\\/www.fnmoc.navy.mil\\/CGI\\/PUBLIC\\/wxmap_single.cgi?area=ngp_namer&prod=prp&tau=132","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBGB3dmMwF;_ylu=X3oDMTEwN2g4ZWdqBGNvbG8DdwRsA1dTMQRwb3MDMzAEc2VjA3NyBHZ0aWQD\\/SIG=13g08kode\\/EXP=1147592336\\/**https%3a\\/\\/www.fnmoc.navy.mil\\/CGI\\/PUBLIC\\/wxmap_single.cgi%3farea=ngp_namer%26prod=prp%26tau=132","ModificationDate":1146812400,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBHR3dmMwF;_ylu=X3oDMTBxaGdhODhjBGNvbG8DdwRwb3MDMzAEc2VjA3NyBHZ0aWQD\\/SIG=18solhmco\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=https%3a\\/\\/www.fnmoc.navy.mil\\/CGI\\/PUBLIC\\/wxmap_single.cgi%253Farea%253Dngp_namer%2526prod%253Dprp%2526tau%253D132%26w=132%26d=MKdCgkaqMuri%26icp=1%26.intl=us","Size":"9048"}},{"Title":"US CODE: Title 36,132. National School Lunch Week","Summary":"National School Lunch Week. Release date: 2005-10-11. (a) Designation.\\u2014. The week beginning on the second Sunday in October is National School Lunch Week. (b) Proclamation.\\u2014 ... TITLE 36 > Subtitle I > Part A > CHAPTER 1 > \\u00a7 132. Prev | Next. \\u00a7 132. National School Lunch Week ...","Url":"http:\\/\\/www4.law.cornell.edu\\/uscode\\/html\\/uscode36\\/usc_sec_36_00000132----000-.html","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBHx3dmMwF;_ylu=X3oDMTEwN3BsMm9vBGNvbG8DdwRsA1dTMQRwb3MDMzEEc2VjA3NyBHZ0aWQD\\/SIG=1359dp76s\\/EXP=1147592336\\/**http%3a\\/\\/www4.law.cornell.edu\\/uscode\\/html\\/uscode36\\/usc_sec_36_00000132----000-.html","ModificationDate":1145343600,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBJB3dmMwF;_ylu=X3oDMTBxNG81cnMxBGNvbG8DdwRwb3MDMzEEc2VjA3NyBHZ0aWQD\\/SIG=17m1he9ur\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www4.law.cornell.edu\\/uscode\\/html\\/uscode36\\/usc_sec_36_00000132----000-.html%26w=132%26d=NTi8bUaqMpvs%26icp=1%26.intl=us","Size":"8976"}},{"Title":"ATel #132: IGR J17464-3213","Summary":"Outside. Other. Present Time: 7 May 2006; 4:08 UT. RSS. XML Gamma Ray Bursts. IGR J17464-3213 ... IGR J17464-3213. ATel #132; M. Revnivtsev (IKI, Moscow; MPA, Garching), M ... XTE J1746-322 = IGR J17464-3213 = H1743-322. 132. IGR J17464-3213 ...","Url":"http:\\/\\/www.astronomerstelegram.org\\/?read=132","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBJh3dmMwF;_ylu=X3oDMTEwYWI0N2o2BGNvbG8DdwRsA1dTMQRwb3MDMzIEc2VjA3NyBHZ0aWQD\\/SIG=122qvcsd1\\/EXP=1147592336\\/**http%3a\\/\\/www.astronomerstelegram.org\\/%3fread=132","ModificationDate":1146985200,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBKx3dmMwF;_ylu=X3oDMTBxYmt2ZDZzBGNvbG8DdwRwb3MDMzIEc2VjA3NyBHZ0aWQD\\/SIG=16pipao89\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.astronomerstelegram.org\\/%253Fread%253D132%26w=132%26d=Pb4lcUaqMvBj%26icp=1%26.intl=us","Size":"9056"}},{"Title":"Vashegyite Mineral Data","Summary":"Vashegyite Mineral Data + General Vashegyite Information. Chemical Formula: Al11(PO4)9(OH)6\\u00b738(H2O) or Al6(PO4)5(OH)3\\u00b723(H2O) Composition: Molecular Weight = 1,938.16 gm. Aluminum 15.31 % Al 28.93 % Al2O3","Url":"http:\\/\\/www.webmineral.com\\/data\\/Vashegyite.shtml","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBLR3dmMwF;_ylu=X3oDMTEwNHFvMGppBGNvbG8DdwRsA1dTMQRwb3MDMzMEc2VjA3NyBHZ0aWQD\\/SIG=123ajp144\\/EXP=1147592336\\/**http%3a\\/\\/www.webmineral.com\\/data\\/Vashegyite.shtml","ModificationDate":1146898800,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBMh3dmMwF;_ylu=X3oDMTBxNzAwNWY0BGNvbG8DdwRwb3MDMzMEc2VjA3NyBHZ0aWQD\\/SIG=16ktl9ibf\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.webmineral.com\\/data\\/Vashegyite.shtml%26w=132%26d=W38GQkaqMvCt%26icp=1%26.intl=us","Size":"29234"}},{"Title":"2003 CFR Title 40, Volume 19","Summary":"... CHAPTER I--ENVIRONMENTAL PROTECTION AGENCY. PART 132--WATER QUALITY GUIDANCE FOR THE GREAT LAKES SYSTEM. 132.1. Scope, purpose, and availability of documents ...","Url":"http:\\/\\/www.access.gpo.gov\\/nara\\/cfr\\/waisidx_03\\/40cfr132_03.html","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBNB3dmMwF;_ylu=X3oDMTEwdHZ0ZXZxBGNvbG8DdwRsA1dTMQRwb3MDMzQEc2VjA3NyBHZ0aWQD\\/SIG=12imj9jh5\\/EXP=1147592336\\/**http%3a\\/\\/www.access.gpo.gov\\/nara\\/cfr\\/waisidx_03\\/40cfr132_03.html","ModificationDate":1123916400,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBOR3dmMwF;_ylu=X3oDMTBxcml1MjI5BGNvbG8DdwRwb3MDMzQEc2VjA3NyBHZ0aWQD\\/SIG=173ahs683\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.access.gpo.gov\\/nara\\/cfr\\/waisidx_03\\/40cfr132_03.html%26w=132%26d=c8h16UaqMjB2%26icp=1%26.intl=us","Size":"4704"}},{"Title":"Chapter HFS 132","Summary":"... 145. HFS 132.13. DEPARTMENT OF HEALTH AND FAMILY SERVICES ... Subchapter I \\u2014 General. HFS 132.11. Statutory authority. HFS 132.12 ...","Url":"http:\\/\\/www.legis.state.wi.us\\/rsb\\/code\\/hfs\\/hfs132.pdf","ClickUrl":"http:\\/\\/www.legis.state.wi.us\\/rsb\\/code\\/hfs\\/hfs132.pdf#search=\'\'","ModificationDate":1099033200,"MimeType":"application\\/pdf","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBPh3dmMwF;_ylu=X3oDMTBxaXI5cmVpBGNvbG8DdwRwb3MDMzUEc2VjA3NyBHZ0aWQD\\/SIG=16p8cmh99\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.legis.state.wi.us\\/rsb\\/code\\/hfs\\/hfs132.pdf%26w=132%26d=CN-yI0aqMkhi%26icp=1%26.intl=us","Size":"283151"}},{"Title":"U.S. Senate: Legislation & Records Home > Votes > Roll Call Vote","Summary":"... Vote Number: 132. Vote Date: June 8, 2005, 05:30 PM ...","Url":"http:\\/\\/www.senate.gov\\/legislative\\/LIS\\/roll_call_lists\\/roll_call_vote_cfm.cfm?congress=109&session=1&vote=00132","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBQB3dmMwF;_ylu=X3oDMTEwdTlzNmU2BGNvbG8DdwRsA1dTMQRwb3MDMzYEc2VjA3NyBHZ0aWQD\\/SIG=148g3pmm4\\/EXP=1147592336\\/**http%3a\\/\\/www.senate.gov\\/legislative\\/LIS\\/roll_call_lists\\/roll_call_vote_cfm.cfm%3fcongress=109%26session=1%26vote=00132","ModificationDate":1143360000,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBRR3dmMwF;_ylu=X3oDMTBxOTlsaWYxBGNvbG8DdwRwb3MDMzYEc2VjA3NyBHZ0aWQD\\/SIG=19b3rasjc\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.senate.gov\\/legislative\\/LIS\\/roll_call_lists\\/roll_call_vote_cfm.cfm%253Fcongress%253D109%2526session%253D1%2526vote%253D00132%26w=132%26d=dtev60aqMh1g%26icp=1%26.intl=us","Size":"51433"}},{"Title":"Storm Prediction Center Tornado Watch 132","Summary":"Severe weather, tornado, thunderstorm, fire weather, storm report, tornado watch, severe thunderstorm watch, mesoscale discussion, convective outlook products from the Storm Prediction Center. ... SEL2 URGENT - IMMEDIATE BROADCAST REQUESTED TORNADO WATCH NUMBER 132 NWS STORM PREDICTION CENTER NORMAN OK 325 PM CDT ...","Url":"http:\\/\\/www.spc.noaa.gov\\/products\\/watch\\/ww0132.html","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBRx3dmMwF;_ylu=X3oDMTEwanQ3MzU2BGNvbG8DdwRsA1dTMQRwb3MDMzcEc2VjA3NyBHZ0aWQD\\/SIG=126urlun7\\/EXP=1147592336\\/**http%3a\\/\\/www.spc.noaa.gov\\/products\\/watch\\/ww0132.html","ModificationDate":1146812400,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBTB3dmMwF;_ylu=X3oDMTBxNDRkc3R1BGNvbG8DdwRwb3MDMzcEc2VjA3NyBHZ0aWQD\\/SIG=16n3e4s74\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.spc.noaa.gov\\/products\\/watch\\/ww0132.html%26w=132%26d=N4g-pUaqMusz%26icp=1%26.intl=us","Size":"19990"}},{"Title":"PLANT PHYSIOLOGY ONLINE -- Table of Contents (132 [2])","Summary":"To see an article, click its [Full Text] link. To review many abstracts, check the boxes to the left of the titles you want, and click the \'Get All Checked Abstract(s)\' button. To see one abstract at a time, click its [Abstract] link.","Url":"http:\\/\\/www.plantphysiol.org\\/content\\/vol132\\/issue2\\/index.shtml","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBTh3dmMwF;_ylu=X3oDMTEwa2NtaWpsBGNvbG8DdwRsA1dTMQRwb3MDMzgEc2VjA3NyBHZ0aWQD\\/SIG=12hg0jpkp\\/EXP=1147592336\\/**http%3a\\/\\/www.plantphysiol.org\\/content\\/vol132\\/issue2\\/index.shtml","ModificationDate":1141804800,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBUx3dmMwF;_ylu=X3oDMTBxYnZvM21yBGNvbG8DdwRwb3MDMzgEc2VjA3NyBHZ0aWQD\\/SIG=172cps28k\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.plantphysiol.org\\/content\\/vol132\\/issue2\\/index.shtml%26w=132%26d=Yvs4KUaqMjZc%26icp=1%26.intl=us","Size":"79038"}},{"Title":"AgGPS 132","Summary":"... The AgGPS 132 outputs sub- meter accuracy DGPS positions ... lightbar is connected to the. AgGPS 132. The AgGPS 132. can output positions up to 10 ...","Url":"http:\\/\\/www.farmgis.com\\/products\\/hardware\\/gps\\/aggps132.pdf","ClickUrl":"http:\\/\\/www.farmgis.com\\/products\\/hardware\\/gps\\/aggps132.pdf#search=\'\'","ModificationDate":1098169200,"MimeType":"application\\/pdf","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBWB3dmMwF;_ylu=X3oDMTBxcXNibWtvBGNvbG8DdwRwb3MDMzkEc2VjA3NyBHZ0aWQD\\/SIG=16us46bp9\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.farmgis.com\\/products\\/hardware\\/gps\\/aggps132.pdf%26w=132%26d=EvLM70aqMkiV%26icp=1%26.intl=us","Size":"162160"}},{"Title":"Chapter 132 \\u2014 Grand Jury, Indictments and Other Accusatory Instruments","Summary":"The text appearing in this database was produced from material provided by the Legislative Counsel Committee of the Oregon Legislative Assembly. The official record copy is the printed published copy of the Oregon Revised Statutes. ... 132.010 Composition. A grand jury is a body of seven persons drawn from the jurors in attendance ... 132.030 Challenge of juror prohibited; when juror may be excused. Neither ...","Url":"http:\\/\\/www.leg.state.or.us\\/ors\\/132.html","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBWh3dmMwF;_ylu=X3oDMTEwYTAzbTUxBGNvbG8DdwRsA1dTMQRwb3MDNDAEc2VjA3NyBHZ0aWQD\\/SIG=11r91jes0\\/EXP=1147592336\\/**http%3a\\/\\/www.leg.state.or.us\\/ors\\/132.html","ModificationDate":1144220400,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBXx3dmMwF;_ylu=X3oDMTBxdGU5a2FhBGNvbG8DdwRwb3MDNDAEc2VjA3NyBHZ0aWQD\\/SIG=16cbqvrlb\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.leg.state.or.us\\/ors\\/132.html%26w=132%26d=MFh3EUaqMk41%26icp=1%26.intl=us","Size":"73717"}},{"Title":"Downloaded 19 Aug 2002 to 132.163.136.56. Redistribution subject to AIP license or copyright, see http:\\/\\/ojps.aip... ","Summary":"Downloaded 19 Aug 2002 to 132.163.136.56. Redistribution subject to AIP license or copyright, see http:\\/\\/ojps.aip.org\\/japo\\/japcr.jsp. Downloaded 19 Aug 2002 to 132.163.136.56.","Url":"http:\\/\\/tf.nist.gov\\/general\\/pdf\\/550.pdf","ClickUrl":"http:\\/\\/tf.nist.gov\\/general\\/pdf\\/550.pdf#search=\'\'","ModificationDate":1029740400,"MimeType":"application\\/pdf","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBZB3dmMwF;_ylu=X3oDMTBxcDdtZjJoBGNvbG8DdwRwb3MDNDEEc2VjA3NyBHZ0aWQD\\/SIG=16bgqks5e\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=tf.nist.gov\\/general\\/pdf\\/550.pdf%26w=132%26d=PNXPXkaqMkLS%26icp=1%26.intl=us","Size":"2485625"}},{"Title":"Father Tom Inspired Pflugerville #132 To Evolve Into A Strong Fraternal Society","Summary":"... Monsignor Tom Frank is presented with the 2002 Society #132. Service Award by President Ray Pokorney ... ach year Society #132. of Pflugerville honors ...","Url":"http:\\/\\/www.kjtnet.org\\/web\\/benefits\\/newsletter\\/march03.pdf","ClickUrl":"http:\\/\\/www.kjtnet.org\\/web\\/benefits\\/newsletter\\/march03.pdf#search=\'\'","ModificationDate":1105603200,"MimeType":"application\\/pdf","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBaR3dmMwF;_ylu=X3oDMTBxMWU2b2h1BGNvbG8DdwRwb3MDNDIEc2VjA3NyBHZ0aWQD\\/SIG=16u12rqgg\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.kjtnet.org\\/web\\/benefits\\/newsletter\\/march03.pdf%26w=132%26d=fjH4hEaqMwZd%26icp=1%26.intl=us","Size":"2791412"}},{"Title":"Alsakharovite-Zn Mineral Data","Summary":"Alsakharovite-Zn Mineral Data. [Log In] [Current Auction] [Register to Bid] [FAQ] [About Us] Tired of Ebay rip-offs, scams, and dishonest people?","Url":"http:\\/\\/www.webmineral.com\\/data\\/Alsakharovite-Zn.shtml","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBax3dmMwF;_ylu=X3oDMTEwN2JwMzlhBGNvbG8DdwRsA1dTMQRwb3MDNDMEc2VjA3NyBHZ0aWQD\\/SIG=129j54b3c\\/EXP=1147592336\\/**http%3a\\/\\/www.webmineral.com\\/data\\/Alsakharovite-Zn.shtml","ModificationDate":1147158000,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBcB3dmMwF;_ylu=X3oDMTBxamhmc2lnBGNvbG8DdwRwb3MDNDMEc2VjA3NyBHZ0aWQD\\/SIG=16q6pnttb\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.webmineral.com\\/data\\/Alsakharovite-Zn.shtml%26w=132%26d=B_smj0aqMwJU%26icp=1%26.intl=us","Size":"38594"}},{"Title":"Psalm 132","Summary":"... Psalm 132. The Eternal Dwelling of God in Zion ...","Url":"http:\\/\\/www.hope.edu\\/academic\\/religion\\/bandstra\\/BIBLE\\/PSA\\/PSA132.HTM","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBch3dmMwF;_ylu=X3oDMTEwdXE2dm1tBGNvbG8DdwRsA1dTMQRwb3MDNDQEc2VjA3NyBHZ0aWQD\\/SIG=12n448u4t\\/EXP=1147592336\\/**http%3a\\/\\/www.hope.edu\\/academic\\/religion\\/bandstra\\/BIBLE\\/PSA\\/PSA132.HTM","ModificationDate":1114758000,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBdx3dmMwF;_ylu=X3oDMTBxMjBjZXRuBGNvbG8DdwRwb3MDNDQEc2VjA3NyBHZ0aWQD\\/SIG=17829d5da\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.hope.edu\\/academic\\/religion\\/bandstra\\/BIBLE\\/PSA\\/PSA132.HTM%26w=132%26d=Gs9Yt0aqMhg_%26icp=1%26.intl=us","Size":"5137"}},{"Title":"Bug 132 - Heartbeat requires all nodes to be pre-configured in ha.cf","Summary":"... Bugzilla Bug 132. Heartbeat requires all nodes to be pre-configured in ha.cf ... Bug#: 132. Platform: All DEC HP Macintosh PC SGI Sun Other ...","Url":"http:\\/\\/www.osdl.org\\/developer_bugzilla\\/show_bug.cgi?id=132","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBeR3dmMwF;_ylu=X3oDMTEwa3QxajIyBGNvbG8DdwRsA1dTMQRwb3MDNDUEc2VjA3NyBHZ0aWQD\\/SIG=12g1vvd06\\/EXP=1147592336\\/**http%3a\\/\\/www.osdl.org\\/developer_bugzilla\\/show_bug.cgi%3fid=132","ModificationDate":1146553200,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBfh3dmMwF;_ylu=X3oDMTBxbHY2NGw5BGNvbG8DdwRwb3MDNDUEc2VjA3NyBHZ0aWQD\\/SIG=177hj2go7\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.osdl.org\\/developer_bugzilla\\/show_bug.cgi%253Fid%253D132%26w=132%26d=Uzd0n0aqMtwg%26icp=1%26.intl=us","Size":"40101"}},{"Title":"Bug 132 - ChargeDispositionPlea and ChargeDispositionVerdict","Summary":"... Bugzilla Bug 132. ChargeDispositionPlea and ChargeDispositionVerdict ... Bug#: 132. Domain: AAMVA Corrections Courts Juvenile Law Enforcement Parole Probation Prosecution Other ...","Url":"http:\\/\\/justicexml.gtri.gatech.edu\\/feedback\\/show_bug.cgi?id=132","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBgB3dmMwF;_ylu=X3oDMTEwdmhtYjA4BGNvbG8DdwRsA1dTMQRwb3MDNDYEc2VjA3NyBHZ0aWQD\\/SIG=12klknku3\\/EXP=1147592336\\/**http%3a\\/\\/justicexml.gtri.gatech.edu\\/feedback\\/show_bug.cgi%3fid=132","ModificationDate":1143360000,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBhR3dmMwF;_ylu=X3oDMTBxa2g2bWNnBGNvbG8DdwRwb3MDNDYEc2VjA3NyBHZ0aWQD\\/SIG=17bcs6mrt\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=justicexml.gtri.gatech.edu\\/feedback\\/show_bug.cgi%253Fid%253D132%26w=132%26d=e0Zoy0aqMjBn%26icp=1%26.intl=us","Size":"16410"}},{"Title":"Publications","Summary":"... Bulletin 132, Management of the California State Water Project, is a series of annual reports that describe the ... annual Appendix E to Bulletin 132 and the final edition of the ...","Url":"http:\\/\\/www.swpao.water.ca.gov\\/publications","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBhx3dmMwF;_ylu=X3oDMTEwZjVhYXMzBGNvbG8DdwRsA1dTMQRwb3MDNDcEc2VjA3NyBHZ0aWQD\\/SIG=11ud1cv0a\\/EXP=1147592336\\/**http%3a\\/\\/www.swpao.water.ca.gov\\/publications","ModificationDate":1143187200,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBjB3dmMwF;_ylu=X3oDMTBxcjNocmY0BGNvbG8DdwRwb3MDNDcEc2VjA3NyBHZ0aWQD\\/SIG=16fvue890\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.swpao.water.ca.gov\\/publications%26w=132%26d=CDqKvkaqMhfi%26icp=1%26.intl=us","Size":"27835"}},{"Title":"Sampling at Head Crater and Bench Crater","Summary":"... 132:10:41 Bean: Boy, this Hand Tool Carrier is light and nice compared to carrying it around ... 132:11:20 Bean: I can see everything from fine-grain basalt ...","Url":"http:\\/\\/www.hq.nasa.gov\\/alsj\\/a12\\/a12.head_bench.html","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBjh3dmMwF;_ylu=X3oDMTEwYjFmcHI4BGNvbG8DdwRsA1dTMQRwb3MDNDgEc2VjA3NyBHZ0aWQD\\/SIG=127h6jrgp\\/EXP=1147592336\\/**http%3a\\/\\/www.hq.nasa.gov\\/alsj\\/a12\\/a12.head_bench.html","ModificationDate":1139731200,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBkx3dmMwF;_ylu=X3oDMTBxazBuMTN2BGNvbG8DdwRwb3MDNDgEc2VjA3NyBHZ0aWQD\\/SIG=16of05gsq\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.hq.nasa.gov\\/alsj\\/a12\\/a12.head_bench.html%26w=132%26d=O2JTbEaqMul1%26icp=1%26.intl=us","Size":"91895"}},{"Title":"Psalms 132","Summary":"Psalms 132. 132:1 A Song of degrees.","Url":"http:\\/\\/www.masterstech-home.com\\/The_Library\\/The_Bible\\/Bible_Chapters\\/Psalms\\/132.html","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBlR3dmMwF;_ylu=X3oDMTEwOG85MWM5BGNvbG8DdwRsA1dTMQRwb3MDNDkEc2VjA3NyBHZ0aWQD\\/SIG=1381oeor0\\/EXP=1147592336\\/**http%3a\\/\\/www.masterstech-home.com\\/The_Library\\/The_Bible\\/Bible_Chapters\\/Psalms\\/132.html","ModificationDate":1135152000,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBmh3dmMwF;_ylu=X3oDMTBxNWpuM3FoBGNvbG8DdwRwb3MDNDkEc2VjA3NyBHZ0aWQD\\/SIG=17p7bjs0u\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.masterstech-home.com\\/The_Library\\/The_Bible\\/Bible_Chapters\\/Psalms\\/132.html%26w=132%26d=TUYYg0aqMhg4%26icp=1%26.intl=us","Size":"11669"}},{"Title":"California Highways (www.cahighways.org): Routes 129 through 136","Summary":"... The 2005 Transportation Bill included \$14.4 million to widen Route 132 from Route 99 west to Dakota Avenue ... between Coulterville and Mariposa was cosigned as Route 49 and Route 132 ...","Url":"http:\\/\\/www.cahighways.org\\/129-136.html","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBnB3dmMwF;_ylu=X3oDMTEwaXBqZ2lxBGNvbG8DdwRsA1dTMQRwb3MDNTAEc2VjA3NyBHZ0aWQD\\/SIG=11q1ne7f6\\/EXP=1147592336\\/**http%3a\\/\\/www.cahighways.org\\/129-136.html","ModificationDate":1145689200,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBoR3dmMwF;_ylu=X3oDMTBxbmZjMXVuBGNvbG8DdwRwb3MDNTAEc2VjA3NyBHZ0aWQD\\/SIG=16bhah065\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.cahighways.org\\/129-136.html%26w=132%26d=fRBtE0aqMqve%26icp=1%26.intl=us","Size":"49110"}},{"Title":"Downloaded 11 Nov 2002 to 132.64.1.37. Redistribution subject to AIP license or copyright, see http:\\/\\/ojps.aip.org\\/... ","Summary":"Downloaded 11 Nov 2002 to 132.64.1.37. Redistribution subject to AIP license or copyright, see http:\\/\\/ojps.aip.org\\/rsio\\/rsicr.jsp. Downloaded 11 Nov 2002 to 132.64.1.37.","Url":"http:\\/\\/chem.ch.huji.ac.il\\/~porath\\/NST2\\/Lecture%205\\/Kuk%20and%20Silverman%20Rev_Sci_Inst_60_165_1989.pdf","ClickUrl":"http:\\/\\/chem.ch.huji.ac.il\\/~porath\\/NST2\\/Lecture%205\\/Kuk%20and%20Silverman%20Rev_Sci_Inst_60_165_1989.pdf#search=\'\'","ModificationDate":1069660800,"MimeType":"application\\/pdf","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBph3dmMwF;_ylu=X3oDMTBxZHJldXUyBGNvbG8DdwRwb3MDNTEEc2VjA3NyBHZ0aWQD\\/SIG=190pnnu1n\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=chem.ch.huji.ac.il\\/%257Eporath\\/NST2\\/Lecture%2525205\\/Kuk%252520and%252520Silverman%252520Rev_Sci_Inst_60_165_1989.pdf%26w=132%26d=F4c-T0aqMhfn%26icp=1%26.intl=us","Size":"3386219"}},{"Title":"Phelps Personnel Associates","Summary":"Welcome to Phelps Personnel Associates. Recruiting and Placing Engineers and Management Professionals since 1976. Concentration in the Carolinas and Southeastern job market. Permanent, Company fee-paid positions only. Confidential, courteous service","Url":"http:\\/\\/www.phelpspersonnel.com\\/","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBqB3dmMwF;_ylu=X3oDMTEwazlldjdwBGNvbG8DdwRsA1dTMQRwb3MDNTIEc2VjA3NyBHZ0aWQD\\/SIG=11j85rkug\\/EXP=1147592336\\/**http%3a\\/\\/www.phelpspersonnel.com\\/","ModificationDate":1060239600,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBrR3dmMwF;_ylu=X3oDMTBxZWJqMW1lBGNvbG8DdwRwb3MDNTIEc2VjA3NyBHZ0aWQD\\/SIG=164jn86me\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.phelpspersonnel.com\\/%26w=132%26d=KRPdjUaqMwQa%26icp=1%26.intl=us","Size":"6288"}},{"Title":"132 - Loss and resumption of Australian citizenship - Declaration of desre to resume Australian citizenship under ... ","Summary":"... retain another citizenship \\u0096 be under the age of 25 years. 132 (Design date 0705) - Page 1 ... 23A, 23AA, 23AB or 23B. 132 (Design date 0705) - Page 2 ...","Url":"http:\\/\\/www.immi.gov.au\\/allforms\\/pdf\\/132.pdf","ClickUrl":"http:\\/\\/www.immi.gov.au\\/allforms\\/pdf\\/132.pdf#search=\'\'","ModificationDate":1141113600,"MimeType":"application\\/pdf","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBsh3dmMwF;_ylu=X3oDMTBxYzdmNTNvBGNvbG8DdwRwb3MDNTMEc2VjA3NyBHZ0aWQD\\/SIG=16gtd8vkd\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.immi.gov.au\\/allforms\\/pdf\\/132.pdf%26w=132%26d=XLvxbUaqMvqk%26icp=1%26.intl=us","Size":"118238"}},{"Title":"Communication Workersof America Local 3808","Summary":"News Highlights and Headlines. Nominations for one (1) 402 Franklin Road Area Representative will be taken at the June 6, 2006 Membership Meeting. BellSouth CONTRACT INFO. Frequently asked Q&A","Url":"http:\\/\\/cwa3808.org\\/","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBtB3dmMwF;_ylu=X3oDMTEwMGJ0MmQ1BGNvbG8DdwRsA1dTMQRwb3MDNTQEc2VjA3NyBHZ0aWQD\\/SIG=117pqud0l\\/EXP=1147592336\\/**http%3a\\/\\/cwa3808.org\\/","ModificationDate":1147071600,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBuR3dmMwF;_ylu=X3oDMTBxY3NiaDkyBGNvbG8DdwRwb3MDNTQEc2VjA3NyBHZ0aWQD\\/SIG=15od3j3p8\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=cwa3808.org\\/%26w=132%26d=ahqtKEaqMwC6%26icp=1%26.intl=us","Size":"53103"}},{"Title":"Mirabilis ICQ 98a Vulnerability","Summary":"... Bugtraq ID: 132. Class: Failure to Handle Exceptional Conditions ...","Url":"http:\\/\\/www.securityfocus.com\\/bid\\/132","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBux3dmMwF;_ylu=X3oDMTEwNXIwZzI2BGNvbG8DdwRsA1dTMQRwb3MDNTUEc2VjA3NyBHZ0aWQD\\/SIG=11ocj9p23\\/EXP=1147592336\\/**http%3a\\/\\/www.securityfocus.com\\/bid\\/132","ModificationDate":1146034800,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBwB3dmMwF;_ylu=X3oDMTBxbnNnYWFhBGNvbG8DdwRwb3MDNTUEc2VjA3NyBHZ0aWQD\\/SIG=169dn3s31\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.securityfocus.com\\/bid\\/132%26w=132%26d=bbuQiUaqMsU1%26icp=1%26.intl=us","Size":"11819"}},{"Title":"Downloaded 23 Dec 2001 to 132.76.33.15. Redistribution subject to AIP license or copyright, see http:\\/\\/ojps.aip.org\\/... ","Summary":"Downloaded 23 Dec 2001 to 132.76.33.15. Redistribution subject to AIP license or copyright, see http:\\/\\/ojps.aip.org\\/jcpo\\/jcpcr.jsp. Downloaded 23 Dec 2001 to 132.76.33.15.","Url":"http:\\/\\/theochem.weizmann.ac.il\\/AIPreprints\\/8.pdf","ClickUrl":"http:\\/\\/theochem.weizmann.ac.il\\/AIPreprints\\/8.pdf#search=\'\'","ModificationDate":1092294000,"MimeType":"application\\/pdf","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBxR3dmMwF;_ylu=X3oDMTBxcjhpcTNrBGNvbG8DdwRwb3MDNTYEc2VjA3NyBHZ0aWQD\\/SIG=16l1r1fiu\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=theochem.weizmann.ac.il\\/AIPreprints\\/8.pdf%26w=132%26d=VrF160aqMjIt%26icp=1%26.intl=us","Size":"1754089"}},{"Title":"Chapter RL 132","Summary":"DEPARTMENT OF REGULATION AND LICENSING. Unofficial Text (See Printed Volume). Current through date and Register shown on Title Page. Register, July, 1999, No. 523. Chapter RL 132. APPLICATIONS. RL 132.01. Authority. RL 132.02 ... Note: Chapter RL 132 was created as an emergency rule effective 11\\u20131\\u201398 ...","Url":"http:\\/\\/www.legis.state.wi.us\\/rsb\\/code\\/rl\\/rl132.pdf","ClickUrl":"http:\\/\\/www.legis.state.wi.us\\/rsb\\/code\\/rl\\/rl132.pdf#search=\'\'","ModificationDate":1011859200,"MimeType":"application\\/pdf","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcByh3dmMwF;_ylu=X3oDMTBxZjI4aHZhBGNvbG8DdwRwb3MDNTcEc2VjA3NyBHZ0aWQD\\/SIG=16nps3tc2\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.legis.state.wi.us\\/rsb\\/code\\/rl\\/rl132.pdf%26w=132%26d=VTECeUaqMi-4%26icp=1%26.intl=us","Size":"8138"}},{"Title":"Rebuffing Bush, 132 Mayors Embrace Kyoto Rules - New York Times","Summary":"Greg Nickels of Seattle and 131 other like-minded mayors have joined a bipartisan coalition to fight global warming on the local level.","Url":"http:\\/\\/www.nytimes.com\\/2005\\/05\\/14\\/national\\/14kyoto.html?ex=1273723200&en=c02e1cce1ca43706&ei=5088","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBzB3dmMwF;_ylu=X3oDMTEwbm43bzM3BGNvbG8DdwRsA1dTMQRwb3MDNTgEc2VjA3NyBHZ0aWQD\\/SIG=13repbe72\\/EXP=1147592336\\/**http%3a\\/\\/www.nytimes.com\\/2005\\/05\\/14\\/national\\/14kyoto.html%3fex=1273723200%26en=c02e1cce1ca43706%26ei=5088","ModificationDate":1147330800,"MimeType":"text\\/html"},{"Title":"DHS-Revised Rule 132","Summary":"Easy access to Illinois services and information ... an e-mail address to pose questions regarding Rule 132. Please review the Rule 132 Q&A document posted on ...","Url":"http:\\/\\/www.dhs.state.il.us\\/revisedRule132","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcB0h3dmMwF;_ylu=X3oDMTEwMjl1dW84BGNvbG8DdwRsA1dTMQRwb3MDNTkEc2VjA3NyBHZ0aWQD\\/SIG=11tb4gcma\\/EXP=1147592336\\/**http%3a\\/\\/www.dhs.state.il.us\\/revisedRule132","ModificationDate":1147244400,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcB1x3dmMwF;_ylu=X3oDMTBxOWMyazRxBGNvbG8DdwRwb3MDNTkEc2VjA3NyBHZ0aWQD\\/SIG=16e8khp3d\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.dhs.state.il.us\\/revisedRule132%26w=132%26d=Oc4YikaqMwgM%26icp=1%26.intl=us","Size":"22903"}},{"Title":"211 CMR: DIVISION OF INSURANCE 6\\/27\\/97 211 CMR - 837 211 CMR 132.00: ACTUARIAL OPINION AND MEMORANDUM REGULATION ... ","Summary":"... 132.01: Purpose. 132.02: Authority. 132.03: Scope. 132.04: Definitions. 132.05: General Requirements. 132.06: Required Opinions. 132 ... Adequacy Analysis. 132.08: Statement of Actuarial ...","Url":"http:\\/\\/www.mass.gov\\/doi\\/Legal_Hearings\\/211_132.PDF","ClickUrl":"http:\\/\\/www.mass.gov\\/doi\\/Legal_Hearings\\/211_132.PDF#search=\'\'","ModificationDate":1003906800,"MimeType":"application\\/pdf","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcB3B3dmMwF;_ylu=X3oDMTBxdG9ldThsBGNvbG8DdwRwb3MDNjAEc2VjA3NyBHZ0aWQD\\/SIG=16no3ibvg\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.mass.gov\\/doi\\/Legal_Hearings\\/211_132.PDF%26w=132%26d=C4QXPkaqMjRM%26icp=1%26.intl=us","Size":"45945"}},{"Title":"Downloaded 22 Jul 2003 to 132.66.16.23. Redistribution subject to AIP license or copyright, see http:\\/\\/ojps.aip.org\\/... ","Summary":"Downloaded 22 Jul 2003 to 132.66.16.23. Redistribution subject to AIP license or copyright, see http:\\/\\/ojps.aip.org\\/jcpo\\/jcpcr.jsp. Downloaded 22 Jul 2003 to 132.66.16.23.","Url":"http:\\/\\/star.tau.ac.il\\/~andelman\\/reprints\\/021_JCP_1987_87_7229.pdf","ClickUrl":"http:\\/\\/star.tau.ac.il\\/~andelman\\/reprints\\/021_JCP_1987_87_7229.pdf#search=\'\'","ModificationDate":1058857200,"MimeType":"application\\/pdf","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcB4R3dmMwF;_ylu=X3oDMTBxZzZxbDZiBGNvbG8DdwRwb3MDNjEEc2VjA3NyBHZ0aWQD\\/SIG=17adesqgt\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=star.tau.ac.il\\/%257Eandelman\\/reprints\\/021_JCP_1987_87_7229.pdf%26w=132%26d=Lvkyh0aqMh8L%26icp=1%26.intl=us","Size":"1798906"}},{"Title":"Special Troops Battalion, 4th Brigade, 10th Mountain Division Insignia","Summary":"The Institute of Heraldry\'s Special Troops Battalion Section, Special Troops Battalion, 4th Brigade, 10th Mountain Division Insignia Page","Url":"http:\\/\\/www.tioh.hqda.pentagon.mil\\/STB\\/STB4Brigade10MountainDivision.htm","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcB4x3dmMwF;_ylu=X3oDMTEwZjFqOHFiBGNvbG8DdwRsA1dTMQRwb3MDNjIEc2VjA3NyBHZ0aWQD\\/SIG=12rjb6bu4\\/EXP=1147592336\\/**http%3a\\/\\/www.tioh.hqda.pentagon.mil\\/STB\\/STB4Brigade10MountainDivision.htm","ModificationDate":1109923200,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcB6B3dmMwF;_ylu=X3oDMTBxZzN1cnRoBGNvbG8DdwRwb3MDNjIEc2VjA3NyBHZ0aWQD\\/SIG=17c61sq2b\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.tioh.hqda.pentagon.mil\\/STB\\/STB4Brigade10MountainDivision.htm%26w=132%26d=CjDx1kaqMwEn%26icp=1%26.intl=us","Size":"8896"}},{"Title":"NNSA\'s Brooks lauds partnership in nonproliferation","Summary":"... ite Way. U133. 132. A-4. 135. 134. 132. Fun With Science ...","Url":"http:\\/\\/www.llnl.gov\\/llnl\\/06news\\/employee\\/articles\\/2001\\/12.21.01newsline.pdf","ClickUrl":"http:\\/\\/www.llnl.gov\\/llnl\\/06news\\/employee\\/articles\\/2001\\/12.21.01newsline.pdf#search=\'\'","ModificationDate":1099555200,"MimeType":"application\\/pdf","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcB7R3dmMwF;_ylu=X3oDMTBxZ25nbWN0BGNvbG8DdwRwb3MDNjMEc2VjA3NyBHZ0aWQD\\/SIG=17go91rgp\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.llnl.gov\\/llnl\\/06news\\/employee\\/articles\\/2001\\/12.21.01newsline.pdf%26w=132%26d=aLdSWEaqMjYB%26icp=1%26.intl=us","Size":"472758"}},{"Title":"Psalms 132. The Holy Bible: King James Version.","Summary":"... Reference > The Bible > The King James Version > Psalms > 132 ... The Psalms. 132. A Prayer for Blessing on the Sanctuary ...","Url":"http:\\/\\/www.bartleby.com\\/108\\/19\\/132.html","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcB7x3dmMwF;_ylu=X3oDMTEwdm1iOTMzBGNvbG8DdwRsA1dTMQRwb3MDNjQEc2VjA3NyBHZ0aWQD\\/SIG=11rfct28r\\/EXP=1147592336\\/**http%3a\\/\\/www.bartleby.com\\/108\\/19\\/132.html","ModificationDate":1134460800,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcB9B3dmMwF;_ylu=X3oDMTBxa3RqY29tBGNvbG8DdwRwb3MDNjQEc2VjA3NyBHZ0aWQD\\/SIG=16ckhlf21\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.bartleby.com\\/108\\/19\\/132.html%26w=132%26d=Om0HPEaqMjyM%26icp=1%26.intl=us","Size":"26896"}},{"Title":"The Criterion Collection: Ruling Class, The","Summary":"Title Person. Film Info. 1972. 154 minutes. Color. 1.77:1. Dolby Digital Mono 1.0. Anamorphic. English. Release Info. Catalog Number: CC1575D. ISBN: 1-55940-922-3. UPC: 7-15515-0124-2-3. SRP: \$39.95. Synopsis","Url":"http:\\/\\/www.criterionco.com\\/asp\\/release.asp?id=132","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcB9h3dmMwF;_ylu=X3oDMTEwcTRya2ltBGNvbG8DdwRsA1dTMQRwb3MDNjUEc2VjA3NyBHZ0aWQD\\/SIG=1272o9dh7\\/EXP=1147592336\\/**http%3a\\/\\/www.criterionco.com\\/asp\\/release.asp%3fid=132","ModificationDate":1147244400,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcB.x3dmMwF;_ylu=X3oDMTBxdDMwMGJvBGNvbG8DdwRwb3MDNjUEc2VjA3NyBHZ0aWQD\\/SIG=16u4fa0dg\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.criterionco.com\\/asp\\/release.asp%253Fid%253D132%26w=132%26d=L2PGVEaqMwN7%26icp=1%26.intl=us","Size":"16920"}},{"Title":"AJP Legacy -- Table of Contents (February 28 1941, 132 [2])","Summary":"Contents: February 28 1941, Volume 132, Issue 2 [Index by Author] Other Issues: To see an article, click its [Full Text] link.","Url":"http:\\/\\/ajplegacy.physiology.org\\/content\\/vol132\\/issue2\\/index.shtml","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcB_R3dmMwF;_ylu=X3oDMTEwZWhkczJpBGNvbG8DdwRsA1dTMQRwb3MDNjYEc2VjA3NyBHZ0aWQD\\/SIG=12lf1ce7j\\/EXP=1147592336\\/**http%3a\\/\\/ajplegacy.physiology.org\\/content\\/vol132\\/issue2\\/index.shtml","ModificationDate":1141459200,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBAh7dmMwF;_ylu=X3oDMTBxNzI0azAwBGNvbG8DdwRwb3MDNjYEc2VjA3NyBHZ0aWQD\\/SIG=176uub081\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=ajplegacy.physiology.org\\/content\\/vol132\\/issue2\\/index.shtml%26w=132%26d=Ms_vOEaqMj-H%26icp=1%26.intl=us","Size":"24095"}},{"Title":"released a letter (PDF)","Summary":"","Url":"http:\\/\\/www.house.gov\\/judiciary_democrats\\/letters\\/rovehrgrequestltr71405.pdf","ClickUrl":"http:\\/\\/www.house.gov\\/judiciary_democrats\\/letters\\/rovehrgrequestltr71405.pdf#search=\'\'","ModificationDate":1121410800,"MimeType":"application\\/pdf","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBBx7dmMwF;_ylu=X3oDMTBxOXQ3MWF0BGNvbG8DdwRwb3MDNjcEc2VjA3NyBHZ0aWQD\\/SIG=17g69a880\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.house.gov\\/judiciary_democrats\\/letters\\/rovehrgrequestltr71405.pdf%26w=132%26d=LPrB50aqMqRY%26icp=1%26.intl=us","Size":"381000"}},{"Title":"NC General Statutes Chapter 132","Summary":"North Carolina. State Public Records Law. North Carolina General Statutes. Chapter 132. Public Records. Last updated December 10th, 1999. Contents. Section Title. 132-1. \\"Public records\\" defined. 132-1.1. ... Section Title. 132-1. \\"Public records\\" defined. 132-1.1. Confidential communications by legal counsel to public board or agency; State tax ...","Url":"http:\\/\\/www.ah.dcr.state.nc.us\\/e-records\\/ncgs\\/ncgs132.htm","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBCR7dmMwF;_ylu=X3oDMTEwMjJmbW84BGNvbG8DdwRsA1dTMQRwb3MDNjgEc2VjA3NyBHZ0aWQD\\/SIG=12ctoo16c\\/EXP=1147592336\\/**http%3a\\/\\/www.ah.dcr.state.nc.us\\/e-records\\/ncgs\\/ncgs132.htm","ModificationDate":953625600,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBDh7dmMwF;_ylu=X3oDMTBxYjJtcGphBGNvbG8DdwRwb3MDNjgEc2VjA3NyBHZ0aWQD\\/SIG=16t5vbni8\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.ah.dcr.state.nc.us\\/e-records\\/ncgs\\/ncgs132.htm%26w=132%26d=MyfGH0aqMwR0%26icp=1%26.intl=us","Size":"43695"}},{"Title":"Technical Introduction to CDMA","Summary":"Course 132. Technical. Introduction to CDMA. Technical. Introduction to CDMA. IS-95, CDMA2000 and a glimpse of 1xEV. February, 2005. 132 - 1. Technical Introduction to CDMA v4.0 (c) 2005 Scott Baxter. Course Outline. Basic CDMA Principles. Coding","Url":"http:\\/\\/www.howcdmaworks.com\\/intro\\/132v3.pdf","ClickUrl":"http:\\/\\/www.howcdmaworks.com\\/intro\\/132v3.pdf#search=\'\'","ModificationDate":1107590400,"MimeType":"application\\/pdf","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBEx7dmMwF;_ylu=X3oDMTBxbTJnbmxhBGNvbG8DdwRwb3MDNjkEc2VjA3NyBHZ0aWQD\\/SIG=16ghr9cvr\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.howcdmaworks.com\\/intro\\/132v3.pdf%26w=132%26d=B6dAbEaqMu7t%26icp=1%26.intl=us","Size":"4342039"}},{"Title":"Thread Images Digitizing","Summary":"Free embroidery design. Specializes in providing custom quality embroidery designs to the professional embroiderer.","Url":"http:\\/\\/www.threadimages.com\\/","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBFR7dmMwF;_ylu=X3oDMTEwMmI2cWQzBGNvbG8DdwRsA1dTMQRwb3MDNzAEc2VjA3NyBHZ0aWQD\\/SIG=11gsp7523\\/EXP=1147592336\\/**http%3a\\/\\/www.threadimages.com\\/","ModificationDate":1147158000,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBGx7dmMwF;_ylu=X3oDMTBxaml0dDF0BGNvbG8DdwRwb3MDNzAEc2VjA3NyBHZ0aWQD\\/SIG=161ukrsfh\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.threadimages.com\\/%26w=132%26d=BmPG10aqMwgW%26icp=1%26.intl=us","Size":"55861"}},{"Title":"Psalms Chapter 132:1-18.","Summary":"Read the Hebrew Transliteration Psalms 132:1-18 Online.","Url":"http:\\/\\/bibledbdata.org\\/onlinebibles\\/hebrew_translit\\/19_132.htm","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBHR7dmMwF;_ylu=X3oDMTEwdXJnMnJuBGNvbG8DdwRsA1dTMQRwb3MDNzEEc2VjA3NyBHZ0aWQD\\/SIG=12i1mped7\\/EXP=1147592336\\/**http%3a\\/\\/bibledbdata.org\\/onlinebibles\\/hebrew_translit\\/19_132.htm","ModificationDate":1044172800,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBIh7dmMwF;_ylu=X3oDMTBxNmJocG1iBGNvbG8DdwRwb3MDNzEEc2VjA3NyBHZ0aWQD\\/SIG=173o8ajtj\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=bibledbdata.org\\/onlinebibles\\/hebrew_translit\\/19_132.htm%26w=132%26d=dfiAJkaqMi1u%26icp=1%26.intl=us","Size":"9706"}},{"Title":"PRC-132","Summary":"K6ERO Portable and pedestrian mobile amateur radio. PRC-132 & M50B. To the left is a Loral Terracom M50B. made in 1988 Serial#19 . Its 10 inches tall. with out battery box or external power. box , 3.5 inches wide and 5.25 inches. deep, weight 6.9 lbs . ... The M50B is the early issue version of the. PRC-132 special operations HF Radio ...","Url":"http:\\/\\/www.muttmotorpool.com\\/PRC-132","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBJB7dmMwF;_ylu=X3oDMTEwYm80YTY1BGNvbG8DdwRsA1dTMQRwb3MDNzIEc2VjA3NyBHZ0aWQD\\/SIG=11ou3h7bi\\/EXP=1147592336\\/**http%3a\\/\\/www.muttmotorpool.com\\/PRC-132","ModificationDate":1146294000,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBKR7dmMwF;_ylu=X3oDMTBxaDgzYWcxBGNvbG8DdwRwb3MDNzIEc2VjA3NyBHZ0aWQD\\/SIG=169r7ofhd\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.muttmotorpool.com\\/PRC-132%26w=132%26d=Utj0H0aqMs48%26icp=1%26.intl=us","Size":"19723"}},{"Title":"Firenze 132 \\/ 170","Summary":"Firenze 132 \\/ 170. Matte Presentation Paper. 132 gram 2-side coated. 170 gram single side coated. Magicl\\u00e9e\\u00ae Firenze 132 and Firenze 170 matte. papers are designed for poster applications and. have an impressive price performance ratio. The ... If using the 132 gram. paper for 2-sided imaging ink limit on ...","Url":"http:\\/\\/www.magicinkjet.com\\/client_data_pdf\\/guides\\/Firenze.pdf","ClickUrl":"http:\\/\\/www.magicinkjet.com\\/client_data_pdf\\/guides\\/Firenze.pdf#search=\'\'","ModificationDate":1081839600,"MimeType":"application\\/pdf","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBLh7dmMwF;_ylu=X3oDMTBxbXY4b2luBGNvbG8DdwRwb3MDNzMEc2VjA3NyBHZ0aWQD\\/SIG=172sdum75\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.magicinkjet.com\\/client_data_pdf\\/guides\\/Firenze.pdf%26w=132%26d=Q4ILzEaqMh1n%26icp=1%26.intl=us","Size":"2152647"}},{"Title":"Museletter # 132 \\/ February 2003: The US and Eurasia: End Game for the Industrial Era?","Summary":"Defining democracy in the wake of the 2002 elections in the U.S.A..","Url":"http:\\/\\/www.museletter.com\\/archive\\/132.html","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBMB7dmMwF;_ylu=X3oDMTEwNGRiZ3FjBGNvbG8DdwRsA1dTMQRwb3MDNzQEc2VjA3NyBHZ0aWQD\\/SIG=11upr7v32\\/EXP=1147592336\\/**http%3a\\/\\/www.museletter.com\\/archive\\/132.html","ModificationDate":1108540800,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBNR7dmMwF;_ylu=X3oDMTBxZTNpbG1nBGNvbG8DdwRwb3MDNzQEc2VjA3NyBHZ0aWQD\\/SIG=16fg9g4no\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.museletter.com\\/archive\\/132.html%26w=132%26d=SS0AQEaqMvuR%26icp=1%26.intl=us","Size":"47428"}},{"Title":"Downloaded 25 Oct 2002 to 132.66.16.12. Redistribution subject to AIP license or copyright, see http:\\/\\/ojps.aip.org\\/... ","Summary":"Downloaded 25 Oct 2002 to 132.66.16.12. Redistribution subject to AIP license or copyright, see http:\\/\\/ojps.aip.org\\/jcpo\\/jcpcr.jsp. Downloaded 25 Oct 2002 to 132.66.16.12.","Url":"http:\\/\\/star.tau.ac.il\\/~andelman\\/reprints\\/018_JCP_1987_86_3673.pdf","ClickUrl":"http:\\/\\/star.tau.ac.il\\/~andelman\\/reprints\\/018_JCP_1987_86_3673.pdf#search=\'\'","ModificationDate":1035529200,"MimeType":"application\\/pdf","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBOh7dmMwF;_ylu=X3oDMTBxbGZmanU1BGNvbG8DdwRwb3MDNzUEc2VjA3NyBHZ0aWQD\\/SIG=17a4s312u\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=star.tau.ac.il\\/%257Eandelman\\/reprints\\/018_JCP_1987_86_3673.pdf%26w=132%26d=YANT3kaqMhfd%26icp=1%26.intl=us","Size":"1204421"}},{"Title":"Hepatitis B Virus: A Comprehensive Strategy for Eliminating Transmission in the United States Through Universal ... ","Summary":"Hepatitis B Virus: A Comprehensive Strategy for Eliminating Transmission in the United States Through Universal Childhood Vaccination: Recommendations of the Immunization Practices Advisory Committee (ACIP)","Url":"http:\\/\\/www.cdc.gov\\/mmwr\\/preview\\/mmwrhtml\\/00033405.htm","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBPB7dmMwF;_ylu=X3oDMTEwb2NlbHRuBGNvbG8DdwRsA1dTMQRwb3MDNzYEc2VjA3NyBHZ0aWQD\\/SIG=129kdm2n4\\/EXP=1147592336\\/**http%3a\\/\\/www.cdc.gov\\/mmwr\\/preview\\/mmwrhtml\\/00033405.htm","ModificationDate":1139990400,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBQR7dmMwF;_ylu=X3oDMTBxZm44bG9sBGNvbG8DdwRwb3MDNzYEc2VjA3NyBHZ0aWQD\\/SIG=16qv48dkp\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.cdc.gov\\/mmwr\\/preview\\/mmwrhtml\\/00033405.htm%26w=132%26d=b-Kz6UaqMwIM%26icp=1%26.intl=us","Size":"87232"}},{"Title":"Tour de France 2005","Summary":"... QUICK STEP - INNERGETIC. 132 - CRETSKENS Wilfried (BEL) Born in 10\\/07\\/1976 \\u00e0 Herk-de-Stad (BEL ...","Url":"http:\\/\\/www.letour.fr\\/2005\\/TDF\\/RIDERS\\/us\\/coureurs\\/132.html","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBQx7dmMwF;_ylu=X3oDMTEwYjdwazg2BGNvbG8DdwRsA1dTMQRwb3MDNzcEc2VjA3NyBHZ0aWQD\\/SIG=12dpjmcf6\\/EXP=1147592336\\/**http%3a\\/\\/www.letour.fr\\/2005\\/TDF\\/RIDERS\\/us\\/coureurs\\/132.html","ModificationDate":1121583600,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBSB7dmMwF;_ylu=X3oDMTBxa21laGFvBGNvbG8DdwRwb3MDNzcEc2VjA3NyBHZ0aWQD\\/SIG=16u0nn96f\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.letour.fr\\/2005\\/TDF\\/RIDERS\\/us\\/coureurs\\/132.html%26w=132%26d=BTTUC0aqMv4Z%26icp=1%26.intl=us","Size":"12171"}},{"Title":"This American Life | Father\'s Day \'99","Summary":"... 6\\/18\\/99. Episode 132. For Father\'s Day, stories about fathers going out of their way to protect their kids, and kids going ...","Url":"http:\\/\\/www.thisamericanlife.org\\/pages\\/descriptions\\/99\\/132.html","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBSh7dmMwF;_ylu=X3oDMTEwNDFvam42BGNvbG8DdwRsA1dTMQRwb3MDNzgEc2VjA3NyBHZ0aWQD\\/SIG=12iobnkgv\\/EXP=1147592336\\/**http%3a\\/\\/www.thisamericanlife.org\\/pages\\/descriptions\\/99\\/132.html","ModificationDate":1146466800,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBTx7dmMwF;_ylu=X3oDMTBxZzFuNDV2BGNvbG8DdwRwb3MDNzgEc2VjA3NyBHZ0aWQD\\/SIG=1738d5fam\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.thisamericanlife.org\\/pages\\/descriptions\\/99\\/132.html%26w=132%26d=Ss_yvkaqMvWK%26icp=1%26.intl=us","Size":"8411"}},{"Title":"Downloaded 21 Jan 2004 to 132.66.16.34. Redistribution subject to AIP license or copyright, see http:\\/\\/ojps.aip.org\\/... ","Summary":"Downloaded 21 Jan 2004 to 132.66.16.34. Redistribution subject to AIP license or copyright, see http:\\/\\/ojps.aip.org\\/jcpo\\/jcpcr.jsp. Downloaded 21 Jan 2004 to 132.66.16.34.","Url":"http:\\/\\/femto.tau.ac.il\\/~nitzan\\/3.pdf","ClickUrl":"http:\\/\\/femto.tau.ac.il\\/~nitzan\\/3.pdf#search=\'\'","ModificationDate":1088665200,"MimeType":"application\\/pdf","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBVB7dmMwF;_ylu=X3oDMTBxdXJmcnJsBGNvbG8DdwRwb3MDNzkEc2VjA3NyBHZ0aWQD\\/SIG=16da99c2u\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=femto.tau.ac.il\\/%257Enitzan\\/3.pdf%26w=132%26d=b5Br7UaqMjB1%26icp=1%26.intl=us","Size":"1071954"}},{"Title":"CHAPTER 12 ENVIRONMENTAL REVIEW \\u2013 EAST 132","Summary":"Solid Waste Management Plan. 12-1. October2004. DEIS. CHAPTER 12. ENVIRONMENTAL REVIEW \\u2013 EAST 132. ND. STREET SITE. 12.1 Introduction. The East 132. nd. Street Site is currently permitted to handle 2,999 tpd of putrescible waste, with a","Url":"http:\\/\\/www.nyc.gov\\/html\\/dsny\\/downloads\\/pdf\\/pubnrpts\\/swmp-4oct\\/deis\\/chapter12.pdf","ClickUrl":"http:\\/\\/www.nyc.gov\\/html\\/dsny\\/downloads\\/pdf\\/pubnrpts\\/swmp-4oct\\/deis\\/chapter12.pdf#search=\'\'","ModificationDate":1099555200,"MimeType":"application\\/pdf","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBWR7dmMwF;_ylu=X3oDMTBxaHNlODZrBGNvbG8DdwRwb3MDODAEc2VjA3NyBHZ0aWQD\\/SIG=17llu5bkp\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.nyc.gov\\/html\\/dsny\\/downloads\\/pdf\\/pubnrpts\\/swmp-4oct\\/deis\\/chapter12.pdf%26w=132%26d=RPmqz0aqMiKh%26icp=1%26.intl=us","Size":"1417879"}},{"Title":"Psalms 132 \\/ Hebrew - English Bible \\/ Mechon-Mamre","Summary":"... 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 ... Psalms Chapter 132. \\u00e0 \\u00f9\\u00d1\\u00c4\\u00e9\\u00f8, \\u00e4\\u00c7\\u00ee\\u00cc\\u00c7\\u00f2\\u00c2\\u00ec\\u00e5\\u00c9\\u00fa ...","Url":"http:\\/\\/www.mechon-mamre.org\\/p\\/pt\\/pt26d2.htm","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBWx7dmMwF;_ylu=X3oDMTEwc3RoZXBrBGNvbG8DdwRsA1dTMQRwb3MDODEEc2VjA3NyBHZ0aWQD\\/SIG=11vhbotpk\\/EXP=1147592336\\/**http%3a\\/\\/www.mechon-mamre.org\\/p\\/pt\\/pt26d2.htm","ModificationDate":1138694400,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBYB7dmMwF;_ylu=X3oDMTBxNjUwMGs2BGNvbG8DdwRwb3MDODEEc2VjA3NyBHZ0aWQD\\/SIG=16gg7tf89\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.mechon-mamre.org\\/p\\/pt\\/pt26d2.htm%26w=132%26d=WTHLVUaqMu6s%26icp=1%26.intl=us","Size":"13881"}},{"Title":"US CODE: Title 28,132. Creation and composition of district courts","Summary":"Creation and composition of district courts. Release date: 2005-09-29. (a) There shall be in each judicial district a district court which shall be a court of record known as the United States District Court for the district.","Url":"http:\\/\\/www4.law.cornell.edu\\/uscode\\/28\\/132.html","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBYh7dmMwF;_ylu=X3oDMTEwcWlsMGMxBGNvbG8DdwRsA1dTMQRwb3MDODIEc2VjA3NyBHZ0aWQD\\/SIG=122ek55sr\\/EXP=1147592336\\/**http%3a\\/\\/www4.law.cornell.edu\\/uscode\\/28\\/132.html","ModificationDate":1143273600,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBZx7dmMwF;_ylu=X3oDMTBxYWs1NmFvBGNvbG8DdwRwb3MDODIEc2VjA3NyBHZ0aWQD\\/SIG=16jb47dcg\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www4.law.cornell.edu\\/uscode\\/28\\/132.html%26w=132%26d=QQ2S7EaqMjbv%26icp=1%26.intl=us","Size":"9107"}},{"Title":"Fiscal Note","Summary":"... Bill, Resolutions and Memorial Documents. SB05-132 ... Final Act\\/ Resolutions or Memorial: 132_enr.pdfn. 132.enrn. Preamended Documents ...","Url":"http:\\/\\/www.leg.state.co.us\\/Clics2005a\\/csl.nsf\\/fsbillcont3\\/A4058D1E27570DC987256F7E0059EAA8?Open&file=132_enr.pdf","ClickUrl":"http:\\/\\/www.leg.state.co.us\\/Clics2005a\\/csl.nsf\\/fsbillcont3\\/A4058D1E27570DC987256F7E0059EAA8?Open&file=132_enr.pdf#search=\'\'","ModificationDate":1124521200,"MimeType":"application\\/pdf","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBbB7dmMwF;_ylu=X3oDMTBxbGJmNjEwBGNvbG8DdwRwb3MDODMEc2VjA3NyBHZ0aWQD\\/SIG=191n41l4b\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.leg.state.co.us\\/Clics2005a\\/csl.nsf\\/fsbillcont3\\/A4058D1E27570DC987256F7E0059EAA8%253FOpen%2526file%253D132_enr.pdf%26w=132%26d=LViIXUaqMkKL%26icp=1%26.intl=us","Size":"87930"}},{"Title":"Development -- Table of Contents (January 1 2005, 132 [1])","Summary":"To see an article, click its [Full Text] link. To review many abstracts, check the boxes to the left of the titles you want, and click the \'Get All Checked Abstract(s)\' button. To see one abstract at a time, click its [Abstract] link.","Url":"http:\\/\\/dev.biologists.org\\/content\\/vol132\\/issue1","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBbh7dmMwF;_ylu=X3oDMTEwdWdwcnIyBGNvbG8DdwRsA1dTMQRwb3MDODQEc2VjA3NyBHZ0aWQD\\/SIG=123019ojj\\/EXP=1147592336\\/**http%3a\\/\\/dev.biologists.org\\/content\\/vol132\\/issue1","ModificationDate":1147071600,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBcx7dmMwF;_ylu=X3oDMTBxczM2ZHFvBGNvbG8DdwRwb3MDODQEc2VjA3NyBHZ0aWQD\\/SIG=16kng2m03\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=dev.biologists.org\\/content\\/vol132\\/issue1%26w=132%26d=LFOVEUaqMwR5%26icp=1%26.intl=us","Size":"25711"}},{"Title":"Winter Carnival (1939)","Summary":"Winter Carnival - Cast, Crew, Reviews, Plot Summary, Comments, Discussion, Taglines, Trailers, Posters, Photos, Showtimes, Link to Official Site, Fan Sites","Url":"http:\\/\\/www.imdb.com\\/title\\/tt0032132\\/","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBdR7dmMwF;_ylu=X3oDMTEwb3IzajNvBGNvbG8DdwRsA1dTMQRwb3MDODUEc2VjA3NyBHZ0aWQD\\/SIG=11o6bhdhm\\/EXP=1147592336\\/**http%3a\\/\\/www.imdb.com\\/title\\/tt0032132\\/","ModificationDate":1147417200,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBeh7dmMwF;_ylu=X3oDMTBxcG9jdDNjBGNvbG8DdwRwb3MDODUEc2VjA3NyBHZ0aWQD\\/SIG=1696d85k0\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.imdb.com\\/title\\/tt0032132\\/%26w=132%26d=OnC3HUaqMw5H%26icp=1%26.intl=us","Size":"44616"}},{"Title":"XM Radio - C-SPAN Radio","Summary":"... XM 132. <Previous. Next ...","Url":"http:\\/\\/www.xmradio.com\\/programming\\/channel_page.jsp?ch=132","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBfB7dmMwF;_ylu=X3oDMTEwa3RyODBuBGNvbG8DdwRsA1dTMQRwb3MDODYEc2VjA3NyBHZ0aWQD\\/SIG=12gtfnvt7\\/EXP=1147592336\\/**http%3a\\/\\/www.xmradio.com\\/programming\\/channel_page.jsp%3fch=132","ModificationDate":1147158000,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBgR7dmMwF;_ylu=X3oDMTBxN24xYzc0BGNvbG8DdwRwb3MDODYEc2VjA3NyBHZ0aWQD\\/SIG=1774en6i4\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.xmradio.com\\/programming\\/channel_page.jsp%253Fch%253D132%26w=132%26d=WS_5a0aqMwE5%26icp=1%26.intl=us","Size":"23601"}},{"Title":"Al-Qaeda tape says bin Laden alive, urges Iraqis to fight - theage.com.au","Summary":"Arabic television channel Al Arabiya has aired what it says is an audiotape from an al-Qaeda spokesman who says Osama bin Laden is alive and well. - The Age","Url":"http:\\/\\/www.theage.com.au\\/articles\\/2003\\/08\\/18\\/1061059775995.html","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBgx7dmMwF;_ylu=X3oDMTEwNXU4aDFlBGNvbG8DdwRsA1dTMQRwb3MDODcEc2VjA3NyBHZ0aWQD\\/SIG=12jscc3ng\\/EXP=1147592336\\/**http%3a\\/\\/www.theage.com.au\\/articles\\/2003\\/08\\/18\\/1061059775995.html","ModificationDate":1147158000,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBiB7dmMwF;_ylu=X3oDMTBxZjFrNnYwBGNvbG8DdwRwb3MDODcEc2VjA3NyBHZ0aWQD\\/SIG=174fs4fo6\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.theage.com.au\\/articles\\/2003\\/08\\/18\\/1061059775995.html%26w=132%26d=VUVD3UaqMwJD%26icp=1%26.intl=us","Size":"25163"}},{"Title":"Psalms 132","Summary":"Psalms 132. 132:1. Lord, remember David, and all his afflictions: 132:2. How he sware unto the LORD, and vowed unto the mighty God of Jacob; 132:3 ... Psalms 132. Chapters: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ... 132:3. Surely I will not come into the tabernacle of my ...","Url":"http:\\/\\/www.maitreg.com\\/bible\\/view.asp?book=38&chapter=132","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBih7dmMwF;_ylu=X3oDMTEwZjVxcHI4BGNvbG8DdwRsA1dTMQRwb3MDODgEc2VjA3NyBHZ0aWQD\\/SIG=12hild8td\\/EXP=1147592336\\/**http%3a\\/\\/www.maitreg.com\\/bible\\/view.asp%3fbook=38%26chapter=132","ModificationDate":1117609200,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBjx7dmMwF;_ylu=X3oDMTBxb2JpMW5pBGNvbG8DdwRwb3MDODgEc2VjA3NyBHZ0aWQD\\/SIG=17elhve1h\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.maitreg.com\\/bible\\/view.asp%253Fbook%253D38%2526chapter%253D132%26w=132%26d=TMHn-UaqMjbU%26icp=1%26.intl=us","Size":"27216"}},{"Title":"132","Summary":"35 U.S.C. 132 Notice of rejection; reexamination. - Patent Laws. 35 U.S.C. 132 Notice of rejection; reexamination.","Url":"http:\\/\\/www.uspto.gov\\/web\\/offices\\/pac\\/mpep\\/documents\\/appxl_35_U_S_C_132.htm","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBkR7dmMwF;_ylu=X3oDMTEwNTA2aTh1BGNvbG8DdwRsA1dTMQRwb3MDODkEc2VjA3NyBHZ0aWQD\\/SIG=12ucmimjn\\/EXP=1147592336\\/**http%3a\\/\\/www.uspto.gov\\/web\\/offices\\/pac\\/mpep\\/documents\\/appxl_35_U_S_C_132.htm","ModificationDate":1133942400,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBlh7dmMwF;_ylu=X3oDMTBxNmVndjYxBGNvbG8DdwRwb3MDODkEc2VjA3NyBHZ0aWQD\\/SIG=17f2jjpsh\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.uspto.gov\\/web\\/offices\\/pac\\/mpep\\/documents\\/appxl_35_U_S_C_132.htm%26w=132%26d=Nil-N0aqMjBx%26icp=1%26.intl=us","Size":"8182"}},{"Title":"A CONCISE SUMMARY OF THE PUBLIC HEARINGS","Summary":"... hearing on Bill 132. It shows you who was for, who was ... Opposes BSL, pointed out many anomalies in Bill 132, for example you can\'t teach a pit bull to ...","Url":"http:\\/\\/www.dogwatch.net\\/bill132.pdf","ClickUrl":"http:\\/\\/www.dogwatch.net\\/bill132.pdf#search=\'\'","ModificationDate":1109232000,"MimeType":"application\\/pdf","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBmx7dmMwF;_ylu=X3oDMTBxZ2gwNnM2BGNvbG8DdwRwb3MDOTAEc2VjA3NyBHZ0aWQD\\/SIG=168j23ta7\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.dogwatch.net\\/bill132.pdf%26w=132%26d=PkjRQEaqMuwO%26icp=1%26.intl=us","Size":"1982792"}},{"Title":"JPL News -- A Galaxy Far, Far Away Eyed by Linked Hawaiian Telescopes","Summary":"... Keck Observatory, Kamuela, Hawaii. 2003-132. Site Manager: Webmasters ...","Url":"http:\\/\\/www.jpl.nasa.gov\\/releases\\/2003\\/132.cfm","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBnR7dmMwF;_ylu=X3oDMTEwaTAxcXV0BGNvbG8DdwRsA1dTMQRwb3MDOTEEc2VjA3NyBHZ0aWQD\\/SIG=12170u1vu\\/EXP=1147592336\\/**http%3a\\/\\/www.jpl.nasa.gov\\/releases\\/2003\\/132.cfm","ModificationDate":1136016000,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBoh7dmMwF;_ylu=X3oDMTBxanNkbHBvBGNvbG8DdwRwb3MDOTEEc2VjA3NyBHZ0aWQD\\/SIG=16i2p31tn\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.jpl.nasa.gov\\/releases\\/2003\\/132.cfm%26w=132%26d=VNPrSUaqMkiG%26icp=1%26.intl=us","Size":"22198"}},{"Title":"(132) Justinian I","Summary":"(132) Justinian I - AV solidus, A.D. 527-545, 4.45 g. ( inv. 91.270). Obverse: Facing helmeted and cuirassed bust of Justinian, holding globus cruciger in r.; at l.","Url":"http:\\/\\/www.lawrence.edu\\/dept\\/art\\/buerger\\/catalogue\\/132.html","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBpB7dmMwF;_ylu=X3oDMTEwamM1Y3A2BGNvbG8DdwRsA1dTMQRwb3MDOTIEc2VjA3NyBHZ0aWQD\\/SIG=12f6r1r1h\\/EXP=1147592336\\/**http%3a\\/\\/www.lawrence.edu\\/dept\\/art\\/buerger\\/catalogue\\/132.html","ModificationDate":1006848000,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBqR7dmMwF;_ylu=X3oDMTBxZWNpdmpnBGNvbG8DdwRwb3MDOTIEc2VjA3NyBHZ0aWQD\\/SIG=1709bh559\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.lawrence.edu\\/dept\\/art\\/buerger\\/catalogue\\/132.html%26w=132%26d=BJJDnkaqMjfk%26icp=1%26.intl=us","Size":"3186"}},{"Title":"131","Summary":"35 U.S.C. 131 Examination of application. - Patent Laws. 35 U.S.C. 131 Examination of application.","Url":"http:\\/\\/www.uspto.gov\\/web\\/offices\\/pac\\/mpep\\/documents\\/appxl_35_U_S_C_131.htm","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBqx7dmMwF;_ylu=X3oDMTEwdDUzZHBhBGNvbG8DdwRsA1dTMQRwb3MDOTMEc2VjA3NyBHZ0aWQD\\/SIG=12u6cdfcn\\/EXP=1147592336\\/**http%3a\\/\\/www.uspto.gov\\/web\\/offices\\/pac\\/mpep\\/documents\\/appxl_35_U_S_C_131.htm","ModificationDate":1133942400,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBsB7dmMwF;_ylu=X3oDMTBxdXZhZWxkBGNvbG8DdwRwb3MDOTMEc2VjA3NyBHZ0aWQD\\/SIG=17f8j8d98\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.uspto.gov\\/web\\/offices\\/pac\\/mpep\\/documents\\/appxl_35_U_S_C_131.htm%26w=132%26d=R2aGhUaqMj30%26icp=1%26.intl=us","Size":"7341"}},{"Title":"132 on Flickr - Photo Sharing!","Summary":"... 132. To take full advantage of Flickr, you should use a JavaScript-enabled browser and ...","Url":"http:\\/\\/www.flickr.com\\/photos\\/brettsky\\/53839790\\/","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBsh7dmMwF;_ylu=X3oDMTEwZ2lxZDhhBGNvbG8DdwRsA1dTMQRwb3MDOTQEc2VjA3NyBHZ0aWQD\\/SIG=123ojcbf0\\/EXP=1147592336\\/**http%3a\\/\\/www.flickr.com\\/photos\\/brettsky\\/53839790\\/","ModificationDate":1145862000,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBtx7dmMwF;_ylu=X3oDMTBxYTJvNGFhBGNvbG8DdwRwb3MDOTQEc2VjA3NyBHZ0aWQD\\/SIG=16ks6e563\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.flickr.com\\/photos\\/brettsky\\/53839790\\/%26w=132%26d=GA_4oEaqMq4P%26icp=1%26.intl=us","Size":"74392"}},{"Title":"Ag GPS 124 \\/ 132","Summary":"AgGPS 124 \\/ 132. Operation Manual. AgGPS Receiver Firmware Version 1.40, 1.41 and 1.42. Part Number 38747-00-ENG. Revision C. September 2000. T. Support Offices. Trimble Precision Agricultural Systems. 9290 Bond Street, Suite 102. Overland Park, KS 66214 U.S.A. ... describes how to install and configure the AgGPS_ 124, 132, and 132. Air receivers ...","Url":"http:\\/\\/www.linco.com\\/AG124132REVB.PDF","ClickUrl":"http:\\/\\/www.linco.com\\/AG124132REVB.PDF#search=\'\'","ModificationDate":986281200,"MimeType":"application\\/pdf","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBvB7dmMwF;_ylu=X3oDMTBxbDgxOWxkBGNvbG8DdwRwb3MDOTUEc2VjA3NyBHZ0aWQD\\/SIG=16ajtq3hk\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.linco.com\\/AG124132REVB.PDF%26w=132%26d=FCohUkaqMjOV%26icp=1%26.intl=us","Size":"3610097"}},{"Title":"Tehillim - Chapter 132 | Chabad.org","Summary":"Please login for more site features. Tehillim - Chapter 132. 1. A song of ascents. Remember, O Lord, onto David all his affliction. 2. That he swore to the Lord, he vowed to the Mighty One of Jacob; ... Chabad.org \\" Library \\" Classic Texts \\" The Bible (with Rashi) \\" K\'tuvim \\" Tehillim \\" Chapter 132 ...","Url":"http:\\/\\/www.chabad.org\\/library\\/article.asp?AID=16353","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBvh7dmMwF;_ylu=X3oDMTEwam44NW9vBGNvbG8DdwRsA1dTMQRwb3MDOTYEc2VjA3NyBHZ0aWQD\\/SIG=129b821nj\\/EXP=1147592336\\/**http%3a\\/\\/www.chabad.org\\/library\\/article.asp%3fAID=16353","ModificationDate":1146898800,"MimeType":"text\\/html","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBwx7dmMwF;_ylu=X3oDMTBxczRxYWlqBGNvbG8DdwRwb3MDOTYEc2VjA3NyBHZ0aWQD\\/SIG=170gmib5a\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.chabad.org\\/library\\/article.asp%253FAID%253D16353%26w=132%26d=I-adaEaqMvld%26icp=1%26.intl=us","Size":"41051"}},{"Title":"Downloaded 19 Jan 2003 to 132.77.4.43. Redistribution subject to AIP license or copyright, see http:\\/\\/ojps.aip.org\\/... ","Summary":"Downloaded 19 Jan 2003 to 132.77.4.43. Redistribution subject to AIP license or copyright, see http:\\/\\/ojps.aip.org\\/jcpo\\/jcpcr.jsp. Downloaded 19 Jan 2003 to 132.77.4.43.","Url":"http:\\/\\/www.weizmann.ac.il\\/chemphys\\/Frydman_group\\/Publications\\/ExchDynamics-JCP90.pdf","ClickUrl":"http:\\/\\/www.weizmann.ac.il\\/chemphys\\/Frydman_group\\/Publications\\/ExchDynamics-JCP90.pdf#search=\'\'","ModificationDate":1061622000,"MimeType":"application\\/pdf","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcByB7dmMwF;_ylu=X3oDMTBxZGVwcTFiBGNvbG8DdwRwb3MDOTcEc2VjA3NyBHZ0aWQD\\/SIG=17p1893is\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.weizmann.ac.il\\/chemphys\\/Frydman_group\\/Publications\\/ExchDynamics-JCP90.pdf%26w=132%26d=KPVdS0aqMkW1%26icp=1%26.intl=us","Size":"816603"}},{"Title":"Downloaded 19 May 2003 to 132.77.4.43. Redistribution subject to AIP license or copyright, see http:\\/\\/ojps.aip.org\\/... ","Summary":"Downloaded 19 May 2003 to 132.77.4.43. Redistribution subject to AIP license or copyright, see http:\\/\\/ojps.aip.org\\/japo\\/japcr.jsp. Downloaded 19 May 2003 to 132.77.4.43.","Url":"http:\\/\\/www.weizmann.ac.il\\/wagner\\/COURSES\\/Reading%20material%20(papers)\\/030_JAP_1990_ContactAngle.pdf","ClickUrl":"http:\\/\\/www.weizmann.ac.il\\/wagner\\/COURSES\\/Reading%20material%20(papers)\\/030_JAP_1990_ContactAngle.pdf#search=\'\'","ModificationDate":1136880000,"MimeType":"application\\/pdf","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcBzR7dmMwF;_ylu=X3oDMTBxMjBxZ2VoBGNvbG8DdwRwb3MDOTgEc2VjA3NyBHZ0aWQD\\/SIG=18pfdig62\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=www.weizmann.ac.il\\/wagner\\/COURSES\\/Reading%252520material%252520%2528papers%2529\\/030_JAP_1990_ContactAngle.pdf%26w=132%26d=Nf5MWEaqMkV0%26icp=1%26.intl=us","Size":"784314"}},{"Title":"Downloaded 24 Jul 2002 to 132.163.135.12. Redistribution subject to AIP license or copyright, see http:\\/\\/ojps.aip... ","Summary":"Downloaded 24 Jul 2002 to 132.163.135.12. Redistribution subject to AIP license or copyright, see http:\\/\\/ojps.aip.org\\/japo\\/japcr.jsp. Downloaded 24 Jul 2002 to 132.163.135.12.","Url":"http:\\/\\/tf.nist.gov\\/general\\/pdf\\/569.pdf","ClickUrl":"http:\\/\\/tf.nist.gov\\/general\\/pdf\\/569.pdf#search=\'\'","ModificationDate":1027494000,"MimeType":"application\\/pdf","Cache":{"Url":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcB0h7dmMwF;_ylu=X3oDMTBxNmJhcjNhBGNvbG8DdwRwb3MDOTkEc2VjA3NyBHZ0aWQD\\/SIG=16b31en6n\\/EXP=1147592336\\/**http%3a\\/\\/66.218.69.11\\/search\\/cache%3fei=UTF-8%26query=132%26output=json%26results=100%26appid=jennyhan_ac%26u=tf.nist.gov\\/general\\/pdf\\/569.pdf%26w=132%26d=IpdTwEaqMirR%26icp=1%26.intl=us","Size":"1002734"}},{"Title":"[DB] naruto 132","Summary":"","Url":"http:\\/\\/yhbt.mine.nu\\/t\\/n132.torrent","ClickUrl":"http:\\/\\/uk.wrs.yahoo.com\\/_ylt=A0Je5VwQjWVEsGcB1B7dmMwF;_ylu=X3oDMTExaW11dG45BGNvbG8DdwRsA1dTMQRwb3MDMTAwBHNlYwNzcgR2dGlkAw--\\/SIG=11m58k4sj\\/EXP=1147592336\\/**http%3a\\/\\/yhbt.mine.nu\\/t\\/n132.torrent","ModificationDate":1114671600,"MimeType":"unknown"}]}}'); + + assertEquals(result.groupCount + 1, 5); +} diff --git a/tests/corelib/regexp/standalones_test.dart b/tests/corelib/regexp/standalones_test.dart new file mode 100644 index 00000000000..bdc048122d9 --- /dev/null +++ b/tests/corelib/regexp/standalones_test.dart @@ -0,0 +1,84 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2008 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + /* Many of the Mozilla regexp tests used 'toSource' to test their + * results. Since we don't currently support toSource, those tests + * are disabled and standalone versions are included here. + */ + + // Tests from ecma_3/RegExp/regress-78156.js + var string = 'aaa\n789\r\nccc\r\n345'; + var pattern = new RegExp(r"^\d", multiLine: true); + var result = pattern.allMatches(string).toList(); + assertEquals(2, result.length, "1"); + assertEquals('7', result[0].group(0), "2"); + assertEquals('3', result[1].group(0), "3"); + + pattern = new RegExp(r"\d$", multiLine: true); + result = pattern.allMatches(string).toList(); + assertEquals(2, result.length, "4"); + assertEquals('9', result[0].group(0), "5"); + assertEquals('5', result[1].group(0), "6"); + + string = 'aaa\n789\r\nccc\r\nddd'; + pattern = new RegExp(r"^\d", multiLine: true); + result = pattern.allMatches(string).toList(); + assertEquals(1, result.length, "7"); + assertEquals('7', result[0].group(0), "8"); + + pattern = new RegExp(r"\d$", multiLine: true); + result = pattern.allMatches(string).toList(); + assertEquals(1, result.length, "9"); + assertEquals('9', result[0].group(0), "10"); + + // Tests from ecma_3/RegExp/regress-72964.js + pattern = new RegExp(r"[\S]+"); + string = '\u00BF\u00CD\u00BB\u00A7'; + result = pattern.firstMatch(string); + assertEquals(1, result.groupCount + 1, "11"); + assertEquals(string, result.group(0), "12"); + + string = '\u00BF\u00CD \u00BB\u00A7'; + result = pattern.firstMatch(string); + assertEquals(1, result.groupCount + 1, "13"); + assertEquals('\u00BF\u00CD', result.group(0), "14"); + + string = '\u4e00\uac00\u4e03\u4e00'; + result = pattern.firstMatch(string); + assertEquals(1, result.groupCount + 1, "15"); + assertEquals(string, result.group(0), "16"); + + string = '\u4e00\uac00 \u4e03\u4e00'; + result = pattern.firstMatch(string); + assertEquals(1, result.groupCount + 1, "17"); + assertEquals('\u4e00\uac00', result.group(0), "18"); +} diff --git a/tests/corelib/regexp/toString_test.dart b/tests/corelib/regexp/toString_test.dart new file mode 100644 index 00000000000..7664881ca78 --- /dev/null +++ b/tests/corelib/regexp/toString_test.dart @@ -0,0 +1,68 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + dynamic testForwardSlash(pattern, _string) { + var string = _string; + + var re1 = new RegExp(pattern); + + return re1.hasMatch(string); + } + + dynamic testLineTerminator(pattern) { + var re1 = new RegExp(pattern); + + return new RegExp(r"\n|\r|\u2028|\u2029").hasMatch(re1.toString()); + } + + // These strings are equivalent, since the '\' is identity escaping the '/' at the string level. + shouldBeTrue(testForwardSlash("^/\$", "/")); + shouldBeTrue(testForwardSlash("^\/\$", "/")); + // This string passes "^\/$" to the RegExp, so the '/' is escaped in the re! + shouldBeTrue(testForwardSlash("^\\/\$", "/")); + // These strings pass "^\\/$" and "^\\\/$" respectively to the RegExp, giving one '\' to match. + shouldBeTrue(testForwardSlash("^\\\\/\$", "\\/")); + shouldBeTrue(testForwardSlash("^\\\\\\/\$", "\\/")); + // These strings match two backslashes (the second with the '/' escaped). + shouldBeTrue(testForwardSlash("^\\\\\\\\/\$", "\\\\/")); + shouldBeTrue(testForwardSlash("^\\\\\\\\\\/\$", "\\\\/")); + // Test that nothing goes wrongif there are multiple forward slashes! + shouldBeTrue(testForwardSlash("x/x/x", "x/x/x")); + shouldBeTrue(testForwardSlash("x\\/x/x", "x/x/x")); + shouldBeTrue(testForwardSlash("x/x\\/x", "x/x/x")); + shouldBeTrue(testForwardSlash("x\\/x\\/x", "x/x/x")); + + shouldBeFalse(testLineTerminator("\\n")); + shouldBeFalse(testLineTerminator("\\\\n")); + shouldBeFalse(testLineTerminator("\\r")); + shouldBeFalse(testLineTerminator("\\\\r")); + shouldBeFalse(testLineTerminator("\\u2028")); + shouldBeFalse(testLineTerminator("\\\\u2028")); + shouldBeFalse(testLineTerminator("\\u2029")); + shouldBeFalse(testLineTerminator("\\\\u2029")); +} diff --git a/tests/corelib/regexp/unicode-handling_test.dart b/tests/corelib/regexp/unicode-handling_test.dart new file mode 100644 index 00000000000..01685ec72c6 --- /dev/null +++ b/tests/corelib/regexp/unicode-handling_test.dart @@ -0,0 +1,75 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + description( + 'Test for proper handling of Unicode RegExps and bug 7445: Gmail puts wrong subject in replies.'); + + // Regex to match Re in various languages straight from Gmail source + var I3 = new RegExp( + r"^\s*(fwd|re|aw|antw|antwort|wg|sv|ang|odp|betreff|betr|transf|reenv\.|reenv|in|res|resp|resp\.|enc|\u8f6c\u53d1|\u56DE\u590D|\u041F\u0435\u0440\u0435\u0441\u043B|\u041E\u0442\u0432\u0435\u0442):\s*(.*)$", + caseSensitive: false); + + // Other RegExs from Gmail source + var Ci = new RegExp(r"\s+"); + var BC = new RegExp(r"^ "); + var BG = new RegExp(r" $"); + + // This function replaces consecutive whitespace with a single space + // then removes a leading and trailing space if they exist. (From Gmail) + dynamic Gn(a) { + return a.replaceAll(Ci, " ").replaceAll(BC, "").replaceAll(BG, ""); + } + + // Strips leading Re or similar (from Gmail source) + dynamic cy(a) { + //var b = I3.firstMatch(a); + var b = I3.firstMatch(a); + + if (b != null) { + a = b.group(2); + } + + return Gn(a); + } + + assertEquals(cy('Re: Moose'), 'Moose'); + assertEquals(cy('\u8f6c\u53d1: Moose'), 'Moose'); + + // Test handling of \u2820 (skull and crossbones) + var sample = "sample bm\u2820p cm\\u2820p"; + + var inlineRe = new RegExp(r".m\u2820p"); + assertEquals(inlineRe.firstMatch(sample).group(0), 'bm\u2820p'); + + // Test handling of \u007c "|" + var bsample = "sample bm\u007cp cm\\u007cp"; + + var binlineRe = new RegExp(r".m\u007cp"); + + assertEquals(binlineRe.firstMatch(bsample).group(0), 'bm|p'); +} diff --git a/tests/corelib/regexp/unicodeCaseInsensitive_test.dart b/tests/corelib/regexp/unicodeCaseInsensitive_test.dart new file mode 100644 index 00000000000..a4c985bde70 --- /dev/null +++ b/tests/corelib/regexp/unicodeCaseInsensitive_test.dart @@ -0,0 +1,108 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + shouldBeTrue( + new RegExp(r"ΣΤΙΓΜΑΣ", caseSensitive: false).hasMatch("στιγμας")); + shouldBeTrue(new RegExp(r"ΔΣΔ", caseSensitive: false).hasMatch("δςδ")); + shouldBeTrue(new RegExp(r"ς", caseSensitive: false).hasMatch("σ")); + shouldBeTrue(new RegExp(r"σ", caseSensitive: false).hasMatch("ς")); + + // Simple case, has no canonical equivalents + shouldBeTrue(new RegExp(r"\u1f16", caseSensitive: false).hasMatch("\u1f16")); + + // Test the sets of USC2 code points that have more than one canonically equivalent value. + dynamic ucs2CodePoint(x) => new String.fromCharCode(x); + dynamic testSet(s) { + for (var i in s) { + for (var j in s) { + shouldBeTrue(new RegExp(ucs2CodePoint(i), caseSensitive: false) + .hasMatch(ucs2CodePoint(j))); + shouldBeTrue(new RegExp( + "[${ucs2CodePoint(i - 1)}-${ucs2CodePoint(i + 1)}]", + caseSensitive: false) + .hasMatch(ucs2CodePoint(j))); + } + } + } + + testSet([0x01c4, 0x01c5, 0x01c6]); + testSet([0x01c7, 0x01c8, 0x01c9]); + testSet([0x01ca, 0x01cb, 0x01cc]); + testSet([0x01f1, 0x01f2, 0x01f3]); + testSet([0x0392, 0x03b2, 0x03d0]); + testSet([0x0395, 0x03b5, 0x03f5]); + testSet([0x0398, 0x03b8, 0x03d1]); + testSet([0x0345, 0x0399, 0x03b9, 0x1fbe]); + testSet([0x039a, 0x03ba, 0x03f0]); + testSet([0x00b5, 0x039c, 0x03bc]); + testSet([0x03a0, 0x03c0, 0x03d6]); + testSet([0x03a1, 0x03c1, 0x03f1]); + testSet([0x03a3, 0x03c2, 0x03c3]); + testSet([0x03a6, 0x03c6, 0x03d5]); + testSet([0x1e60, 0x1e61, 0x1e9b]); + + // Test a couple of lo/hi pairs + shouldBeTrue(new RegExp(r"\u03cf", caseSensitive: false).hasMatch("\u03cf")); + shouldBeTrue(new RegExp(r"\u03d7", caseSensitive: false).hasMatch("\u03cf")); + shouldBeTrue(new RegExp(r"\u03cf", caseSensitive: false).hasMatch("\u03d7")); + shouldBeTrue(new RegExp(r"\u03d7", caseSensitive: false).hasMatch("\u03d7")); + shouldBeTrue(new RegExp(r"\u1f11", caseSensitive: false).hasMatch("\u1f11")); + shouldBeTrue(new RegExp(r"\u1f19", caseSensitive: false).hasMatch("\u1f11")); + shouldBeTrue(new RegExp(r"\u1f11", caseSensitive: false).hasMatch("\u1f19")); + shouldBeTrue(new RegExp(r"\u1f19", caseSensitive: false).hasMatch("\u1f19")); + + // Test an aligned alternating capitalization pair. + shouldBeFalse(new RegExp(r"\u0489", caseSensitive: false).hasMatch("\u048a")); + shouldBeTrue(new RegExp(r"\u048a", caseSensitive: false).hasMatch("\u048a")); + shouldBeTrue(new RegExp(r"\u048b", caseSensitive: false).hasMatch("\u048a")); + shouldBeFalse(new RegExp(r"\u048c", caseSensitive: false).hasMatch("\u048a")); + shouldBeFalse(new RegExp(r"\u0489", caseSensitive: false).hasMatch("\u048b")); + shouldBeTrue(new RegExp(r"\u048a", caseSensitive: false).hasMatch("\u048b")); + shouldBeTrue(new RegExp(r"\u048b", caseSensitive: false).hasMatch("\u048b")); + shouldBeFalse(new RegExp(r"\u048c", caseSensitive: false).hasMatch("\u048b")); + shouldBeTrue( + new RegExp(r"[\u0489-\u048a]", caseSensitive: false).hasMatch("\u048b")); + shouldBeTrue( + new RegExp(r"[\u048b-\u048c]", caseSensitive: false).hasMatch("\u048a")); + + // Test an unaligned alternating capitalization pair. + shouldBeFalse(new RegExp(r"\u04c4", caseSensitive: false).hasMatch("\u04c5")); + shouldBeTrue(new RegExp(r"\u04c5", caseSensitive: false).hasMatch("\u04c5")); + shouldBeTrue(new RegExp(r"\u04c6", caseSensitive: false).hasMatch("\u04c5")); + shouldBeFalse(new RegExp(r"\u04c7", caseSensitive: false).hasMatch("\u04c5")); + shouldBeFalse(new RegExp(r"\u04c4", caseSensitive: false).hasMatch("\u04c6")); + shouldBeTrue(new RegExp(r"\u04c5", caseSensitive: false).hasMatch("\u04c6")); + shouldBeTrue(new RegExp(r"\u04c6", caseSensitive: false).hasMatch("\u04c6")); + shouldBeFalse(new RegExp(r"\u04c7", caseSensitive: false).hasMatch("\u04c6")); + shouldBeTrue( + new RegExp(r"[\u04c4-\u04c5]", caseSensitive: false).hasMatch("\u04c6")); + shouldBeTrue( + new RegExp(r"[\u04c6-\u04c7]", caseSensitive: false).hasMatch("\u04c5")); + + var successfullyParsed = true; +} diff --git a/tests/corelib/regexp/v8_regexp_utils.dart b/tests/corelib/regexp/v8_regexp_utils.dart new file mode 100644 index 00000000000..cde750a7294 --- /dev/null +++ b/tests/corelib/regexp/v8_regexp_utils.dart @@ -0,0 +1,65 @@ +// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// Utility functions to easily port V8 tests. + +import "package:expect/expect.dart"; + +void assertEquals(actual, expected, [String message = null]) { + Expect.equals(actual, expected, message); +} + +void assertTrue(actual, [String message = null]) { + Expect.isTrue(actual, message); +} + +void assertFalse(actual, [String message = null]) { + Expect.isFalse(actual, message); +} + +void assertThrows(fn, [num testid = null]) { + Expect.throws(fn, null, "Test $testid"); +} + +void assertNull(actual, [num testid = null]) { + Expect.isNull(actual, "Test $testid"); +} + +void assertToStringEquals(str, match, num testid) { + var actual = []; + for (int i = 0; i <= match.groupCount; i++) { + var g = match.group(i); + actual.add((g == null) ? "" : g); + } + Expect.equals(str, actual.join(","), "Test $testid"); +} + +void shouldBeTrue(actual) { + Expect.isTrue(actual); +} + +void shouldBeFalse(actual) { + Expect.isFalse(actual); +} + +void shouldBeNull(actual) { + Expect.isNull(actual); +} + +void shouldBe(actual, expected, [String message = null]) { + if (expected == null) { + Expect.isNull(actual, message); + } else { + Expect.equals(expected.length, actual.groupCount + 1); + for (int i = 0; i <= actual.groupCount; i++) { + Expect.equals(expected[i], actual.group(i), message); + } + } +} + +Match firstMatch(String str, RegExp pattern) => pattern.firstMatch(str); +List allStringMatches(String str, RegExp pattern) => + pattern.allMatches(str).map((Match m) => m.group(0)).toList(); + +void description(str) {} diff --git a/tests/corelib/regexp/zero-length-alternatives_test.dart b/tests/corelib/regexp/zero-length-alternatives_test.dart new file mode 100644 index 00000000000..108b513af94 --- /dev/null +++ b/tests/corelib/regexp/zero-length-alternatives_test.dart @@ -0,0 +1,279 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + description( + 'Test regular expression processing with alternatives that match consuming no characters'); + + var emptyStr = ""; + var s1 = "xxxx"; + var s2 = "aaaa"; + var s3 = "aax"; + var s4 = "abab"; + var s5 = "ab"; + var s6 = "xabx"; + var s7 = "g0"; + + // Non-capturing empty first alternative greedy '*' + var re1 = new RegExp(r"(?:|a|z)*"); + shouldBe(firstMatch(emptyStr, re1), [""]); + shouldBe(firstMatch(s1, re1), [""]); + shouldBe(firstMatch(s2, re1), ["aaaa"]); + shouldBe(firstMatch(s3, re1), ["aa"]); + + // Non-capturing empty middle alternative greedy '*' + var re2 = new RegExp(r"(?:a||z)*"); + shouldBe(firstMatch(emptyStr, re2), [""]); + shouldBe(firstMatch(s1, re2), [""]); + shouldBe(firstMatch(s2, re2), ["aaaa"]); + shouldBe(firstMatch(s3, re2), ["aa"]); + + // Non-capturing empty last alternative greedy '*' + var re3 = new RegExp(r"(?:a|z|)*"); + shouldBe(firstMatch(emptyStr, re3), [""]); + shouldBe(firstMatch(s1, re3), [""]); + shouldBe(firstMatch(s2, re3), ["aaaa"]); + shouldBe(firstMatch(s3, re3), ["aa"]); + + // Capturing empty first alternative greedy '*' + var re4 = new RegExp(r"(|a|z)*"); + shouldBe(firstMatch(emptyStr, re4), ["", null]); + shouldBe(firstMatch(s1, re4), ["", null]); + shouldBe(firstMatch(s2, re4), ["aaaa", "a"]); + shouldBe(firstMatch(s3, re4), ["aa", "a"]); + + // Capturing empty middle alternative greedy '*' + var re5 = new RegExp(r"(a||z)*"); + shouldBe(firstMatch(emptyStr, re5), ["", null]); + shouldBe(firstMatch(s1, re5), ["", null]); + shouldBe(firstMatch(s2, re5), ["aaaa", "a"]); + shouldBe(firstMatch(s3, re5), ["aa", "a"]); + + // Capturing empty last alternative greedy '*' + var re6 = new RegExp(r"(a|z|)*"); + shouldBe(firstMatch(emptyStr, re6), ["", null]); + shouldBe(firstMatch(s1, re6), ["", null]); + shouldBe(firstMatch(s2, re6), ["aaaa", "a"]); + shouldBe(firstMatch(s3, re6), ["aa", "a"]); + + // Non-capturing empty first alternative fixed-count + var re7 = new RegExp(r"(?:|a|z){2,5}"); + shouldBe(firstMatch(emptyStr, re7), [""]); + shouldBe(firstMatch(s1, re7), [""]); + shouldBe(firstMatch(s2, re7), ["aaa"]); + shouldBe(firstMatch(s3, re7), ["aa"]); + + // Non-capturing empty middle alternative fixed-count + var re8 = new RegExp(r"(?:a||z){2,5}"); + shouldBe(firstMatch(emptyStr, re8), [""]); + shouldBe(firstMatch(s1, re8), [""]); + shouldBe(firstMatch(s2, re8), ["aaaa"]); + shouldBe(firstMatch(s3, re8), ["aa"]); + + // Non-capturing empty last alternative fixed-count + var re9 = new RegExp(r"(?:a|z|){2,5}"); + shouldBe(firstMatch(emptyStr, re9), [""]); + shouldBe(firstMatch(s1, re9), [""]); + shouldBe(firstMatch(s2, re9), ["aaaa"]); + shouldBe(firstMatch(s3, re9), ["aa"]); + + // Non-capturing empty first alternative non-greedy '*' + var re10 = new RegExp(r"(?:|a|z)*?"); + shouldBe(firstMatch(emptyStr, re10), [""]); + shouldBe(firstMatch(s1, re10), [""]); + shouldBe(firstMatch(s2, re10), [""]); + shouldBe(firstMatch(s3, re10), [""]); + + // Non-capturing empty middle alternative non-greedy '*' + var re11 = new RegExp(r"(?:a||z)*?"); + shouldBe(firstMatch(emptyStr, re11), [""]); + shouldBe(firstMatch(s1, re11), [""]); + shouldBe(firstMatch(s2, re11), [""]); + shouldBe(firstMatch(s3, re11), [""]); + + // Non-capturing empty last alternative non-greedy '*' + var re12 = new RegExp(r"(?:a|z|)*?"); + shouldBe(firstMatch(emptyStr, re12), [""]); + shouldBe(firstMatch(s1, re12), [""]); + shouldBe(firstMatch(s2, re12), [""]); + shouldBe(firstMatch(s3, re12), [""]); + + // Capturing empty first alternative non-greedy '*' + var re13 = new RegExp(r"(|a|z)*?"); + shouldBe(firstMatch(emptyStr, re13), ["", null]); + shouldBe(firstMatch(s1, re13), ["", null]); + shouldBe(firstMatch(s2, re13), ["", null]); + shouldBe(firstMatch(s3, re13), ["", null]); + + // Capturing empty middle alternative non-greedy '*' + var re14 = new RegExp(r"(a||z)*?"); + shouldBe(firstMatch(emptyStr, re14), ["", null]); + shouldBe(firstMatch(s1, re14), ["", null]); + shouldBe(firstMatch(s2, re14), ["", null]); + shouldBe(firstMatch(s3, re14), ["", null]); + + // Capturing empty last alternative non-greedy '*' + var re15 = new RegExp(r"(a|z|)*?"); + shouldBe(firstMatch(emptyStr, re15), ["", null]); + shouldBe(firstMatch(s1, re15), ["", null]); + shouldBe(firstMatch(s2, re15), ["", null]); + shouldBe(firstMatch(s3, re15), ["", null]); + + // Non-capturing empty first alternative greedy '?' + var re16 = new RegExp(r"(?:|a|z)?"); + shouldBe(firstMatch(emptyStr, re16), [""]); + shouldBe(firstMatch(s1, re16), [""]); + shouldBe(firstMatch(s2, re16), ["a"]); + shouldBe(firstMatch(s3, re16), ["a"]); + + // Non-capturing empty middle alternative greedy '?' + var re17 = new RegExp(r"(?:a||z)?"); + shouldBe(firstMatch(emptyStr, re17), [""]); + shouldBe(firstMatch(s1, re17), [""]); + shouldBe(firstMatch(s2, re17), ["a"]); + shouldBe(firstMatch(s3, re17), ["a"]); + + // Non-capturing empty last alternative greedy '?' + var re18 = new RegExp(r"(?:a|z|)?"); + shouldBe(firstMatch(emptyStr, re18), [""]); + shouldBe(firstMatch(s1, re18), [""]); + shouldBe(firstMatch(s2, re18), ["a"]); + shouldBe(firstMatch(s3, re18), ["a"]); + + // Capturing empty first alternative greedy '?' + var re19 = new RegExp(r"(|a|z)?"); + shouldBe(firstMatch(emptyStr, re19), ["", null]); + shouldBe(firstMatch(s1, re19), ["", null]); + shouldBe(firstMatch(s2, re19), ["a", "a"]); + shouldBe(firstMatch(s3, re19), ["a", "a"]); + + // Capturing empty middle alternative greedy '?' + var re20 = new RegExp(r"(a||z)?"); + shouldBe(firstMatch(emptyStr, re20), ["", null]); + shouldBe(firstMatch(s1, re20), ["", null]); + shouldBe(firstMatch(s2, re20), ["a", "a"]); + shouldBe(firstMatch(s3, re20), ["a", "a"]); + + // Capturing empty last alternative greedy '?' + var re21 = new RegExp(r"(a|z|)?"); + shouldBe(firstMatch(emptyStr, re21), ["", null]); + shouldBe(firstMatch(s1, re21), ["", null]); + shouldBe(firstMatch(s2, re21), ["a", "a"]); + shouldBe(firstMatch(s3, re21), ["a", "a"]); + + // Non-capturing empty first alternative non-greedy '?' + var re22 = new RegExp(r"(?:|a|z)??"); + shouldBe(firstMatch(emptyStr, re22), [""]); + shouldBe(firstMatch(s1, re22), [""]); + shouldBe(firstMatch(s2, re22), [""]); + shouldBe(firstMatch(s3, re22), [""]); + + // Non-capturing empty middle alternative non-greedy '?' + var re23 = new RegExp(r"(?:a||z)??"); + shouldBe(firstMatch(emptyStr, re23), [""]); + shouldBe(firstMatch(s1, re23), [""]); + shouldBe(firstMatch(s2, re23), [""]); + shouldBe(firstMatch(s3, re23), [""]); + + // Non-capturing empty last alternative non-greedy '?' + var re24 = new RegExp(r"(?:a|z|)??"); + shouldBe(firstMatch(emptyStr, re24), [""]); + shouldBe(firstMatch(s1, re24), [""]); + shouldBe(firstMatch(s2, re24), [""]); + shouldBe(firstMatch(s3, re24), [""]); + + // Capturing empty first alternative non-greedy '?' + var re25 = new RegExp(r"(|a|z)??"); + shouldBe(firstMatch(emptyStr, re25), ["", null]); + shouldBe(firstMatch(s1, re25), ["", null]); + shouldBe(firstMatch(s2, re25), ["", null]); + shouldBe(firstMatch(s3, re25), ["", null]); + + // Capturing empty middle alternative non-greedy '?' + var re26 = new RegExp(r"(a||z)??"); + shouldBe(firstMatch(emptyStr, re26), ["", null]); + shouldBe(firstMatch(s1, re26), ["", null]); + shouldBe(firstMatch(s2, re26), ["", null]); + shouldBe(firstMatch(s3, re26), ["", null]); + + // Capturing empty last alternative non-greedy '?' + var re27 = new RegExp(r"(a|z|)??"); + shouldBe(firstMatch(emptyStr, re27), ["", null]); + shouldBe(firstMatch(s1, re27), ["", null]); + shouldBe(firstMatch(s2, re27), ["", null]); + shouldBe(firstMatch(s3, re27), ["", null]); + + // Non-capturing empty first alternative greedy '*' non-terminal + var re28 = new RegExp(r"(?:|a|z)*x"); + shouldBe(firstMatch(emptyStr, re28), null); + shouldBe(firstMatch(s1, re28), ["x"]); + shouldBe(firstMatch(s2, re28), null); + shouldBe(firstMatch(s3, re28), ["aax"]); + + // Non-capturing empty middle alternative greedy '*' non-terminal + var re29 = new RegExp(r"(?:a||z)*x"); + shouldBe(firstMatch(emptyStr, re29), null); + shouldBe(firstMatch(s1, re29), ["x"]); + shouldBe(firstMatch(s2, re29), null); + shouldBe(firstMatch(s3, re29), ["aax"]); + + // Non-capturing empty last alternative greedy '*' non-terminal + var re30 = new RegExp(r"(?:a|z|)*x"); + shouldBe(firstMatch(emptyStr, re30), null); + shouldBe(firstMatch(s1, re30), ["x"]); + shouldBe(firstMatch(s2, re30), null); + shouldBe(firstMatch(s3, re30), ["aax"]); + + // Non-capturing two possibly empty alternatives greedy '*' + var re31 = new RegExp(r"(?:a*|b*)*"); + shouldBe(firstMatch(emptyStr, re31), [""]); + shouldBe(firstMatch(s1, re31), [""]); + shouldBe(firstMatch(s3, re31), ["aa"]); + shouldBe(firstMatch(s4, re31), ["abab"]); + + // Non-capturing two possibly empty non-greedy alternatives non-greedy '*' + var re32 = new RegExp(r"(?:a*?|b*?)*"); + shouldBe(firstMatch(emptyStr, re32), [""]); + shouldBe(firstMatch(s1, re32), [""]); + shouldBe(firstMatch(s2, re32), ["aaaa"]); + shouldBe(firstMatch(s4, re32), ["abab"]); + shouldBe(firstMatch(s5, re32), ["ab"]); + shouldBe(firstMatch(s6, re32), [""]); + + // Three possibly empty alternatives with greedy + + var re33 = new RegExp(r"(?:(?:(?!))|g?|0*\*?)+"); + shouldBe(firstMatch(emptyStr, re33), [""]); + shouldBe(firstMatch(s1, re33), [""]); + shouldBe(firstMatch(s7, re33), ["g0"]); + + // first alternative zero length fixed count + var re34 = new RegExp(r"(?:|a)"); + shouldBe(firstMatch(emptyStr, re34), [""]); + shouldBe(firstMatch(s1, re34), [""]); + shouldBe(firstMatch(s2, re34), [""]); + shouldBe(firstMatch(s3, re34), [""]); +} diff --git a/tests/corelib/regress_11099_test.dart b/tests/corelib/regress_11099_test.dart new file mode 100644 index 00000000000..2e6b8c15952 --- /dev/null +++ b/tests/corelib/regress_11099_test.dart @@ -0,0 +1,16 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +void main() { + var l = [new MyTest(1), new MyTest(5), new MyTest(3)]; + l.sort(); + if (l.toString() != "[d{1}, d{3}, d{5}]") throw 'Wrong result!'; +} + +class MyTest implements Comparable { + final int a; + MyTest(this.a); + int compareTo(MyTest b) => this.a - b.a; + String toString() => "d{$a}"; +} diff --git a/tests/corelib/regress_r21715_test.dart b/tests/corelib/regress_r21715_test.dart new file mode 100644 index 00000000000..5a0ef73d936 --- /dev/null +++ b/tests/corelib/regress_r21715_test.dart @@ -0,0 +1,17 @@ +// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// VMOptions=--optimization_counter_threshold=5 --no-background_compilation + +import "package:expect/expect.dart"; + +sll(x, shift) => x << shift; + +main() { + for (int i = 0; i < 10; i++) { + var x = 0x50000000; + var shift = 34; + Expect.equals(sll(x, shift), 0x14000000000000000); + } +} diff --git a/tests/corelib/safe_to_string_test.dart b/tests/corelib/safe_to_string_test.dart new file mode 100644 index 00000000000..0356e81f0cb --- /dev/null +++ b/tests/corelib/safe_to_string_test.dart @@ -0,0 +1,35 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + Expect.stringEquals('1', Error.safeToString(1)); + Expect.stringEquals('0.5', Error.safeToString(0.5)); + Expect.stringEquals('"1"', Error.safeToString("1")); + Expect.stringEquals('"\'"', Error.safeToString("'")); + Expect.stringEquals('"\'\'"', Error.safeToString("''")); + Expect.stringEquals(r'"\""', Error.safeToString('"')); + Expect.stringEquals(r'"\"\""', Error.safeToString('""')); + + Expect.stringEquals(r'"\\\"\n\r"', Error.safeToString('\\"\n\r')); + + Expect.stringEquals(r'"\u0000\u0001\u0002\u0003\u0004\u0005\u0006\u0007"', + Error.safeToString('\x00\x01\x02\x03\x04\x05\x06\x07')); + Expect.stringEquals(r'"\b\t\n\u000b\f\r\u000e\u000f"', + Error.safeToString('\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f')); + Expect.stringEquals(r'"\u0010\u0011\u0012\u0013\u0014\u0015\u0016\u0017"', + Error.safeToString('\x10\x11\x12\x13\x14\x15\x16\x17')); + Expect.stringEquals(r'"\u0018\u0019\u001a\u001b\u001c\u001d\u001e\u001f"', + Error.safeToString('\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f')); + Expect.stringEquals('" "', Error.safeToString(" ")); + + Expect.stringEquals('null', Error.safeToString(null)); + Expect.stringEquals('true', Error.safeToString(true)); + Expect.stringEquals('false', Error.safeToString(false)); + // The class name may be minified. + String className = "$Object"; + Expect.stringEquals( + "Instance of '$className'", Error.safeToString(new Object())); +} diff --git a/tests/corelib/set_containsAll_test.dart b/tests/corelib/set_containsAll_test.dart new file mode 100644 index 00000000000..ccab046818e --- /dev/null +++ b/tests/corelib/set_containsAll_test.dart @@ -0,0 +1,26 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +class A { + const A(); +} + +class B extends A { + const B(); +} + +main() { + var set1 = new Set(); + set1.add(const B()); + var set2 = new Set(); + var list = [const B()]; + var set3 = list.toSet(); + + var sets = [set1, set2, set3]; + for (var setToTest in sets) { + Expect.isFalse(setToTest.containsAll([new A()])); + } +} diff --git a/tests/corelib/set_contains_test.dart b/tests/corelib/set_contains_test.dart new file mode 100644 index 00000000000..c955374e999 --- /dev/null +++ b/tests/corelib/set_contains_test.dart @@ -0,0 +1,28 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +class A { + const A(); +} + +class B extends A { + const B(); +} + +main() { + var set1 = new Set(); + set1.add(const B()); + var set2 = new Set(); + var list = [const B()]; + var set3 = list.toSet(); + + var sets = [set1, set2, set3]; + for (var setToTest in sets) { + // Test that the set accepts a value that is not of the same type + // Set.contains(A) + Expect.isFalse(setToTest.contains(new A())); + } +} diff --git a/tests/corelib/set_intersection_test.dart b/tests/corelib/set_intersection_test.dart new file mode 100644 index 00000000000..2cd8a65acf1 --- /dev/null +++ b/tests/corelib/set_intersection_test.dart @@ -0,0 +1,31 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +class A { + const A(); +} + +class B extends A { + const B(); +} + +main() { + var set1 = new Set(); + set1.add(const B()); + var set2 = new Set(); + var list = [const B()]; + var set3 = list.toSet(); + + var setOther = new Set(); + setOther.add(new A()); + var sets = [set1, set2, set3]; + for (var setToTest in sets) { + // Test that the set accepts another set that is not of the same type: + // Set.intersection(Set) + Set result = setToTest.intersection(setOther); + Expect.isTrue(result.isEmpty); + } +} diff --git a/tests/corelib/set_iterator_test.dart b/tests/corelib/set_iterator_test.dart new file mode 100644 index 00000000000..26d0deec908 --- /dev/null +++ b/tests/corelib/set_iterator_test.dart @@ -0,0 +1,146 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +class FixedHashCode { + final int _hashCode; + const FixedHashCode(this._hashCode); + int get hashCode { + return _hashCode; + } +} + +class SetIteratorTest { + static testMain() { + testSmallSet(); + testLargeSet(); + testEmptySet(); + testSetWithDeletedEntries(); + testBug5116829(); + testDifferentSizes(); + testDifferentHashCodes(); + } + + static int sum(int expected, Iterator it) { + int count = 0; + while (it.moveNext()) { + count += it.current; + } + Expect.equals(expected, count); + } + + static void testSmallSet() { + Set set = new Set(); + set.add(1); + set.add(2); + set.add(3); + + Iterator it = set.iterator; + sum(6, it); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + } + + static void testLargeSet() { + Set set = new Set(); + int count = 0; + for (int i = 0; i < 100; i++) { + count += i; + set.add(i); + } + Iterator it = set.iterator; + sum(count, it); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + } + + static void testEmptySet() { + Set set = new Set(); + Iterator it = set.iterator; + sum(0, it); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + } + + static void testSetWithDeletedEntries() { + Set set = new Set(); + for (int i = 0; i < 100; i++) { + set.add(i); + } + for (int i = 0; i < 100; i++) { + set.remove(i); + } + Iterator it = set.iterator; + Expect.isFalse(it.moveNext()); + it = set.iterator; + sum(0, it); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + + int count = 0; + for (int i = 0; i < 100; i++) { + set.add(i); + if (i % 2 == 0) + set.remove(i); + else + count += i; + } + it = set.iterator; + sum(count, it); + Expect.isFalse(it.moveNext()); + Expect.isNull(it.current); + } + + static void testBug5116829() { + // During iteration we skipped slot 0 of the hashset's key list. "A" was + // hashed to slot 0 and therefore triggered the bug. + Set mystrs = new Set(); + mystrs.add("A"); + int seen = 0; + for (String elt in mystrs) { + seen++; + Expect.equals("A", elt); + } + Expect.equals(1, seen); + } + + static void testDifferentSizes() { + for (int i = 1; i < 20; i++) { + Set set = new Set(); + int sum = 0; + for (int j = 0; j < i; j++) { + set.add(j); + sum += j; + } + int count = 0; + int controlSum = 0; + for (int x in set) { + controlSum += x; + count++; + } + Expect.equals(i, count); + Expect.equals(sum, controlSum); + } + } + + static void testDifferentHashCodes() { + for (int i = -20; i < 20; i++) { + Set set = new Set(); + var element = new FixedHashCode(i); + set.add(element); + Expect.equals(1, set.length); + bool foundIt = false; + for (var x in set) { + foundIt = true; + Expect.equals(true, identical(x, element)); + } + Expect.equals(true, foundIt); + } + } +} + +main() { + SetIteratorTest.testMain(); +} diff --git a/tests/corelib/set_removeAll_test.dart b/tests/corelib/set_removeAll_test.dart new file mode 100644 index 00000000000..12dfa397408 --- /dev/null +++ b/tests/corelib/set_removeAll_test.dart @@ -0,0 +1,28 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +class A { + const A(); +} + +class B extends A { + const B(); +} + +main() { + var set1 = new Set(); + set1.add(const B()); + var set2 = new Set(); + var list = [const B()]; + var set3 = list.toSet(); + + var sets = [set1, set2, set3]; + for (var setToTest in sets) { + // Test that the set accepts a list that is not of the same type: + // Set.removeAll(List) + Expect.isNull(setToTest.removeAll([new A()])); + } +} diff --git a/tests/corelib/set_remove_test.dart b/tests/corelib/set_remove_test.dart new file mode 100644 index 00000000000..20f48e59226 --- /dev/null +++ b/tests/corelib/set_remove_test.dart @@ -0,0 +1,28 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +class A { + const A(); +} + +class B extends A { + const B(); +} + +main() { + var set1 = new Set(); + set1.add(const B()); + var set2 = new Set(); + var list = [const B()]; + var set3 = list.toSet(); + + var sets = [set1, set2, set3]; + for (var setToTest in sets) { + // Test that the set accepts a value that is not of the same type + // Set.remove(A) + Expect.isFalse(setToTest.remove(new A())); + } +} diff --git a/tests/corelib/set_retainAll_test.dart b/tests/corelib/set_retainAll_test.dart new file mode 100644 index 00000000000..73810952327 --- /dev/null +++ b/tests/corelib/set_retainAll_test.dart @@ -0,0 +1,28 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +class A { + const A(); +} + +class B extends A { + const B(); +} + +main() { + var set1 = new Set(); + set1.add(const B()); + var set2 = new Set(); + var list = [const B()]; + var set3 = list.toSet(); + + var sets = [set1, set2, set3]; + for (var setToTest in sets) { + // Test that the set accepts a list that is not of the same type: + // Set.retainAll(List) + setToTest.retainAll([new A()]); + } +} diff --git a/tests/corelib/set_test.dart b/tests/corelib/set_test.dart new file mode 100644 index 00000000000..bfe4172efb6 --- /dev/null +++ b/tests/corelib/set_test.dart @@ -0,0 +1,550 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +library set_test; + +import 'package:expect/expect.dart'; +import "dart:collection"; + +void testMain(Set create()) { + testInts(create); + testStrings(create); + testInts(() => create().toSet()); + testStrings(() => create().toSet()); +} + +void testInts(Set create()) { + Set set = create(); + + testLength(0, set); + Expect.isTrue(set.add(1)); + testLength(1, set); + Expect.isTrue(set.contains(1)); + + Expect.isFalse(set.add(1)); + testLength(1, set); + Expect.isTrue(set.contains(1)); + + Expect.isTrue(set.remove(1)); + testLength(0, set); + Expect.isFalse(set.contains(1)); + + Expect.isFalse(set.remove(1)); + testLength(0, set); + Expect.isFalse(set.contains(1)); + + for (int i = 0; i < 10; i++) { + set.add(i); + } + + testLength(10, set); + for (int i = 0; i < 10; i++) { + Expect.isTrue(set.contains(i)); + } + + testLength(10, set); + + for (int i = 10; i < 20; i++) { + Expect.isFalse(set.contains(i)); + } + + // Test Set.forEach. + int sum = 0; + testForEach(int val) { + sum += (val + 1); + } + + set.forEach(testForEach); + Expect.equals(10 + 9 + 8 + 7 + 6 + 5 + 4 + 3 + 2 + 1, sum); + + Expect.isTrue(set.containsAll(set)); + + // Test Set.map. + testMap(int val) { + return val * val; + } + + Set mapped = set.map(testMap).toSet(); + Expect.equals(10, mapped.length); + + Expect.isTrue(mapped.contains(0)); + Expect.isTrue(mapped.contains(1)); + Expect.isTrue(mapped.contains(4)); + Expect.isTrue(mapped.contains(9)); + Expect.isTrue(mapped.contains(16)); + Expect.isTrue(mapped.contains(25)); + Expect.isTrue(mapped.contains(36)); + Expect.isTrue(mapped.contains(49)); + Expect.isTrue(mapped.contains(64)); + Expect.isTrue(mapped.contains(81)); + + sum = 0; + set.forEach(testForEach); + Expect.equals(10 + 9 + 8 + 7 + 6 + 5 + 4 + 3 + 2 + 1, sum); + + sum = 0; + + mapped.forEach(testForEach); + Expect.equals(1 + 2 + 5 + 10 + 17 + 26 + 37 + 50 + 65 + 82, sum); + + // Test Set.filter. + testFilter(int val) { + return val.isEven; + } + + Set filtered = set.where(testFilter).toSet(); + + Expect.equals(5, filtered.length); + + Expect.isTrue(filtered.contains(0)); + Expect.isTrue(filtered.contains(2)); + Expect.isTrue(filtered.contains(4)); + Expect.isTrue(filtered.contains(6)); + Expect.isTrue(filtered.contains(8)); + + sum = 0; + filtered.forEach(testForEach); + Expect.equals(1 + 3 + 5 + 7 + 9, sum); + + Expect.isTrue(set.containsAll(filtered)); + + // Test Set.every. + testEvery(int val) { + return (val < 10); + } + + Expect.isTrue(set.every(testEvery)); + Expect.isTrue(filtered.every(testEvery)); + + filtered.add(10); + Expect.isFalse(filtered.every(testEvery)); + + // Test Set.some. + testSome(int val) { + return (val == 4); + } + + Expect.isTrue(set.any(testSome)); + Expect.isTrue(filtered.any(testSome)); + filtered.remove(4); + Expect.isFalse(filtered.any(testSome)); + + // Test Set.intersection. + Set intersection = set.intersection(filtered); + Expect.isTrue(set.contains(0)); + Expect.isTrue(set.contains(2)); + Expect.isTrue(set.contains(6)); + Expect.isTrue(set.contains(8)); + Expect.isFalse(intersection.contains(1)); + Expect.isFalse(intersection.contains(3)); + Expect.isFalse(intersection.contains(4)); + Expect.isFalse(intersection.contains(5)); + Expect.isFalse(intersection.contains(7)); + Expect.isFalse(intersection.contains(9)); + Expect.isFalse(intersection.contains(10)); + Expect.equals(4, intersection.length); + + Expect.isTrue(set.containsAll(intersection)); + Expect.isTrue(filtered.containsAll(intersection)); + + // Test Set.union. + Set twice = create()..addAll([0, 2, 4, 6, 8, 10, 12, 14]); + Set thrice = create()..addAll([0, 3, 6, 9, 12, 15]); + Set union = twice.union(thrice); + Expect.equals(11, union.length); + for (int i = 0; i < 16; i++) { + Expect.equals(i.isEven || (i % 3) == 0, union.contains(i)); + } + + // Test Set.difference. + Set difference = twice.difference(thrice); + Expect.equals(5, difference.length); + for (int i = 0; i < 16; i++) { + Expect.equals(i.isEven && (i % 3) != 0, difference.contains(i)); + } + Expect.isTrue(twice.difference(thrice).difference(twice).isEmpty); + + // Test Set.difference with non-element type. + Set diffSet = create()..addAll([0, 1, 2, 499, 999]); + Set objectSet = new Set(); + objectSet.add("foo"); + objectSet.add(499); + Set diffResult = diffSet.difference(objectSet); + Expect.equals(4, diffResult.length); + for (int value in [0, 1, 2, 999]) { + Expect.isTrue(diffResult.contains(value)); + } + + // Test Set.addAll. + List list = new List(10); + for (int i = 0; i < 10; i++) { + list[i] = i + 10; + } + set.addAll(list); + testLength(20, set); + for (int i = 0; i < 20; i++) { + Expect.isTrue(set.contains(i)); + } + + // Test Set.removeAll + set.removeAll(list); + testLength(10, set); + for (int i = 0; i < 10; i++) { + Expect.isTrue(set.contains(i)); + } + for (int i = 10; i < 20; i++) { + Expect.isFalse(set.contains(i)); + } + + // Test Set.clear. + set.clear(); + testLength(0, set); + Expect.isTrue(set.add(11)); + testLength(1, set); + + // Test Set.toSet. + set.add(1); + set.add(21); + testLength(3, set); + var set2 = set.toSet(); + testLength(3, set2); + Expect.listEquals(set.toList(), set2.toList()); + set.add(31); + testLength(4, set); + testLength(3, set2); + + set2 = set.toSet()..clear(); + testLength(0, set2); + Expect.isTrue(set2.add(11)); + Expect.isTrue(set2.add(1)); + Expect.isTrue(set2.add(21)); + Expect.isTrue(set2.add(31)); + testLength(4, set2); + Expect.listEquals(set.toList(), set2.toList()); + + set2 = (set.toSet()..clear()).toSet(); // Cloning empty set shouldn't fail. + testLength(0, set2); +} + +void testLength(int length, Set set) { + Expect.equals(length, set.length); + (length == 0 ? Expect.isTrue : Expect.isFalse)(set.isEmpty); + (length != 0 ? Expect.isTrue : Expect.isFalse)(set.isNotEmpty); + if (length == 0) { + for (var e in set) { + Expect.fail("contains element when iterated: $e"); + } + } + (length == 0 ? Expect.isFalse : Expect.isTrue)(set.iterator.moveNext()); +} + +void testStrings(Set create()) { + var set = create(); + var strings = ["foo", "bar", "baz", "qux", "fisk", "hest", "svin", "pigvar"]; + set.addAll(strings); + testLength(8, set); + set.removeAll(strings.where((x) => x.length == 3)); + testLength(4, set); + Expect.isTrue(set.add("bar")); + Expect.isTrue(set.add("qux")); + testLength(6, set); + set.addAll(strings); + testLength(8, set); + set.removeWhere((x) => x.length != 3); + testLength(4, set); + set.retainWhere((x) => x[1] == "a"); + testLength(2, set); + Expect.isTrue(set.containsAll(["baz", "bar"])); + + set = set.union(strings.where((x) => x.length != 3).toSet()); + testLength(6, set); + set = set.intersection(["qux", "baz", "fisk", "egern"].toSet()); + testLength(2, set); + Expect.isTrue(set.containsAll(["baz", "fisk"])); +} + +void testTypeAnnotations(Set set) { + set.add(0); + set.add(999); + set.add(0x800000000); + set.add(0x20000000000000); + Expect.isFalse(set.contains("not an it")); + Expect.isFalse(set.remove("not an it")); + Expect.isFalse(set.containsAll(["Not an int", "Also no an int"])); + + testLength(4, set); + set.removeAll(["Not an int", 999, "Also no an int"]); + testLength(3, set); + set.retainAll(["Not an int", 0, "Also no an int"]); + testLength(1, set); +} + +void testRetainWhere(Set create([equals, hashCode, validKey, compare])) { + // The retainWhere method must not collapse the argument Iterable + // in a way that doesn't match the equality of the set. + // It must not throw away equal elements that are different in the + // equality of the set. + // It must not consider objects to be not there if they are equal + // in the equality of the set. + + // If set equality is natural equality, using different but equal objects + // must work. Can't use an identity set internally (as was done at some point + // during development). + Set set = create(); + set.addAll([new CE(0), new CE(1), new CE(2)]); + Expect.equals(3, set.length); // All different. + set.retainAll([new CE(0), new CE(2)]); + Expect.equals(2, set.length); + Expect.isTrue(set.contains(new CE(0))); + Expect.isTrue(set.contains(new CE(2))); + + // If equality of set is identity, we can't internally use a non-identity + // based set because it might throw away equal objects that are not identical. + var elems = [new CE(0), new CE(1), new CE(2), new CE(0)]; + set = create(identical, null, null, identityCompare); + set.addAll(elems); + Expect.equals(4, set.length); + set.retainAll([elems[0], elems[2], elems[3]]); + Expect.equals(3, set.length); + Expect.isTrue(set.contains(elems[0])); + Expect.isTrue(set.contains(elems[2])); + Expect.isTrue(set.contains(elems[3])); + + // If set equality is less precise than equality, we must not use equality + // internally to see if the element is there: + set = create(customEq(3), customHash(3), validKey, customCompare(3)); + set.addAll([new CE(0), new CE(1), new CE(2)]); + Expect.equals(3, set.length); + set.retainAll([new CE(3), new CE(5)]); + Expect.equals(2, set.length); + Expect.isTrue(set.contains(new CE(6))); + Expect.isTrue(set.contains(new CE(8))); + + // It shouldn't matter if the input is a set. + set.clear(); + set.addAll([new CE(0), new CE(1), new CE(2)]); + Expect.equals(3, set.length); + set.retainAll(new Set.from([new CE(3), new CE(5)])); + Expect.equals(2, set.length); + Expect.isTrue(set.contains(new CE(6))); + Expect.isTrue(set.contains(new CE(8))); +} + +void testDifferenceIntersection(create([equals, hashCode, validKey, compare])) { + // Test that elements of intersection comes from receiver set. + CE ce1a = new CE(1); + CE ce1b = new CE(1); + CE ce2 = new CE(2); + CE ce3 = new CE(3); + Expect.equals(ce1a, ce1b); // Sanity check. + + var set1 = create(); + var set2 = create(); + set1.add(ce1a); + set1.add(ce2); + set2.add(ce1b); + set2.add(ce3); + + var difference = set1.difference(set2); + testLength(1, difference); + Expect.identical(ce2, difference.lookup(ce2)); + + difference = set2.difference(set1); + testLength(1, difference); + Expect.identical(ce3, difference.lookup(ce3)); + + // Difference uses other.contains to check for equality. + var set3 = create(identical, identityHashCode, null, identityCompare); + set3.add(ce1b); + difference = set1.difference(set3); + testLength(2, difference); // ce1a is not identical to element in set3. + Expect.identical(ce1a, difference.lookup(ce1a)); + Expect.identical(ce2, difference.lookup(ce2)); + + // Intersection always takes elements from receiver set. + var intersection = set1.intersection(set2); + testLength(1, intersection); + Expect.identical(ce1a, intersection.lookup(ce1a)); + + intersection = set1.intersection(set3); + testLength(0, intersection); +} + +// Objects that are equal based on data. +class CE implements Comparable { + final int id; + const CE(this.id); + int get hashCode => id; + bool operator ==(Object other) => other is CE && id == (other as CE).id; + int compareTo(CE other) => id - other.id; + String toString() => "CE($id)"; +} + +// Equality of Id objects based on id modulo value. +Function customEq(int mod) => (CE e1, CE e2) => ((e1.id - e2.id) % mod) == 0; +Function customHash(int mod) => (CE e) => e.id % mod; +Function customCompare(int mod) => + (CE e1, CE e2) => (e1.id % mod) - (e2.id % mod); +bool validKey(Object o) => o is CE; +final customId = new Map.identity(); +int counter = 0; +int identityCompare(e1, e2) { + if (identical(e1, e2)) return 0; + int i1 = customId.putIfAbsent(e1, () => ++counter); + int i2 = customId.putIfAbsent(e2, () => ++counter); + return i1 - i2; +} + +void testIdentity(Set create()) { + Set set = create(); + var e1 = new CE(0); + var e2 = new CE(0); + Expect.equals(e1, e2); + Expect.isFalse(identical(e1, e2)); + + testLength(0, set); + set.add(e1); + testLength(1, set); + Expect.isTrue(set.contains(e1)); + Expect.isFalse(set.contains(e2)); + + set.add(e2); + testLength(2, set); + Expect.isTrue(set.contains(e1)); + Expect.isTrue(set.contains(e2)); + + var set2 = set.toSet(); + testLength(2, set2); + Expect.isTrue(set2.contains(e1)); + Expect.isTrue(set2.contains(e2)); +} + +void testIntSetFrom(setFrom) { + List numList = [2, 3, 5, 7, 11, 13]; + + Set set1 = setFrom(numList); + Expect.listEquals(numList, set1.toList()..sort()); + + Set numSet = numList.toSet(); + Set set2 = setFrom(numSet); + Expect.listEquals(numList, set2.toList()..sort()); + + Iterable numIter = numList.where((x) => true); + Set set3 = setFrom(numIter); + Expect.listEquals(numList, set3.toList()..sort()); + + Set set4 = setFrom(new Iterable.generate(0)); + Expect.isTrue(set4.isEmpty); +} + +void testCESetFrom(setFrom) { + List ceList = [ + new CE(2), + new CE(3), + new CE(5), + new CE(7), + new CE(11), + new CE(13) + ]; + + Set set1 = setFrom(ceList); + Expect.listEquals(ceList, set1.toList()..sort()); + + Set ceSet = ceList.toSet(); + Set set2 = setFrom(ceSet); + Expect.listEquals(ceList, set2.toList()..sort()); + + Iterable ceIter = ceList.where((x) => true); + Set set3 = setFrom(ceIter); + Expect.listEquals(ceList, set3.toList()..sort()); + + Set set4 = setFrom(new Iterable.generate(0)); + Expect.isTrue(set4.isEmpty); +} + +class A {} + +class B {} + +class C implements A, B {} + +void testASetFrom(setFrom) { + List bList = [new C()]; + // Set.from allows to cast elements. + Set aSet = setFrom(bList); + Expect.isTrue(aSet.length == 1); +} + +main() { + testMain(() => new HashSet()); + testMain(() => new LinkedHashSet()); + testMain(() => new HashSet.identity()); + testMain(() => new LinkedHashSet.identity()); + testMain(() => new HashSet(equals: identical)); + testMain(() => new LinkedHashSet(equals: identical)); + testMain(() => new HashSet( + equals: (a, b) => a == b, + hashCode: (a) => -a.hashCode, + isValidKey: (a) => true)); + testMain(() => new LinkedHashSet( + equals: (a, b) => a == b, + hashCode: (a) => -a.hashCode, + isValidKey: (a) => true)); + testMain(() => new SplayTreeSet()); + + testIdentity(() => new HashSet.identity()); + testIdentity(() => new LinkedHashSet.identity()); + testIdentity(() => new HashSet(equals: identical)); + testIdentity(() => new LinkedHashSet(equals: identical)); + testIdentity(() => new SplayTreeSet(identityCompare)); + + testTypeAnnotations(new HashSet()); + testTypeAnnotations(new LinkedHashSet()); + testTypeAnnotations(new HashSet(equals: identical)); + testTypeAnnotations(new LinkedHashSet(equals: identical)); + testTypeAnnotations(new HashSet( + equals: (int a, int b) => a == b, + hashCode: (int a) => a.hashCode, + isValidKey: (a) => a is int)); + testTypeAnnotations(new LinkedHashSet( + equals: (int a, int b) => a == b, + hashCode: (int a) => a.hashCode, + isValidKey: (a) => a is int)); + testTypeAnnotations(new SplayTreeSet()); + + testRetainWhere(([equals, hashCode, validKey, comparator]) => + new HashSet(equals: equals, hashCode: hashCode, isValidKey: validKey)); + testRetainWhere(([equals, hashCode, validKey, comparator]) => + new LinkedHashSet( + equals: equals, hashCode: hashCode, isValidKey: validKey)); + testRetainWhere(([equals, hashCode, validKey, comparator]) => + new SplayTreeSet(comparator, validKey)); + + testDifferenceIntersection(([equals, hashCode, validKey, comparator]) => + new HashSet(equals: equals, hashCode: hashCode, isValidKey: validKey)); + testDifferenceIntersection(([equals, hashCode, validKey, comparator]) => + new LinkedHashSet( + equals: equals, hashCode: hashCode, isValidKey: validKey)); + testDifferenceIntersection(([equals, hashCode, validKey, comparator]) => + new SplayTreeSet(comparator, validKey)); + + testIntSetFrom((x) => new Set.from(x)); + testIntSetFrom((x) => new HashSet.from(x)); + testIntSetFrom((x) => new LinkedHashSet.from(x)); + testIntSetFrom((x) => new SplayTreeSet.from(x)); + + testCESetFrom((x) => new Set.from(x)); + testCESetFrom((x) => new HashSet.from(x)); + testCESetFrom((x) => new LinkedHashSet.from(x)); + testCESetFrom((x) => new SplayTreeSet.from(x)); + + testCESetFrom( + (x) => new SplayTreeSet.from(x, customCompare(20), validKey)); + testCESetFrom((x) => new SplayTreeSet.from(x, identityCompare)); + + testASetFrom((x) => new Set.from(x)); + testASetFrom((x) => new HashSet.from(x)); + testASetFrom((x) => new LinkedHashSet.from(x)); + testASetFrom((x) => new SplayTreeSet.from(x, identityCompare)); +} diff --git a/tests/corelib/set_to_string_test.dart b/tests/corelib/set_to_string_test.dart new file mode 100644 index 00000000000..f9833bde5d2 --- /dev/null +++ b/tests/corelib/set_to_string_test.dart @@ -0,0 +1,36 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; +import "dart:collection"; + +void main() { + Set s = new HashSet(); + s.add(1); + Expect.equals("{1}", s.toString()); + s.remove(1); + s.add(s); + Expect.equals("{{...}}", s.toString()); + + Queue q = new ListQueue(4); + q.add(1); + q.add(2); + q.add(q); + q.add(s); + + Expect.equals("{1, 2, {...}, {{...}}}", q.toString()); + + // Throwing in the middle of a toString does not leave the + // set as being visited + q.addLast(new ThrowOnToString()); + Expect.throws(q.toString, (e) => e == "Bad!"); + q.removeLast(); + Expect.equals("{1, 2, {...}, {{...}}}", q.toString()); +} + +class ThrowOnToString { + String toString() { + throw "Bad!"; + } +} diff --git a/tests/corelib/shuffle_test.dart b/tests/corelib/shuffle_test.dart new file mode 100644 index 00000000000..09281ef21c6 --- /dev/null +++ b/tests/corelib/shuffle_test.dart @@ -0,0 +1,129 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// Dart test for List.shuffle. +library shuffle_test; + +import "dart:typed_data"; +import "dart:math" show Random; +import "package:expect/expect.dart"; + +main() { + List mkList(int n) => new List.generate(n, (x) => x); + + for (int size in [0, 1, 2, 3, 7, 15, 99, 1023]) { + List numbers = new List.generate(size, (x) => x); + testShuffle(numbers.toList(growable: true)); + testShuffle(numbers.toList(growable: false)); + testShuffle(new Uint32List(size)..setAll(0, numbers)); + testShuffle(new Int32List(size)..setAll(0, numbers)); + testShuffle(new Uint16List(size)..setAll(0, numbers)); + testShuffle(new Int16List(size)..setAll(0, numbers)); + // Some numbers will be truncated in the following two. + testShuffle(new Uint8List(size)..setAll(0, numbers)); + testShuffle(new Int8List(size)..setAll(0, numbers)); + testShuffle(numbers.map((x) => "$x").toList()); + } + + // Check that it actually can keep the same list (regression test). + List l = [1, 2]; + success: + { + for (int i = 0; i < 266; i++) { + int first = l.first; + l.shuffle(); + if (l.first == first) break success; // List didn't change. + } + // Chance of changing 266 times in a row should be < 1:1e80. + Expect.fail("List changes every time."); + } + + testRandom(); +} + +void testShuffle(list) { + List copy = list.toList(); + list.shuffle(); + if (list.length < 2) { + Expect.listEquals(copy, list); + return; + } + // Test that the list after shuffling has the same elements as before, + // without considering order. + Map seen = {}; + for (var e in list) { + seen[e] = seen.putIfAbsent(e, () => 0) + 1; + } + for (var e in copy) { + int remaining = seen[e]; + remaining -= 1; // Throws if e was not in map at all. + if (remaining == 0) { + seen.remove(e); + } else { + seen[e] = remaining; + } + } + Expect.isTrue(seen.isEmpty); + // Test that shuffle actually does make a change. Repeat until the probability + // of a proper shuffling hitting the same list again is less than 10^80 + // (arbitrary bignum - approx. number of atoms in the universe). + // + // The probablility of shuffling a list of length n into the same list is + // 1/n!. If one shuffle didn't change the list, repeat shuffling until + // probability of randomly hitting the same list every time is less than + // 1/1e80. + + bool listsDifferent() { + for (int i = 0; i < list.length; i++) { + if (list[i] != copy[i]) return true; + } + return false; + } + + if (list.length < 59) { + // 59! > 1e80. + double limit = 1e80; + double fact = 1.0; + for (int i = 2; i < list.length; i++) fact *= i; + double combos = fact; + + while (!listsDifferent() && combos < limit) { + list.shuffle(); + combos *= fact; + } + } + if (!listsDifferent()) { + Expect.fail("Didn't shuffle at all, p < 1:1e80: $list"); + } +} + +// Checks that the "random" argument to shuffle is used. +testRandom() { + List randomNums = [37, 87, 42, 157, 252, 17]; + List numbers = new List.generate(25, (x) => x); + List l1 = numbers.toList()..shuffle(new MockRandom(randomNums)); + for (int i = 0; i < 50; i++) { + // With same random sequence, we get the same shuffling each time. + List l2 = numbers.toList()..shuffle(new MockRandom(randomNums)); + Expect.listEquals(l1, l2); + } +} + +class MockRandom implements Random { + final List _values; + int index = 0; + MockRandom(this._values); + + int get _next { + int next = _values[index]; + index = (index + 1) % _values.length; + return next; + } + + int nextInt(int limit) => _next % limit; + + double nextDouble() => _next / 256.0; + + bool nextBool() => _next.isEven; +} diff --git a/tests/corelib/sort_helper.dart b/tests/corelib/sort_helper.dart new file mode 100644 index 00000000000..9c730177ea2 --- /dev/null +++ b/tests/corelib/sort_helper.dart @@ -0,0 +1,152 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +library sort_helper; + +import "package:expect/expect.dart"; + +class SortHelper { + SortHelper(this.sortFunction, this.compareFunction) {} + + void run() { + testSortIntLists(); + testSortDoubleLists(); + } + + bool isSorted(List a) { + for (int i = 1; i < a.length; i++) { + if (compareFunction(a[i - 1], a[i]) > 0) { + return false; + } + } + return true; + } + + void testSortIntLists() { + List a = new List(40); + + for (int i = 0; i < a.length; i++) { + a[i] = i; + } + testSort(a); + + for (int i = 0; i < a.length; i++) { + a[a.length - i - 1] = i; + } + testSort(a); + + for (int i = 0; i < 21; i++) { + a[i] = 1; + } + for (int i = 21; i < a.length; i++) { + a[i] = 2; + } + testSort(a); + + // Same with bad pivot-choices. + for (int i = 0; i < 21; i++) { + a[i] = 1; + } + for (int i = 21; i < a.length; i++) { + a[i] = 2; + } + a[6] = 1; + a[13] = 1; + a[19] = 1; + a[25] = 1; + a[33] = 2; + testSort(a); + + for (int i = 0; i < 21; i++) { + a[i] = 2; + } + for (int i = 21; i < a.length; i++) { + a[i] = 1; + } + testSort(a); + + // Same with bad pivot-choices. + for (int i = 0; i < 21; i++) { + a[i] = 2; + } + for (int i = 21; i < a.length; i++) { + a[i] = 1; + } + a[6] = 2; + a[13] = 2; + a[19] = 2; + a[25] = 2; + a[33] = 1; + testSort(a); + + var a2 = new List(0); + testSort(a2); + + var a3 = new List(1); + a3[0] = 1; + testSort(a3); + + // -------- + // Test insertion sort. + testInsertionSort(0, 1, 2, 3); + testInsertionSort(0, 1, 3, 2); + testInsertionSort(0, 3, 2, 1); + testInsertionSort(0, 3, 1, 2); + testInsertionSort(0, 2, 1, 3); + testInsertionSort(0, 2, 3, 1); + testInsertionSort(1, 0, 2, 3); + testInsertionSort(1, 0, 3, 2); + testInsertionSort(1, 2, 3, 0); + testInsertionSort(1, 2, 0, 3); + testInsertionSort(1, 3, 2, 0); + testInsertionSort(1, 3, 0, 2); + testInsertionSort(2, 0, 1, 3); + testInsertionSort(2, 0, 3, 1); + testInsertionSort(2, 1, 3, 0); + testInsertionSort(2, 1, 0, 3); + testInsertionSort(2, 3, 1, 0); + testInsertionSort(2, 3, 0, 1); + testInsertionSort(3, 0, 1, 2); + testInsertionSort(3, 0, 2, 1); + testInsertionSort(3, 1, 2, 0); + testInsertionSort(3, 1, 0, 2); + testInsertionSort(3, 2, 1, 0); + testInsertionSort(3, 2, 0, 1); + } + + void testSort(List a) { + sortFunction(a); + Expect.isTrue(isSorted(a)); + } + + void testInsertionSort(int i1, int i2, int i3, int i4) { + var a = new List(4); + a[0] = i1; + a[1] = i2; + a[2] = i3; + a[3] = i4; + testSort(a); + } + + void testSortDoubleLists() { + List a = new List(40); + for (int i = 0; i < a.length; i++) { + a[i] = 1.0 * i + 0.5; + } + testSort(a); + + for (int i = 0; i < a.length; i++) { + a[i] = 1.0 * (a.length - i) + 0.5; + } + testSort(a); + + for (int i = 0; i < a.length; i++) { + a[i] = 1.5; + } + testSort(a); + } + + Function sortFunction; + Function compareFunction; +} diff --git a/tests/corelib/sort_test.dart b/tests/corelib/sort_test.dart new file mode 100644 index 00000000000..722964450be --- /dev/null +++ b/tests/corelib/sort_test.dart @@ -0,0 +1,313 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// Dart test for sort routines. +library sort_test; + +import "package:expect/expect.dart"; +import 'sort_helper.dart'; + +main() { + var compare = (a, b) => a.compareTo(b); + var sort = (list) => list.sort(compare); + new SortHelper(sort, compare).run(); + + compare = (a, b) => -a.compareTo(b); + new SortHelper(sort, compare).run(); + + compare = (a, b) => a.compareTo(b); + + // Pivot-candidate indices: 7, 15, 22, 29, 37 + // Test Dutch flag partitioning (candidates 2 and 4 are the same). + var list = [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 /**/, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1 /**/, + 1, + 1, + 1, + 1, + 1, + 1, + 1 /**/, + 1, + 1, + 1, + 1, + 1, + 1, + 1 /**/, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2 /**/, + 2, + 2, + 2, + 2, + 2, + 2, + 2 + ]; + list.sort(compare); + Expect.listEquals(list, [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2 + ]); + + list = [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1 /**/, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0 /**/, + 1, + 1, + 1, + 1, + 1, + 1, + 0 /**/, + 1, + 1, + 1, + 1, + 1, + 1, + 0 /**/, + 2 /**/, + 2, + 2, + 2, + 2, + 2, + 2, + 2 /**/, + 2, + 2, + 2, + 2, + 2, + 2, + 2 + ]; + list.sort(compare); + Expect.listEquals(list, [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2 + ]); + + // Pivots: 1 and 8. + // The second partition will be big (more than 2/3 of the list), and an + // optimization kicks in that removes the pivots from the partition. + list = [ + 0, + 9, + 0, + 9, + 3, + 9, + 0, + 1 /**/, + 1, + 0, + 1, + 9, + 8, + 2, + 1, + 1 /**/, + 4, + 5, + 2, + 5, + 0, + 1, + 8 /**/, + 8, + 8, + 5, + 2, + 2, + 9, + 8 /**/, + 8, + 4, + 4, + 1, + 5, + 3, + 2, + 8 /**/, + 5, + 1, + 2, + 8, + 5, + 6, + 8 + ]; + list.sort(compare); + Expect.listEquals(list, [ + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 2, + 2, + 2, + 2, + 2, + 2, + 3, + 3, + 4, + 4, + 4, + 5, + 5, + 5, + 5, + 5, + 5, + 6, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 8, + 9, + 9, + 9, + 9, + 9 + ]); +} diff --git a/tests/corelib/splay_tree_from_iterable_test.dart b/tests/corelib/splay_tree_from_iterable_test.dart new file mode 100644 index 00000000000..5db4c1b9a36 --- /dev/null +++ b/tests/corelib/splay_tree_from_iterable_test.dart @@ -0,0 +1,167 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; +import 'dart:collection'; + +main() { + defaultFunctionValuesTest(); + defaultKeyFunctionTest(); + defaultValueFunctionTest(); + noDefaultValuesTest(); + emptyIterableTest(); + equalElementsTest(); + genericTypeTest(); + typedTest(); +} + +void defaultFunctionValuesTest() { + var map = new SplayTreeMap.fromIterable([1, 2, 3]); + + Expect.isTrue(map is Map); + Expect.isTrue(map is SplayTreeMap); + Expect.isFalse(map is HashMap); + + Expect.equals(3, map.length); + Expect.equals(3, map.keys.length); + Expect.equals(3, map.values.length); + + Expect.equals(1, map[1]); + Expect.equals(2, map[2]); + Expect.equals(3, map[3]); +} + +void defaultKeyFunctionTest() { + var map = new SplayTreeMap.fromIterable([1, 2, 3], value: (x) => x + 1); + + Expect.isTrue(map is Map); + Expect.isTrue(map is SplayTreeMap); + Expect.isFalse(map is HashMap); + + Expect.equals(3, map.length); + Expect.equals(3, map.keys.length); + Expect.equals(3, map.values.length); + + Expect.equals(2, map[1]); + Expect.equals(3, map[2]); + Expect.equals(4, map[3]); +} + +void defaultValueFunctionTest() { + var map = new SplayTreeMap.fromIterable([1, 2, 3], key: (x) => x + 1); + + Expect.isTrue(map is Map); + Expect.isTrue(map is SplayTreeMap); + Expect.isFalse(map is HashMap); + + Expect.equals(3, map.length); + Expect.equals(3, map.keys.length); + Expect.equals(3, map.values.length); + + Expect.equals(1, map[2]); + Expect.equals(2, map[3]); + Expect.equals(3, map[4]); +} + +void noDefaultValuesTest() { + var map = new SplayTreeMap.fromIterable([1, 2, 3], + key: (x) => x + 1, value: (x) => x - 1); + + Expect.isTrue(map is Map); + Expect.isTrue(map is SplayTreeMap); + Expect.isFalse(map is HashMap); + + Expect.equals(3, map.length); + Expect.equals(3, map.keys.length); + Expect.equals(3, map.values.length); + + Expect.equals(0, map[2]); + Expect.equals(1, map[3]); + Expect.equals(2, map[4]); +} + +void emptyIterableTest() { + var map = new SplayTreeMap.fromIterable([]); + + Expect.isTrue(map is Map); + Expect.isTrue(map is SplayTreeMap); + Expect.isFalse(map is HashMap); + + Expect.equals(0, map.length); + Expect.equals(0, map.keys.length); + Expect.equals(0, map.values.length); +} + +void equalElementsTest() { + var map = new SplayTreeMap.fromIterable([1, 2, 2], key: (x) => x + 1); + + Expect.isTrue(map is Map); + Expect.isTrue(map is SplayTreeMap); + Expect.isFalse(map is HashMap); + + Expect.equals(2, map.length); + Expect.equals(2, map.keys.length); + Expect.equals(2, map.values.length); + + Expect.equals(1, map[2]); + Expect.equals(2, map[3]); +} + +void genericTypeTest() { + var map = + new SplayTreeMap.fromIterable([1, 2, 3], value: (x) => '$x'); + Expect.isTrue(map is Map); + Expect.isTrue(map is SplayTreeMap); + + // Make sure it is not just SplayTreeMap. + Expect.isFalse(map is SplayTreeMap); + Expect.isFalse(map is SplayTreeMap); +} + +// Test in checked mode with explicitly given types. +void typedTest() { + if (!typeAssertionsEnabled) return; + + // Assign functions to untyped function variables. + Function key = (int v) => "$v"; + Function value = (int v) => v.isOdd; + Function id = (int i) => i; + + Expect.throws(() { + new SplayTreeMap.fromIterable([1, 2, 3], key: key + // No "value" map, defaults to identity, which returns int, not bool. + ); + }); + + Expect.throws(() { + new SplayTreeMap.fromIterable([1, 2, 3], + // No "key" map, defaults to identity, which returns int, not String. + value: value); + }); + + Expect.throws(() { + new SplayTreeMap.fromIterable([1, 2, 3], + key: id, // wrong type. + value: value); + }); + + Expect.throws(() { + new SplayTreeMap.fromIterable([1, 2, 3], + key: key, value: id // wrong type. + ); + }); + + // But it works with explicit types when used correctly. + SplayTreeMap map = new SplayTreeMap.fromIterable( + [1, 2, 3], + key: key, value: value); + Iterable keys = map.keys; + Iterable values = map.values; + List keyList = keys.toList(); + List valueList = values.toList(); + Expect.equals(3, keyList.length); + Expect.equals(3, valueList.length); + Expect.equals(keys.first, map.firstKey()); + Expect.equals(keys.last, map.lastKey()); +} diff --git a/tests/corelib/splay_tree_from_iterables_test.dart b/tests/corelib/splay_tree_from_iterables_test.dart new file mode 100644 index 00000000000..6e22ddf3792 --- /dev/null +++ b/tests/corelib/splay_tree_from_iterables_test.dart @@ -0,0 +1,85 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; +import 'dart:collection'; + +main() { + positiveTest(); + emptyMapTest(); + fewerKeysIterableTest(); + fewerValuesIterableTest(); + equalElementsTest(); + genericTypeTest(); +} + +void positiveTest() { + var map = new SplayTreeMap.fromIterables([1, 2, 3], ["one", "two", "three"]); + + Expect.isTrue(map is Map); + Expect.isTrue(map is SplayTreeMap); + Expect.isFalse(map is HashMap); + + Expect.equals(3, map.length); + Expect.equals(3, map.keys.length); + Expect.equals(3, map.values.length); + + Expect.equals("one", map[1]); + Expect.equals("two", map[2]); + Expect.equals("three", map[3]); +} + +void emptyMapTest() { + var map = new SplayTreeMap.fromIterables([], []); + + Expect.isTrue(map is Map); + Expect.isTrue(map is SplayTreeMap); + Expect.isFalse(map is HashMap); + + Expect.equals(0, map.length); + Expect.equals(0, map.keys.length); + Expect.equals(0, map.values.length); +} + +void fewerValuesIterableTest() { + Expect.throws(() => new SplayTreeMap.fromIterables([1, 2], [0])); +} + +void fewerKeysIterableTest() { + Expect.throws(() => new SplayTreeMap.fromIterables([1], [0, 2])); +} + +void equalElementsTest() { + var map = new SplayTreeMap.fromIterables([1, 2, 2], ["one", "two", "three"]); + + Expect.isTrue(map is Map); + Expect.isTrue(map is SplayTreeMap); + Expect.isFalse(map is HashMap); + + Expect.equals(2, map.length); + Expect.equals(2, map.keys.length); + Expect.equals(2, map.values.length); + + Expect.equals("one", map[1]); + Expect.equals("three", map[2]); +} + +void genericTypeTest() { + var map = new SplayTreeMap.fromIterables( + [1, 2, 3], ["one", "two", "three"]); + Expect.isTrue(map is Map); + Expect.isTrue(map is SplayTreeMap); + + // Make sure it is not just SplayTreeMap. + Expect.isFalse(map is SplayTreeMap); + Expect.isFalse(map is SplayTreeMap); + + Expect.equals(3, map.length); + Expect.equals(3, map.keys.length); + Expect.equals(3, map.values.length); + + Expect.equals("one", map[1]); + Expect.equals("two", map[2]); + Expect.equals("three", map[3]); +} diff --git a/tests/corelib/splay_tree_test.dart b/tests/corelib/splay_tree_test.dart new file mode 100644 index 00000000000..f1064a3b867 --- /dev/null +++ b/tests/corelib/splay_tree_test.dart @@ -0,0 +1,142 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// Dart test for Splaytrees. +library splay_tree_test; + +import "package:expect/expect.dart"; +import 'dart:collection'; + +main() { + // Simple tests. + SplayTreeMap tree = new SplayTreeMap(); + tree[1] = "first"; + tree[3] = "third"; + tree[5] = "fifth"; + tree[2] = "second"; + tree[4] = "fourth"; + + var correctSolution = ["first", "second", "third", "fourth", "fifth"]; + + tree.forEach((key, value) { + Expect.equals(true, key >= 1); + Expect.equals(true, key <= 5); + Expect.equals(value, correctSolution[key - 1]); + }); + + for (var v in ["first", "second", "third", "fourth", "fifth"]) { + Expect.isTrue(tree.containsValue(v)); + } + ; + Expect.isFalse(tree.containsValue("sixth")); + + tree[7] = "seventh"; + + Expect.equals(1, tree.firstKey()); + Expect.equals(7, tree.lastKey()); + + Expect.equals(2, tree.lastKeyBefore(3)); + Expect.equals(4, tree.firstKeyAfter(3)); + + Expect.equals(null, tree.lastKeyBefore(1)); + Expect.equals(2, tree.firstKeyAfter(1)); + + Expect.equals(4, tree.lastKeyBefore(5)); + Expect.equals(7, tree.firstKeyAfter(5)); + + Expect.equals(5, tree.lastKeyBefore(7)); + Expect.equals(null, tree.firstKeyAfter(7)); + + Expect.equals(5, tree.lastKeyBefore(6)); + Expect.equals(7, tree.firstKeyAfter(6)); + + testSetFrom(); + regressRemoveWhere(); + regressRemoveWhere2(); + regressFromCompare(); +} + +void regressRemoveWhere() { + // Regression test. Fix in https://codereview.chromium.org/148523006/ + var t = new SplayTreeSet(); + t.addAll([1, 3, 5, 7, 2, 4, 6, 8, 0]); + var seen = new List.filled(9, false); + t.removeWhere((x) { + // Called only once per element. + Expect.isFalse(seen[x], "seen $x"); + seen[x] = true; + return x.isOdd; + }); +} + +void regressRemoveWhere2() { + // Regression test for http://dartbug.com/18676 + // Removing all elements with removeWhere causes error. + + var t = new SplayTreeSet(); + t.addAll([1, 2, 3, 4, 5]); + t.removeWhere((_) => true); // Should not throw. + Expect.isTrue(t.isEmpty); + t.addAll([1, 2, 3, 4, 5]); + t.retainWhere((_) => false); // Should not throw. + Expect.isTrue(t.isEmpty); +} + +void testSetFrom() { + var set1 = new SplayTreeSet()..addAll([1, 2, 3, 4, 5]); + var set2 = new SplayTreeSet.from(set1); + Expect.equals(5, set2.length); + for (int i = 1; i <= 5; i++) { + Expect.isTrue(set2.contains(i)); + } + + set1 = new SplayTreeSet()..addAll([0, 1, 2.4, 3.14, 5]); + set2 = new SplayTreeSet.from(set1.where((x) => x is int)); + Expect.equals(3, set2.length); +} + +void regressFromCompare() { + // Regression test for http://dartbug.com/23387. + // The compare and isValidKey arguments to SplayTreeMap.from were ignored. + + int compare(a, b) { + if (a is IncomparableKey && b is IncomparableKey) { + return b.id - a.id; + } + throw "isValidKey failure"; + } + + bool isValidKey(o) => o is IncomparableKey; + IncomparableKey key(int n) => new IncomparableKey(n); + + var entries = {key(0): 0, key(1): 1, key(2): 2, key(0): 0}; + Expect.equals(4, entries.length); + var map = + new SplayTreeMap.from(entries, compare, isValidKey); + Expect.equals(3, map.length); + for (int i = 0; i < 3; i++) { + Expect.isTrue(map.containsKey(key(i))); + Expect.equals(i, map[key(i)]); + } + Expect.isFalse(map.containsKey(key(5))); + Expect.isFalse(map.containsKey(1)); + Expect.isFalse(map.containsKey("string")); + Expect.equals(null, map[key(5)]); + Expect.equals(null, map[1]); + Expect.equals(null, map["string"]); + Expect.throws(() { + map[1] = 42; + }); + Expect.throws(() { + map["string"] = 42; + }); + map[key(5)] = 42; + Expect.equals(4, map.length); + Expect.equals(42, map[key(5)]); +} + +class IncomparableKey { + final int id; + IncomparableKey(this.id); +} diff --git a/tests/corelib/stacktrace_current_test.dart b/tests/corelib/stacktrace_current_test.dart new file mode 100644 index 00000000000..6712e64ed86 --- /dev/null +++ b/tests/corelib/stacktrace_current_test.dart @@ -0,0 +1,36 @@ +// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "dart:convert" show LineSplitter; + +import "package:expect/expect.dart"; + +void main() { + var st0; + var st1; + // Primitive way to get stack trace,. + try { + throw 0; + } catch (_, s) { + st0 = s; + } + st1 = StackTrace.current; + + var st0s = findMain(st0); + var st1s = findMain(st1); + // Stack traces are not equal (contains at least a different line number, + // and possible different frame numbers). + // They are *similar*, so check that they agree on everything but numbers. + var digits = new RegExp(r"\d+"); + Expect.equals(st0s.replaceAll(digits, "0"), st1s.replaceAll(digits, "0")); +} + +String findMain(StackTrace stack) { + var string = "$stack"; + var lines = LineSplitter.split(string).toList(); + while (lines.isNotEmpty && !lines.first.contains("main")) { + lines.removeAt(0); + } + return lines.join("\n"); +} diff --git a/tests/corelib/stacktrace_fromstring_test.dart b/tests/corelib/stacktrace_fromstring_test.dart new file mode 100644 index 00000000000..b42aba3ed94 --- /dev/null +++ b/tests/corelib/stacktrace_fromstring_test.dart @@ -0,0 +1,45 @@ +// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; +import "package:async_helper/async_helper.dart"; +import "dart:async"; + +void main() { + StackTrace stack; + try { + throw 0; + } catch (e, s) { + stack = s; + } + var string = "$stack"; + StackTrace stringTrace = new StackTrace.fromString(string); + Expect.isTrue(stringTrace is StackTrace); + Expect.equals(stack.toString(), stringTrace.toString()); + + string = "some random string, nothing like a StackTrace"; + stringTrace = new StackTrace.fromString(string); + Expect.isTrue(stringTrace is StackTrace); + Expect.equals(string, stringTrace.toString()); + + // Use stacktrace asynchronously. + asyncStart(); + var c = new Completer(); + c.completeError(0, stringTrace); + c.future.then((v) { + throw "Unexpected value: $v"; + }, onError: (e, s) { + Expect.equals(string, s.toString()); + }).then((_) { + var c = new StreamController(); + c.stream.listen((v) { + throw "Unexpected value: $v"; + }, onError: (e, s) { + Expect.equals(string, s.toString()); + asyncEnd(); + }); + c.addError(0, stringTrace); + c.close(); + }); +} diff --git a/tests/corelib/stopwatch2_test.dart b/tests/corelib/stopwatch2_test.dart new file mode 100644 index 00000000000..a95db460261 --- /dev/null +++ b/tests/corelib/stopwatch2_test.dart @@ -0,0 +1,17 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// Dart test program for elapsed getters in stopwatch support. + +import "package:expect/expect.dart"; + +main() { + Stopwatch sw = new Stopwatch()..start(); + while (sw.elapsedMilliseconds < 2) { + /* do nothing. */ + } + sw.stop(); + Expect.equals(sw.elapsedMicroseconds, sw.elapsed.inMicroseconds); + Expect.equals(sw.elapsedMilliseconds, sw.elapsed.inMilliseconds); +} diff --git a/tests/corelib/stopwatch_test.dart b/tests/corelib/stopwatch_test.dart new file mode 100644 index 00000000000..e6b8a979821 --- /dev/null +++ b/tests/corelib/stopwatch_test.dart @@ -0,0 +1,128 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// Dart test program for testing stopwatch support. + +library stopwatch_test; + +import "package:expect/expect.dart"; + +class StopwatchTest { + static bool checkTicking(Stopwatch sw) { + Expect.isFalse(sw.isRunning); + sw.start(); + Expect.isTrue(sw.isRunning); + for (int i = 0; i < 1000000; i++) { + int.parse(i.toString()); + if (sw.elapsedTicks > 0) { + break; + } + } + return sw.elapsedTicks > 0; + } + + static bool checkStopping(Stopwatch sw) { + sw.stop(); + Expect.isFalse(sw.isRunning); + int v1 = sw.elapsedTicks; + Expect.isTrue(v1 > 0); // Expect a non-zero elapsed time. + Stopwatch sw2 = new Stopwatch(); // Used for verification. + sw2.start(); + Expect.isTrue(sw2.isRunning); + int sw2LastElapsed = 0; + for (int i = 0; i < 100000; i++) { + int.parse(i.toString()); + int v2 = sw.elapsedTicks; + if (v1 != v2) { + return false; + } + // If sw2 elapsed twice then sw must have advanced too if it wasn't + // stopped. + if (sw2LastElapsed > 0 && sw2.elapsedTicks > sw2LastElapsed) { + break; + } + sw2LastElapsed = sw2.elapsedTicks; + } + // The test only makes sense if measureable time elapsed and elapsed time + // on the stopped Stopwatch did not increase. + Expect.isTrue(sw2.elapsedTicks > 0); + return true; + } + + static checkRestart() { + Stopwatch sw = new Stopwatch(); + Expect.isFalse(sw.isRunning); + sw.start(); + Expect.isTrue(sw.isRunning); + for (int i = 0; i < 100000; i++) { + int.parse(i.toString()); + if (sw.elapsedTicks > 0) { + break; + } + } + sw.stop(); + Expect.isFalse(sw.isRunning); + int initial = sw.elapsedTicks; + sw.start(); + Expect.isTrue(sw.isRunning); + for (int i = 0; i < 100000; i++) { + int.parse(i.toString()); + if (sw.elapsedTicks > initial) { + break; + } + } + sw.stop(); + Expect.isFalse(sw.isRunning); + Expect.isTrue(sw.elapsedTicks > initial); + } + + static checkReset() { + Stopwatch sw = new Stopwatch(); + Expect.isFalse(sw.isRunning); + sw.start(); + Expect.isTrue(sw.isRunning); + for (int i = 0; i < 100000; i++) { + int.parse(i.toString()); + if (sw.elapsedTicks > 0) { + break; + } + } + sw.stop(); + Expect.isFalse(sw.isRunning); + sw.reset(); + Expect.isFalse(sw.isRunning); + Expect.equals(0, sw.elapsedTicks); + sw.start(); + Expect.isTrue(sw.isRunning); + for (int i = 0; i < 100000; i++) { + int.parse(i.toString()); + if (sw.elapsedTicks > 0) { + break; + } + } + sw.reset(); + Expect.isTrue(sw.isRunning); + for (int i = 0; i < 100000; i++) { + int.parse(i.toString()); + if (sw.elapsedTicks > 0) { + break; + } + } + sw.stop(); + Expect.isFalse(sw.isRunning); + Expect.isTrue(sw.elapsedTicks > 0); + } + + static testMain() { + Stopwatch sw = new Stopwatch(); + Expect.isTrue(checkTicking(sw)); + Expect.isTrue(checkStopping(sw)); + checkRestart(); + checkReset(); + } +} + +main() { + StopwatchTest.testMain(); +} diff --git a/tests/corelib/string_base_vm_test.dart b/tests/corelib/string_base_vm_test.dart new file mode 100644 index 00000000000..76ff9ade8fe --- /dev/null +++ b/tests/corelib/string_base_vm_test.dart @@ -0,0 +1,83 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. +// Dart test program for testing class 'StringBase' (currently VM specific). + +library string_base_test; + +import "package:expect/expect.dart"; + +class StringBaseTest { + StringBaseTest() {} + + toString() { + return "StringBase Tester"; + } + + static testInterpolation() { + var answer = 40 + 2; + var s = "The answer is $answer."; + Expect.equals("The answer is 42.", s); + + int numBottles = 33; + String wall = "wall"; + s = "${numBottles*3} bottles of beer on the $wall."; + Expect.equals("99 bottles of beer on the wall.", s); + } + + static testCreation() { + String s = "Hello"; + List a = new List(s.length); + List ga = new List(); + bool exception_caught = false; + for (int i = 0; i < a.length; i++) { + a[i] = s.codeUnitAt(i); + ga.add(s.codeUnitAt(i)); + } + try { + String s4 = new String.fromCharCodes([0.0]); + } on ArgumentError catch (ex) { + exception_caught = true; + } on TypeError catch (ex) { + exception_caught = true; + } + Expect.equals(true, exception_caught); + exception_caught = false; + try { + String s4 = new String.fromCharCodes([-1]); + } on ArgumentError catch (ex) { + exception_caught = true; + } + Expect.equals(true, exception_caught); + } + + static testSubstring() { + String s = "Hello World"; + Expect.equals("World", s.substring(6, s.length)); + Expect.equals("", s.substring(8, 8)); + bool exception_caught = false; + try { + s.substring(5, 12); + } on RangeError catch (ex) { + exception_caught = true; + } + Expect.equals(true, exception_caught); + exception_caught = false; + try { + s.substring(5, 4); + } on RangeError catch (ex) { + exception_caught = true; + } + Expect.equals(true, exception_caught); + } + + static void testMain() { + testInterpolation(); + testCreation(); + testSubstring(); + } +} + +main() { + StringBaseTest.testMain(); +} diff --git a/tests/corelib/string_buffer_test.dart b/tests/corelib/string_buffer_test.dart new file mode 100644 index 00000000000..669bde680b7 --- /dev/null +++ b/tests/corelib/string_buffer_test.dart @@ -0,0 +1,239 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +// TODO(srdjan): Move StringBuffer to visible names. + +void testConstructor() { + StringBuffer bf = new StringBuffer(""); + testBufferLength(0, bf); + + bf = new StringBuffer("abc"); + testBufferLength(3, bf); + Expect.equals("abc", bf.toString()); + + bf = new StringBuffer("\x00"); +} + +void testWrite() { + StringBuffer bf = new StringBuffer(""); + Expect.equals(true, bf.isEmpty); + + bf.write("a"); + testBufferLength(1, bf); + Expect.equals("a", bf.toString()); + + bf = new StringBuffer(""); + bf.write("a"); + bf.write("b"); + Expect.equals("ab", bf.toString()); + + bf = new StringBuffer("abc"); + bf.write("d"); + bf.write("e"); + bf.write("f"); + bf.write("g"); + bf.write("h"); + bf.write("i"); + bf.write("j"); + bf.write("k"); + bf.write("l"); + bf.write("m"); + bf.write("n"); + bf.write("o"); + bf.write("p"); + bf.write("q"); + bf.write("r"); + bf.write("s"); + bf.write("t"); + bf.write("u"); + bf.write("v"); + bf.write("w"); + bf.write("x"); + bf.write("y"); + bf.write("z"); + bf.write("\n"); + bf.write("thequickbrownfoxjumpsoverthelazydog"); + Expect.equals( + "abcdefghijklmnopqrstuvwxyz\n" + "thequickbrownfoxjumpsoverthelazydog", + bf.toString()); + + bf = new StringBuffer(""); + for (int i = 0; i < 100000; i++) { + bf.write(''); + bf.write(""); + } + Expect.equals("", bf.toString()); +} + +void testLength() { + StringBuffer bf = new StringBuffer(""); + testBufferLength(0, bf); + bf.write("foo"); + testBufferLength(3, bf); + bf.write("bar"); + testBufferLength(6, bf); + bf.write(""); + testBufferLength(6, bf); +} + +void testIsEmpty() { + StringBuffer bf = new StringBuffer(""); + Expect.equals(true, bf.isEmpty); + bf.write("foo"); + Expect.equals(false, bf.isEmpty); +} + +void testWriteAll() { + StringBuffer bf = new StringBuffer(""); + bf.writeAll(["foo", "bar", "a", "b", "c"]); + Expect.equals("foobarabc", bf.toString()); + + bf.writeAll([]); + Expect.equals("foobarabc", bf.toString()); + + bf.writeAll(["", "", ""]); + Expect.equals("foobarabc", bf.toString()); + + bf.writeAll(["", "", ""], ""); + Expect.equals("foobarabc", bf.toString()); + + StringBuffer bf2 = new StringBuffer(""); + bf2.writeAll([], "s"); + Expect.equals("", bf2.toString()); + + StringBuffer bf3 = new StringBuffer(""); + bf3.writeAll(["a"], "s"); + Expect.equals("a", bf3.toString()); + + StringBuffer bf4 = new StringBuffer(""); + bf4.writeAll(["a", "b"], "s"); + Expect.equals("asb", bf4.toString()); +} + +void testWriteAll2() { + // Passing `null` for separator is an error that is checked when the iterable + // is not empty. This is not specified in the documentation but we want + // implementations to be consistent. + StringBuffer bf1 = new StringBuffer(""); + bf1.writeAll([], null); + Expect.equals("", bf1.toString()); + + StringBuffer bf2 = new StringBuffer(""); + Expect.throws(() { + bf2.writeAll([1], null); + }); +} + +void testWriteln() { + StringBuffer bf1 = new StringBuffer(""); + bf1.writeln("Hello"); + Expect.equals("Hello\n", bf1.toString()); + + StringBuffer bf2 = new StringBuffer(""); + bf2.writeln(); + Expect.equals("\n", bf2.toString()); + + StringBuffer bf3 = new StringBuffer(""); + bf3.writeln("\n"); + bf3.writeln(null); + bf3.writeln(1); + Expect.equals("\n\nnull\n1\n", bf3.toString()); +} + +void testClear() { + StringBuffer bf = new StringBuffer(""); + bf.write("foo"); + bf.clear(); + Expect.equals("", bf.toString()); + testBufferLength(0, bf); + + bf.write("bar"); + Expect.equals("bar", bf.toString()); + testBufferLength(3, bf); + bf.clear(); + Expect.equals("", bf.toString()); + testBufferLength(0, bf); +} + +void testToString() { + StringBuffer bf = new StringBuffer(""); + Expect.equals("", bf.toString()); + + bf = new StringBuffer("foo"); + Expect.equals("foo", bf.toString()); + + bf = new StringBuffer("foo"); + bf.write("bar"); + Expect.equals("foobar", bf.toString()); +} + +void testChaining() { + StringBuffer bf = new StringBuffer(""); + StringBuffer bf2 = new StringBuffer(""); + bf2.write("bf2"); + bf..write("foo")..write("bar")..write(bf2)..write(bf2)..write("toto"); + Expect.equals("foobarbf2bf2toto", bf.toString()); +} + +void testWriteCharCode() { + StringBuffer bf1 = new StringBuffer(); + StringBuffer bf2 = new StringBuffer(); + bf1.write("a"); + bf2.writeCharCode(0x61); // a + bf1.write("b"); + bf2.writeCharCode(0x62); // b + bf1.write("c"); + bf2.writeCharCode(0x63); // c + bf1.write(new String.fromCharCode(0xD823)); + bf2.writeCharCode(0xD823); + bf1.write(new String.fromCharCode(0xDC23)); + bf2.writeCharCode(0xDC23); + bf1.write("\u{1d49e}"); + bf2.writeCharCode(0x1d49e); + bf1.write("\x00"); + bf2.writeCharCode(0); + Expect.equals(bf1.toString(), bf2.toString()); + Expect.equals("abc\u{18c23}\u{1d49e}\x00", bf2.toString()); + + // Mixing strings and char-codes. + bf1.clear(); + bf1.write("abcde"); + bf1.writeCharCode(0x61); + bf1.writeCharCode(0x62); + bf1.writeCharCode(0x63); + bf1.write("d"); + bf1.writeCharCode(0x65); + Expect.equals("abcdeabcde", bf1.toString()); + + // Out-of-range character codes are not allowed. + Expect.throws(() { + bf2.writeCharCode(-1); + }); + Expect.throws(() { + bf2.writeCharCode(0x110000); + }); +} + +void testBufferLength(int length, StringBuffer bf) { + Expect.equals(length, bf.length); + (length == 0 ? Expect.isTrue : Expect.isFalse)(bf.isEmpty); + (length != 0 ? Expect.isTrue : Expect.isFalse)(bf.isNotEmpty); +} + +void main() { + testToString(); + testConstructor(); + testLength(); + testIsEmpty(); + testWrite(); + testWriteCharCode(); + testWriteAll(); + testWriteAll2(); + testWriteln(); + testClear(); + testChaining(); +} diff --git a/tests/corelib/string_case_test.dart b/tests/corelib/string_case_test.dart new file mode 100644 index 00000000000..b199de732bf --- /dev/null +++ b/tests/corelib/string_case_test.dart @@ -0,0 +1,55 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + testLowerUpper(); + testSpecialCases(); +} + +void testLowerUpper() { + var a = "Stop! Smell the Roses."; + var allLower = "stop! smell the roses."; + var allUpper = "STOP! SMELL THE ROSES."; + Expect.equals(allUpper, a.toUpperCase()); + Expect.equals(allLower, a.toLowerCase()); +} + +void testSpecialCases() { + // Letters in Latin-1 where the upper case is not in Latin-1. + + // German sharp s. Upper case variant is "SS". + Expect.equals("SS", "\xdf".toUpperCase()); // //# 01: ok + Expect.equals("\xdf", "\xdf".toLowerCase()); + Expect.equals("ss", "\xdf".toUpperCase().toLowerCase()); // //# 01: continued + // Micro sign (not same as lower-case Greek letter mu, U+03BC). + Expect.equals("\u039c", "\xb5".toUpperCase()); // //# 02: ok + Expect.equals("\xb5", "\xb5".toLowerCase()); + Expect.equals("\u03Bc", // //# 02: continued + "\xb5".toUpperCase().toLowerCase()); // //# 02: continued + // Small letter y diaresis. + Expect.equals("\u0178", "\xff".toUpperCase()); // //# 03: ok + Expect.equals("\xff", "\xff".toLowerCase()); + Expect.equals("\xff", "\xff".toUpperCase().toLowerCase()); // //# 03: continued + // Zero. + Expect.equals("\x00", "\x00".toLowerCase()); + Expect.equals("\x00", "\x00".toUpperCase()); + + // Test all combinations of ordering of lower-case, upper-case and + // special-when-upper-cased characters. + Expect.equals("AA\u0178", "Aa\xff".toUpperCase()); // //# 03: continued + Expect.equals("AA\u0178", "aA\xff".toUpperCase()); // //# 03: continued + Expect.equals("A\u0178A", "A\xffa".toUpperCase()); // //# 03: continued + Expect.equals("A\u0178A", "a\xffA".toUpperCase()); // //# 03: continued + Expect.equals("\u0178AA", "\xffAa".toUpperCase()); // //# 03: continued + Expect.equals("\u0178AA", "\xffaA".toUpperCase()); // //# 03: continued + + Expect.equals("aa\xff", "Aa\xff".toLowerCase()); + Expect.equals("aa\xff", "aA\xff".toLowerCase()); + Expect.equals("a\xffa", "A\xffa".toLowerCase()); + Expect.equals("a\xffa", "a\xffA".toLowerCase()); + Expect.equals("\xffaa", "\xffAa".toLowerCase()); + Expect.equals("\xffaa", "\xffaA".toLowerCase()); +} diff --git a/tests/corelib/string_codeunits_test.dart b/tests/corelib/string_codeunits_test.dart new file mode 100644 index 00000000000..074b1aba116 --- /dev/null +++ b/tests/corelib/string_codeunits_test.dart @@ -0,0 +1,80 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + test(String s) { + List units = s.codeUnits; + List expectedUnits = []; + for (int i = 0; i < s.length; i++) { + expectedUnits.add(s.codeUnitAt(i)); + } + + Expect.equals(s.length, units.length); + for (int i = 0; i < s.length; i++) { + Expect.equals(s.codeUnitAt(i), units.elementAt(i)); + } + + // for-in + var res = []; + for (int unit in units) { + res.add(unit); + } + Expect.listEquals(expectedUnits, res); + + // .map + Expect.listEquals(expectedUnits.map((x) => x.toRadixString(16)).toList(), + units.map((x) => x.toRadixString(16)).toList()); + + if (s == "") { + Expect.throws(() => units.first, (e) => e is StateError); + Expect.throws(() => units.last, (e) => e is StateError); + Expect.throws(() => units[0], (e) => e is RangeError); + Expect.throws(() => units[0] = 499, (e) => e is UnsupportedError); + Expect.listEquals([], units.sublist(0, 0)); + Expect.equals(-1, units.indexOf(42)); + Expect.equals(-1, units.lastIndexOf(499)); + } else { + Expect.equals(s.codeUnitAt(0), units.first); + Expect.equals(s.codeUnitAt(s.length - 1), units.last); + Expect.equals(s.codeUnitAt(0), units[0]); + Expect.throws(() { + units[0] = 499; + }, (e) => e is UnsupportedError); + List sub = units.sublist(1); + Expect.listEquals(s.substring(1, s.length).codeUnits, sub); + Expect.equals(-1, units.indexOf(-1)); + Expect.equals(0, units.indexOf(units[0])); + Expect.equals(-1, units.lastIndexOf(-1)); + Expect.equals( + units.length - 1, units.lastIndexOf(units[units.length - 1])); + } + + Iterable reversed = units.reversed; + int i = units.length - 1; + for (int codeUnit in reversed) { + Expect.equals(units[i--], codeUnit); + } + } + + test(""); + test("abc"); + test("\x00\u0000\u{000000}"); + test("\u{ffff}\u{10000}\u{10ffff}"); + String string = new String.fromCharCodes( + [0xdc00, 0xd800, 61, 0xd9ab, 0xd9ab, 0xddef, 0xddef, 62, 0xdc00, 0xd800]); + test(string); + string = "\x00\x7f\xff\u0100\ufeff\uffef\uffff" + "\u{10000}\u{12345}\u{1d800}\u{1dc00}\u{1ffef}\u{1ffff}"; + test(string); + + // Reading each unit of a surrogate pair works. + var r = "\u{10000}".codeUnits; + var it = r.iterator; + Expect.isTrue(it.moveNext()); + Expect.equals(0xD800, it.current); + Expect.isTrue(it.moveNext()); + Expect.equals(0xDC00, it.current); +} diff --git a/tests/corelib/string_from_environment2_test.dart b/tests/corelib/string_from_environment2_test.dart new file mode 100644 index 00000000000..b6d81b816d7 --- /dev/null +++ b/tests/corelib/string_from_environment2_test.dart @@ -0,0 +1,12 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. +// SharedOptions=-Da=a -Da=bb -Db=bb -Dc=ccc -Da=ccc -Db=ccc + +import "package:expect/expect.dart"; + +main() { + Expect.equals('ccc', const String.fromEnvironment('a')); + Expect.equals('ccc', const String.fromEnvironment('b')); + Expect.equals('ccc', const String.fromEnvironment('c')); +} diff --git a/tests/corelib/string_from_environment3_test.dart b/tests/corelib/string_from_environment3_test.dart new file mode 100644 index 00000000000..962f5f1de05 --- /dev/null +++ b/tests/corelib/string_from_environment3_test.dart @@ -0,0 +1,11 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +main() { + const String.fromEnvironment('NOT_FOUND', defaultValue: 1); // //# 01: compile-time error + const String.fromEnvironment('NOT_FOUND', defaultValue: true); // //# 02: compile-time error + const String.fromEnvironment(null); // //# 03: compile-time error + const String.fromEnvironment(1); // //# 04: compile-time error + const String.fromEnvironment([]); // //# 05: compile-time error +} diff --git a/tests/corelib/string_from_environment_test.dart b/tests/corelib/string_from_environment_test.dart new file mode 100644 index 00000000000..2134e44da1f --- /dev/null +++ b/tests/corelib/string_from_environment_test.dart @@ -0,0 +1,13 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. +// SharedOptions=-Da=a -Db=bb -Dc=ccc -Dd= + +import "package:expect/expect.dart"; + +main() { + Expect.equals('a', const String.fromEnvironment('a')); + Expect.equals('bb', const String.fromEnvironment('b')); + Expect.equals('ccc', const String.fromEnvironment('c')); + Expect.equals('', const String.fromEnvironment('d')); +} diff --git a/tests/corelib/string_from_list_test.dart b/tests/corelib/string_from_list_test.dart new file mode 100644 index 00000000000..062d6b6f049 --- /dev/null +++ b/tests/corelib/string_from_list_test.dart @@ -0,0 +1,84 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +void main() { + Expect.equals("", new String.fromCharCodes(new List(0))); + Expect.equals("", new String.fromCharCodes([])); + Expect.equals("", new String.fromCharCodes(const [])); + Expect.equals("AB", new String.fromCharCodes([65, 66])); + Expect.equals("AB", new String.fromCharCodes(const [65, 66])); + Expect.equals("Ærø", new String.fromCharCodes(const [0xc6, 0x72, 0xf8])); + Expect.equals("\u{1234}", new String.fromCharCodes([0x1234])); + Expect.equals("\u{12345}*", new String.fromCharCodes([0x12345, 42])); + Expect.equals("", new String.fromCharCodes(new List())); + { + var a = new List(); + a.add(65); + a.add(66); + Expect.equals("AB", new String.fromCharCodes(a)); + } + + // Long list (bug 6919). + for (int len in [499, 500, 501, 999, 100000]) { + List list = new List(len); + for (int i = 0; i < len; i++) { + list[i] = 65 + (i % 26); + } + for (int i = len - 9; i < len; i++) { + list[i] = 48 + (len - i); + } + // We should not throw a stack overflow here. + String long = new String.fromCharCodes(list); + // Minimal sanity checking on the string. + Expect.isTrue(long.startsWith('ABCDE')); + Expect.isTrue(long.endsWith('987654321')); + int middle = len ~/ 2; + middle -= middle % 26; + Expect.equals('XYZABC', long.substring(middle - 3, middle + 3)); + Expect.equals(len, long.length); + } + + // Should work with iterables and non-default-lists (http://dartbug.com/8922) + Expect.equals("CBA", new String.fromCharCodes([65, 66, 67].reversed)); + Expect.equals( + "BCD", new String.fromCharCodes([65, 66, 67].map((x) => x + 1))); + Expect.equals( + "AC", new String.fromCharCodes([0x41, 0x42, 0x43].where((x) => x.isOdd))); + Expect.equals( + "CE", + new String.fromCharCodes( + [0x41, 0x42, 0x43].where((x) => x.isOdd).map((x) => x + 2))); + Expect.equals( + "ABC", new String.fromCharCodes(new Iterable.generate(3, (x) => 65 + x))); + Expect.equals("ABC", new String.fromCharCodes("ABC".codeUnits)); + Expect.equals( + "BCD", new String.fromCharCodes("ABC".codeUnits.map((x) => x + 1))); + Expect.equals("BCD", new String.fromCharCodes("ABC".runes.map((x) => x + 1))); + + var nonBmpCharCodes = [0, 0xD812, 0xDC34, 0x14834, 0xDC34, 0xD812]; + var nonBmp = new String.fromCharCodes(nonBmpCharCodes); + Expect.equals(7, nonBmp.length); + Expect.equals(0, nonBmp.codeUnitAt(0)); + Expect.equals(0xD812, nonBmp.codeUnitAt(1)); // Separated surrogate pair + Expect.equals(0xDC34, nonBmp.codeUnitAt(2)); + Expect.equals(0xD812, nonBmp.codeUnitAt(3)); // Single non-BMP code point. + Expect.equals(0xDC34, nonBmp.codeUnitAt(4)); + Expect.equals(0xDC34, nonBmp.codeUnitAt(5)); // Unmatched surrogate. + Expect.equals(0xD812, nonBmp.codeUnitAt(6)); // Unmatched surrogate. + + var reversedNonBmp = new String.fromCharCodes(nonBmpCharCodes.reversed); + Expect.equals(7, reversedNonBmp.length); + Expect.equals(0, reversedNonBmp.codeUnitAt(6)); + Expect.equals(0xD812, reversedNonBmp.codeUnitAt(5)); + Expect.equals(0xDC34, reversedNonBmp.codeUnitAt(4)); + Expect.equals(0xDC34, reversedNonBmp.codeUnitAt(3)); + Expect.equals(0xD812, reversedNonBmp.codeUnitAt(2)); + Expect.equals(0xDC34, reversedNonBmp.codeUnitAt(1)); + Expect.equals(0xD812, reversedNonBmp.codeUnitAt(0)); + + Expect.equals(nonBmp, new String.fromCharCodes(nonBmp.codeUnits)); + Expect.equals(nonBmp, new String.fromCharCodes(nonBmp.runes)); +} diff --git a/tests/corelib/string_fromcharcode_test.dart b/tests/corelib/string_fromcharcode_test.dart new file mode 100644 index 00000000000..fcc874dcdda --- /dev/null +++ b/tests/corelib/string_fromcharcode_test.dart @@ -0,0 +1,31 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + Expect.equals("A", new String.fromCharCode(65)); + Expect.equals("B", new String.fromCharCode(66)); + var gClef = new String.fromCharCode(0x1D11E); + Expect.equals(2, gClef.length); + Expect.equals(0xD834, gClef.codeUnitAt(0)); + Expect.equals(0xDD1E, gClef.codeUnitAt(1)); + + // Unmatched surrogates. + var unmatched = new String.fromCharCode(0xD800); + Expect.equals(1, unmatched.length); + Expect.equals(0xD800, unmatched.codeUnitAt(0)); + unmatched = new String.fromCharCode(0xDC00); + Expect.equals(1, unmatched.length); + Expect.equals(0xDC00, unmatched.codeUnitAt(0)); + + Expect.throws(() => new String.fromCharCode(-1), (e) => e is ArgumentError); + + // Invalid code point. + Expect.throws( + () => new String.fromCharCode(0x110000), (e) => e is ArgumentError); + + Expect.throws( + () => new String.fromCharCode(0x110001), (e) => e is ArgumentError); +} diff --git a/tests/corelib/string_fromcharcodes_test.dart b/tests/corelib/string_fromcharcodes_test.dart new file mode 100644 index 00000000000..c5b90a79516 --- /dev/null +++ b/tests/corelib/string_fromcharcodes_test.dart @@ -0,0 +1,292 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; +import "dart:typed_data"; + +main() { + iter(count, [values]) => values is List + ? new Iterable.generate(count, (x) => values[x]) + : new Iterable.generate(count, (x) => values); + test(expect, iter, [start = 0, end]) { + var actual = new String.fromCharCodes(iter, start, end); + Expect.equals(expect, actual); + } + + testThrows(iterable, [start = 0, end]) { + Expect.throws(() { + new String.fromCharCodes(iterable, start, end); + }); + } + + test("", iter(0)); + test("", []); + test("", const []); + test("", new List(0)); + test("", new Uint8List(0)); + test("", new Uint16List(0)); + test("", new Uint32List(0)); + test("", "".codeUnits); + + test("\x00", iter(1, 0)); + test("\x00", [0]); + test("\x00", const [0]); + test("\x00", new List(1)..[0] = 0); + test("\x00", new Uint8List(1)); + test("\x00", new Uint16List(1)); + test("\x00", new Uint32List(1)); + test("\x00", "\x00".codeUnits); + + test("\xff", iter(1, 255)); + test("\xFF", [255]); + test("\xFF", const [255]); + test("\xFF", new List(1)..[0] = 255); + test("\xFF", new Uint8List(1)..[0] = 255); + test("\xFF", new Uint16List(1)..[0] = 255); + test("\xFF", new Uint32List(1)..[0] = 255); + test("\xFF", "\xFF".codeUnits); + + test("\u0100", iter(1, 256)); + test("\u0100", [256]); + test("\u0100", const [256]); + test("\u0100", new List(1)..[0] = 256); + test("\u0100", new Uint16List(1)..[0] = 256); + test("\u0100", new Uint32List(1)..[0] = 256); + test("\u0100", "\u0100".codeUnits); + + test("\uffff", iter(1, 65535)); + test("\uffff", [65535]); + test("\uffff", const [65535]); + test("\uffff", new List(1)..[0] = 65535); + test("\uffff", new Uint16List(1)..[0] = 65535); + test("\uffff", new Uint32List(1)..[0] = 65535); + test("\uffff", "\uffff".codeUnits); + + test("\u{10000}", iter(1, 65536)); + test("\u{10000}", [65536]); + test("\u{10000}", const [65536]); + test("\u{10000}", new List(1)..[0] = 65536); + test("\u{10000}", new Uint32List(1)..[0] = 65536); + test("\u{10000}", "\u{10000}".codeUnits); + + test("\u{10FFFF}", iter(1, 0x10FFFF)); + test("\u{10FFFF}", [0x10FFFF]); + test("\u{10FFFF}", const [0x10FFFF]); + test("\u{10FFFF}", new List(1)..[0] = 0x10FFFF); + test("\u{10FFFF}", new Uint32List(1)..[0] = 0x10FFFF); + + test("\u{10ffff}", iter(2, [0xDBFF, 0xDFFF])); + test("\u{10ffff}", [0xDBFF, 0xDFFF]); + test("\u{10ffff}", const [0xDBFF, 0xDFFF]); + test( + "\u{10ffff}", + new List(2) + ..[0] = 0xDBFF + ..[1] = 0xDFFF); + test( + "\u{10ffff}", + new Uint16List(2) + ..[0] = 0xDBFF + ..[1] = 0xDFFF); + test( + "\u{10ffff}", + new Uint32List(2) + ..[0] = 0xDBFF + ..[1] = 0xDFFF); + test("\u{10FFFF}", "\u{10FFFF}".codeUnits); + + var leadSurrogate = "\u{10ffff}"[0]; + test(leadSurrogate, iter(1, 0xDBFF)); + test(leadSurrogate, [0xDBFF]); + test(leadSurrogate, const [0xDBFF]); + test(leadSurrogate, new List(1)..[0] = 0xDBFF); + test(leadSurrogate, new Uint16List(1)..[0] = 0xDBFF); + test(leadSurrogate, new Uint32List(1)..[0] = 0xDBFF); + test(leadSurrogate, leadSurrogate.codeUnits); + + var tailSurrogate = "\u{10ffff}"[1]; + test(tailSurrogate, iter(1, 0xDFFF)); + test(tailSurrogate, [0xDFFF]); + test(tailSurrogate, const [0xDFFF]); + test(tailSurrogate, new List(1)..[0] = 0xDFFF); + test(tailSurrogate, new Uint16List(1)..[0] = 0xDFFF); + test(tailSurrogate, new Uint32List(1)..[0] = 0xDFFF); + test(tailSurrogate, tailSurrogate.codeUnits); + + testThrows(null); + testThrows("not an iterable"); + testThrows(42); + testThrows([-1]); + testThrows(new List(1)..[0] = -1); + testThrows(const [-1]); + testThrows(new Int8List(1)..[0] = -1); + testThrows(new Int16List(1)..[0] = -1); + testThrows(new Int32List(1)..[0] = -1); + testThrows([0x110000]); + testThrows(new List(1)..[0] = 0x110000); + testThrows(const [0x110000]); + testThrows(new Int32List(1)..[0] = 0x110000); + + // Check start/end + var list = const [0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48]; + for (var iterable in [ + iter(list.length, list), + list.toList(growable: true), + list.toList(growable: false), + list, + new Uint8List(8)..setRange(0, 8, list), + new Uint16List(8)..setRange(0, 8, list), + new Uint32List(8)..setRange(0, 8, list), + "ABCDEFGH".codeUnits, + ]) { + test("ABCDEFGH", iterable); + // start varies, end is null. + test("ABCDEFGH", iterable, 0); + test("BCDEFGH", iterable, 1); + test("H", iterable, 7); + test("", iterable, 8); + // start = 0, end varies. + test("ABCDEFGH", iterable, 0); + test("A", iterable, 0, 1); + test("AB", iterable, 0, 2); + test("ABCDEFG", iterable, 0, 7); + test("ABCDEFGH", iterable, 0, 8); + test("", iterable, 0, 0); + // Both varying. + test("ABCDEFGH", iterable, 0, 8); + test("AB", iterable, 0, 2); + test("GH", iterable, 6, 8); + test("DE", iterable, 3, 5); + test("", iterable, 3, 3); + } + // Can split surrogates in input, but not a single big code point. + test(leadSurrogate, [0xDBFF, 0xDFFF], 0, 1); + test(tailSurrogate, [0xDBFF, 0xDFFF], 1); + test("\u{10FFFF}", [0x10FFFF], 0, 1); + + void testThrowsRange(iterable, [start = 0, end]) { + Expect.throws(() => new String.fromCharCodes(iterable, start, end), + (e) => e is RangeError); + } + + // Test varying slices of the code units of a string. + testSubstring(string) { + var codes = string.codeUnits; + int length = string.length; + for (var iterable in [ + iter(length, codes), + codes.toList(growable: true), + codes.toList(growable: false), + new Uint16List(length)..setRange(0, length, codes), + new Int32List(length)..setRange(0, length, codes), + new Uint32List(length)..setRange(0, length, codes), + codes, + ]) { + var newString = new String.fromCharCodes(iterable); + Expect.equals(string, newString); + for (int i = 0; i < length; i = i * 2 + 1) { + test(string.substring(i), iterable, i); + test(string.substring(0, i), iterable, 0, i); + for (int j = 0; i + j < length; j = j * 2 + 1) { + test(string.substring(i, i + j), iterable, i, i + j); + } + } + + testThrowsRange(iterable, -1); + testThrowsRange(iterable, 0, -1); + testThrowsRange(iterable, 2, 1); + testThrowsRange(iterable, 0, length + 1); + testThrowsRange(iterable, length + 1); + testThrowsRange(iterable, length + 1, length + 2); + } + } + + testSubstring(""); + testSubstring("ABCDEFGH"); + // length > 128 + testSubstring("ABCDEFGH" * 33); + testSubstring("\x00" * 357); + // length > 128 and non-ASCII. + testSubstring("\uFFFD\uFFFE\u{10000}\u{10ffff}c\x00" * 37); + + // Large List. + var megaList = ("abcde" * 200000).codeUnits.toList(); + test("abcde" * 199998, megaList, 5, 999995); + // Large Uint8List. + test("abcde" * 199998, new Uint8List.fromList(megaList), 5, 999995); + + const cLatin1 = const [0x00, 0xff]; + const cUtf16 = const [0x00, 0xffff, 0xdfff, 0xdbff, 0xdfff, 0xdbff]; + const cCodepoints = const [0x00, 0xffff, 0xdfff, 0x10ffff, 0xdbff]; + List gLatin1 = cLatin1.toList(growable: true); + List gUtf16 = cUtf16.toList(growable: true); + List gCodepoints = cCodepoints.toList(growable: true); + List fLatin1 = cLatin1.toList(growable: false); + List fUtf16 = cUtf16.toList(growable: false); + List fCodepoints = cCodepoints.toList(growable: false); + Uint8List bLatin1 = new Uint8List(2)..setRange(0, 2, cLatin1); + Uint16List wLatin1 = new Uint16List(2)..setRange(0, 2, cLatin1); + Uint16List wUtf16 = new Uint16List(6)..setRange(0, 6, cUtf16); + Uint32List lLatin1 = new Uint32List(2)..setRange(0, 2, cLatin1); + Uint32List lUtf16 = new Uint32List(6)..setRange(0, 6, cUtf16); + Uint32List lCodepoints = new Uint32List(5)..setRange(0, 5, cCodepoints); + Uint8List bvLatin1 = new Uint8List.view(bLatin1.buffer); + Uint16List wvLatin1 = new Uint16List.view(wLatin1.buffer); + Uint16List wvUtf16 = new Uint16List.view(wUtf16.buffer); + Uint32List lvLatin1 = new Uint32List.view(lLatin1.buffer); + Uint32List lvUtf16 = new Uint32List.view(lUtf16.buffer); + Uint32List lvCodepoints = new Uint32List.view(lCodepoints.buffer); + var buffer = new Uint8List(200).buffer; + Uint8List bbLatin1 = new Uint8List.view(buffer, 3, 2)..setAll(0, bLatin1); + Uint16List wbLatin1 = new Uint16List.view(buffer, 8, 2)..setAll(0, wLatin1); + Uint16List wbUtf16 = new Uint16List.view(buffer, 16, 6)..setAll(0, wUtf16); + Uint32List lbLatin1 = new Uint32List.view(buffer, 32, 2)..setAll(0, lLatin1); + Uint32List lbUtf16 = new Uint32List.view(buffer, 64, 6)..setAll(0, lUtf16); + Uint32List lbCodepoints = new Uint32List.view(buffer, 128, 5) + ..setAll(0, lCodepoints); + + String sLatin1 = "\x00\xff"; + String sUnicode = + "\x00\uffff$tailSurrogate$leadSurrogate$tailSurrogate$leadSurrogate"; + for (int i = 0; i < 2; i++) { + for (int j = i + 1; j < 2; j++) { + test(sLatin1.substring(i, j), cLatin1, i, j); + test(sLatin1.substring(i, j), gLatin1, i, j); + test(sLatin1.substring(i, j), fLatin1, i, j); + test(sLatin1.substring(i, j), bLatin1, i, j); + test(sLatin1.substring(i, j), wLatin1, i, j); + test(sLatin1.substring(i, j), lLatin1, i, j); + test(sLatin1.substring(i, j), bvLatin1, i, j); + test(sLatin1.substring(i, j), wvLatin1, i, j); + test(sLatin1.substring(i, j), lvLatin1, i, j); + test(sLatin1.substring(i, j), bbLatin1, i, j); + test(sLatin1.substring(i, j), wbLatin1, i, j); + test(sLatin1.substring(i, j), lbLatin1, i, j); + } + } + for (int i = 0; i < 6; i++) { + for (int j = i + 1; j < 6; j++) { + test(sUnicode.substring(i, j), cUtf16, i, j); + test(sUnicode.substring(i, j), gUtf16, i, j); + test(sUnicode.substring(i, j), fUtf16, i, j); + test(sUnicode.substring(i, j), wUtf16, i, j); + test(sUnicode.substring(i, j), lUtf16, i, j); + test(sUnicode.substring(i, j), wvUtf16, i, j); + test(sUnicode.substring(i, j), lvUtf16, i, j); + test(sUnicode.substring(i, j), wbUtf16, i, j); + test(sUnicode.substring(i, j), lbUtf16, i, j); + } + } + for (int i = 0; i < 5; i++) { + for (int j = i + 1; j < 5; j++) { + int stringEnd = j < 4 ? j : j + 1; + test(sUnicode.substring(i, stringEnd), cCodepoints, i, j); + test(sUnicode.substring(i, stringEnd), gCodepoints, i, j); + test(sUnicode.substring(i, stringEnd), fCodepoints, i, j); + test(sUnicode.substring(i, stringEnd), lCodepoints, i, j); + test(sUnicode.substring(i, stringEnd), lvCodepoints, i, j); + test(sUnicode.substring(i, stringEnd), lbCodepoints, i, j); + } + } +} diff --git a/tests/corelib/string_operations_with_null_test.dart b/tests/corelib/string_operations_with_null_test.dart new file mode 100644 index 00000000000..a05b98592e3 --- /dev/null +++ b/tests/corelib/string_operations_with_null_test.dart @@ -0,0 +1,17 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +@NoInline() +@AssumeDynamic() +returnStringOrNull() { + return new DateTime.now().millisecondsSinceEpoch == 0 ? 'foo' : null; +} + +main() { + Expect.throws(() => 'foo' + returnStringOrNull(), (e) => e is ArgumentError); + Expect.throws(() => 'foo'.split(returnStringOrNull()), + (e) => e is ArgumentError || e is NoSuchMethodError); +} diff --git a/tests/corelib/string_pattern_test.dart b/tests/corelib/string_pattern_test.dart new file mode 100644 index 00000000000..9a4555e8e14 --- /dev/null +++ b/tests/corelib/string_pattern_test.dart @@ -0,0 +1,111 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. +// Dart test for testing String.allMatches. + +import "package:expect/expect.dart"; + +String str = "this is a string with hello here and hello there"; + +main() { + testNoMatch(); + testOneMatch(); + testTwoMatches(); + testEmptyPattern(); + testEmptyString(); + testEmptyPatternAndString(); + testMatchAsPrefix(); + testAllMatchesStart(); +} + +testNoMatch() { + // Also tests that RegExp groups don't work. + String helloPattern = "with (hello)"; + Iterable matches = helloPattern.allMatches(str); + Expect.isFalse(matches.iterator.moveNext()); +} + +testOneMatch() { + String helloPattern = "with hello"; + Iterable matches = helloPattern.allMatches(str); + var iterator = matches.iterator; + Expect.isTrue(iterator.moveNext()); + Match match = iterator.current; + Expect.isFalse(iterator.moveNext()); + Expect.equals(str.indexOf('with', 0), match.start); + Expect.equals(str.indexOf('with', 0) + helloPattern.length, match.end); + Expect.equals(helloPattern, match.pattern); + Expect.equals(str, match.input); + Expect.equals(helloPattern, match[0]); + Expect.equals(0, match.groupCount); +} + +testTwoMatches() { + String helloPattern = "hello"; + Iterable matches = helloPattern.allMatches(str); + + int count = 0; + int start = 0; + for (var match in matches) { + count++; + Expect.equals(str.indexOf('hello', start), match.start); + Expect.equals(str.indexOf('hello', start) + helloPattern.length, match.end); + Expect.equals(helloPattern, match.pattern); + Expect.equals(str, match.input); + Expect.equals(helloPattern, match[0]); + Expect.equals(0, match.groupCount); + start = match.end; + } + Expect.equals(2, count); +} + +testEmptyPattern() { + String pattern = ""; + Iterable matches = pattern.allMatches(str); + Expect.isTrue(matches.iterator.moveNext()); +} + +testEmptyString() { + String pattern = "foo"; + String str = ""; + Iterable matches = pattern.allMatches(str); + Expect.isFalse(matches.iterator.moveNext()); +} + +testEmptyPatternAndString() { + String pattern = ""; + String str = ""; + Iterable matches = pattern.allMatches(str); + Expect.isTrue(matches.iterator.moveNext()); +} + +testMatchAsPrefix() { + String pattern = "an"; + String str = "banana"; + Expect.isNull(pattern.matchAsPrefix(str)); + Expect.isNull(pattern.matchAsPrefix(str, 0)); + var m = pattern.matchAsPrefix(str, 1); + Expect.equals("an", m[0]); + Expect.equals(1, m.start); + Expect.isNull(pattern.matchAsPrefix(str, 2)); + m = pattern.matchAsPrefix(str, 3); + Expect.equals("an", m[0]); + Expect.equals(3, m.start); + Expect.isNull(pattern.matchAsPrefix(str, 4)); + Expect.isNull(pattern.matchAsPrefix(str, 5)); + Expect.isNull(pattern.matchAsPrefix(str, 6)); + Expect.throws(() => pattern.matchAsPrefix(str, -1)); + Expect.throws(() => pattern.matchAsPrefix(str, 7)); +} + +testAllMatchesStart() { + String p = "ass"; + String s = "assassin"; + Expect.equals(2, p.allMatches(s).length); + Expect.equals(2, p.allMatches(s, 0).length); + Expect.equals(1, p.allMatches(s, 1).length); + Expect.equals(0, p.allMatches(s, 4).length); + Expect.equals(0, p.allMatches(s, s.length).length); + Expect.throws(() => p.allMatches(s, -1)); + Expect.throws(() => p.allMatches(s, s.length + 1)); +} diff --git a/tests/corelib/string_replace_all_test.dart b/tests/corelib/string_replace_all_test.dart new file mode 100644 index 00000000000..548ad624d72 --- /dev/null +++ b/tests/corelib/string_replace_all_test.dart @@ -0,0 +1,140 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +testReplaceAll() { + Expect.equals("aXXcaXXdae", "abcabdae".replaceAll("b", "XX")); + + // Test with the replaced string at the beginning. + Expect.equals("XXbcXXbdXXe", "abcabdae".replaceAll("a", "XX")); + + // Test with the replaced string at the end. + Expect.equals("abcabdaXX", "abcabdae".replaceAll("e", "XX")); + + // Test when there are no occurence of the string to replace. + Expect.equals("abcabdae", "abcabdae".replaceAll("f", "XX")); + + // Test when the string to change is the empty string. + Expect.equals("", "".replaceAll("from", "to")); + + // Test when the string to change is a substring of the string to + // replace. + Expect.equals("fro", "fro".replaceAll("from", "to")); + + // Test when the string to change is the replaced string. + Expect.equals("to", "from".replaceAll("from", "to")); + + // Test when matches are adjacent + Expect.equals("toto", "fromfrom".replaceAll("from", "to")); + + // Test when the string to change is the replacement string. + Expect.equals("to", "to".replaceAll("from", "to")); + + // Test replacing by the empty string. + Expect.equals("bcbde", "abcabdae".replaceAll("a", "")); + Expect.equals("AB", "AfromB".replaceAll("from", "")); + + // Test changing the empty string. + Expect.equals("to", "".replaceAll("", "to")); + + // Test replacing the empty string. + Expect.equals("toAtoBtoCto", "ABC".replaceAll("", "to")); + + // Pattern strings containing RegExp metacharacters - these are not + // interpreted as RegExps. + Expect.equals(r"$$", "||".replaceAll("|", r"$")); + Expect.equals(r"$$$$", "||".replaceAll("|", r"$$")); + Expect.equals(r"x$|x", "x|.|x".replaceAll("|.", r"$")); + Expect.equals(r"$$", "..".replaceAll(".", r"$")); + Expect.equals(r"[$$$$]", "[..]".replaceAll(".", r"$$")); + Expect.equals(r"[$]", "[..]".replaceAll("..", r"$")); + Expect.equals(r"$$", r"\\".replaceAll(r"\", r"$")); +} + +testReplaceAllMapped() { + String mark(Match m) => "[${m[0]}]"; + Expect.equals("a[b]ca[b]dae", "abcabdae".replaceAllMapped("b", mark)); + + // Test with the replaced string at the beginning. + Expect.equals("[a]bc[a]bd[a]e", "abcabdae".replaceAllMapped("a", mark)); + + // Test with the replaced string at the end. + Expect.equals("abcabda[e]", "abcabdae".replaceAllMapped("e", mark)); + + // Test when there are no occurence of the string to replace. + Expect.equals("abcabdae", "abcabdae".replaceAllMapped("f", mark)); + + // Test when the string to change is the empty string. + Expect.equals("", "".replaceAllMapped("from", mark)); + + // Test when the string to change is a substring of the string to + // replace. + Expect.equals("fro", "fro".replaceAllMapped("from", mark)); + + // Test when matches are adjacent + Expect.equals("[from][from]", "fromfrom".replaceAllMapped("from", mark)); + + // Test replacing by the empty string. + Expect.equals("bcbde", "abcabdae".replaceAllMapped("a", (m) => "")); + Expect.equals("AB", "AfromB".replaceAllMapped("from", (m) => "")); + + // Test changing the empty string. + Expect.equals("[]", "".replaceAllMapped("", mark)); + + // Test replacing the empty string. + Expect.equals("[]A[]B[]C[]", "ABC".replaceAllMapped("", mark)); +} + +testSplitMapJoin() { + String mark(Match m) => "[${m[0]}]"; + String wrap(String s) => "<${s}>"; + + Expect.equals("[b][b]", + "abcabdae".splitMapJoin("b", onMatch: mark, onNonMatch: wrap)); + + // Test with the replaced string at the beginning. + Expect.equals("<>[a][a][a]", + "abcabdae".splitMapJoin("a", onMatch: mark, onNonMatch: wrap)); + + // Test with the replaced string at the end. + Expect.equals("[e]<>", + "abcabdae".splitMapJoin("e", onMatch: mark, onNonMatch: wrap)); + + // Test when there are no occurence of the string to replace. + Expect.equals("", + "abcabdae".splitMapJoin("f", onMatch: mark, onNonMatch: wrap)); + + // Test when the string to change is the empty string. + Expect.equals("<>", "".splitMapJoin("from", onMatch: mark, onNonMatch: wrap)); + + // Test when the string to change is a substring of the string to + // replace. + Expect.equals( + "", "fro".splitMapJoin("from", onMatch: mark, onNonMatch: wrap)); + + // Test when matches are adjacent + Expect.equals("<>[from]<>[from]<>", + "fromfrom".splitMapJoin("from", onMatch: mark, onNonMatch: wrap)); + + // Test changing the empty string. + Expect.equals("<>[]<>", "".splitMapJoin("", onMatch: mark, onNonMatch: wrap)); + + // Test replacing the empty string. + Expect.equals("<>[][][][]<>", + "ABC".splitMapJoin("", onMatch: mark, onNonMatch: wrap)); + + // Test with only onMatch. + Expect.equals("[a]bc[a]bd[a]e", "abcabdae".splitMapJoin("a", onMatch: mark)); + + // Test with only onNonMatch + Expect.equals( + "<>aaa", "abcabdae".splitMapJoin("a", onNonMatch: wrap)); +} + +main() { + testReplaceAll(); + testReplaceAllMapped(); + testSplitMapJoin(); +} diff --git a/tests/corelib/string_replace_dollar_test.dart b/tests/corelib/string_replace_dollar_test.dart new file mode 100644 index 00000000000..c0077a05965 --- /dev/null +++ b/tests/corelib/string_replace_dollar_test.dart @@ -0,0 +1,27 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + String jsText = r"""'$' +"""; + String htmlStr = '%%DART'; + String htmlOut = htmlStr.replaceAll("%%DART", jsText); + Expect.equals(jsText, htmlOut); + htmlOut = htmlStr.replaceFirst("%%DART", jsText); + Expect.equals(jsText, htmlOut); + htmlOut = htmlStr.replaceAll(new RegExp("%%DART"), jsText); + Expect.equals(jsText, htmlOut); + htmlOut = htmlStr.replaceFirst(new RegExp("%%DART"), jsText); + Expect.equals(jsText, htmlOut); + + // Regression test, http://dartbug.com/17886 + String doubleDollar = r"$'$`"; + var string = r"flip-flip-flop"; + var result = string.replaceFirst("flip", doubleDollar); + Expect.equals(r"$'$`-flip-flop", result); + result = string.replaceAll("flip", doubleDollar); + Expect.equals(r"$'$`-$'$`-flop", result); +} diff --git a/tests/corelib/string_replace_test.dart b/tests/corelib/string_replace_test.dart new file mode 100644 index 00000000000..80bbe4cc242 --- /dev/null +++ b/tests/corelib/string_replace_test.dart @@ -0,0 +1,227 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + // Test replaceFirst. + Expect.equals("AtoBtoCDtoE", "AfromBtoCDtoE".replaceFirst("from", "to")); + + // Test with the replaced string at the beginning. + Expect.equals("toABtoCDtoE", "fromABtoCDtoE".replaceFirst("from", "to")); + + // Test with the replaced string at the end. + Expect.equals("toABtoCDtoEto", "fromABtoCDtoEto".replaceFirst("from", "to")); + + // Test when there are no occurence of the string to replace. + Expect.equals("ABC", "ABC".replaceFirst("from", "to")); + + // Test when the string to change is the empty string. + Expect.equals("", "".replaceFirst("from", "to")); + + // Test when the string to change is a substring of the string to + // replace. + Expect.equals("fro", "fro".replaceFirst("from", "to")); + + // Test when the string to change is the replaced string. + Expect.equals("to", "from".replaceFirst("from", "to")); + + // Test when the string to change is the replacement string. + Expect.equals("to", "to".replaceFirst("from", "to")); + + // Test replacing by the empty string. + Expect.equals("", "from".replaceFirst("from", "")); + Expect.equals("AB", "AfromB".replaceFirst("from", "")); + + // Test changing the empty string. + Expect.equals("to", "".replaceFirst("", "to")); + + // Test replacing the empty string. + Expect.equals("toAtoBtoCto", "AtoBtoCto".replaceFirst("", "to")); + + // Test startIndex. + Expect.equals( + "foo-AAA-foo-bar", "foo-bar-foo-bar".replaceFirst("bar", "AAA", 4)); + + // Test startIndex skipping one case at the beginning. + Expect.equals( + "foo-bar-AAA-bar", "foo-bar-foo-bar".replaceFirst("foo", "AAA", 1)); + + // Test startIndex skipping one case at the beginning. + Expect.equals( + "foo-bar-foo-AAA", "foo-bar-foo-bar".replaceFirst("bar", "AAA", 5)); + + // Test startIndex replacing with the empty string. + Expect.equals("foo-bar--bar", "foo-bar-foo-bar".replaceFirst("foo", "", 1)); + + // Test startIndex with a RegExp with carat + Expect.equals("foo-bar-foo-bar", + "foo-bar-foo-bar".replaceFirst(new RegExp(r"^foo"), "", 8)); + + // Test startIndex with a RegExp + Expect.equals( + "aaa{3}X{3}", "aaa{3}aaa{3}".replaceFirst(new RegExp(r"a{3}"), "X", 1)); + + // Test startIndex with regexp-looking String + Expect.equals("aaa{3}aaX", "aaa{3}aaa{3}".replaceFirst("a{3}", "X", 3)); + + // Test negative startIndex + Expect.throws( + () => "hello".replaceFirst("h", "X", -1), (e) => e is RangeError); + + // Test startIndex too large + Expect.throws( + () => "hello".replaceFirst("h", "X", 6), (e) => e is RangeError); + + // Test null startIndex + Expect.throws( + () => "hello".replaceFirst("h", "X", null), (e) => e is ArgumentError); + + // Test object startIndex + Expect.throws(() => "hello".replaceFirst("h", "X", new Object())); + + // Test replaceFirstMapped. + + Expect.equals( + "AtoBtoCDtoE", "AfromBtoCDtoE".replaceFirstMapped("from", (_) => "to")); + + // Test with the replaced string at the beginning. + Expect.equals( + "toABtoCDtoE", "fromABtoCDtoE".replaceFirstMapped("from", (_) => "to")); + + // Test with the replaced string at the end. + Expect.equals("toABtoCDtoEto", + "fromABtoCDtoEto".replaceFirstMapped("from", (_) => "to")); + + // Test when there are no occurence of the string to replace. + Expect.equals("ABC", "ABC".replaceFirstMapped("from", (_) => "to")); + + // Test when the string to change is the empty string. + Expect.equals("", "".replaceFirstMapped("from", (_) => "to")); + + // Test when the string to change is a substring of the string to + // replace. + Expect.equals("fro", "fro".replaceFirstMapped("from", (_) => "to")); + + // Test when the string to change is the replaced string. + Expect.equals("to", "from".replaceFirstMapped("from", (_) => "to")); + + // Test when the string to change is the replacement string. + Expect.equals("to", "to".replaceFirstMapped("from", (_) => "to")); + + // Test replacing by the empty string. + Expect.equals("", "from".replaceFirstMapped("from", (_) => "")); + Expect.equals("AB", "AfromB".replaceFirstMapped("from", (_) => "")); + + // Test changing the empty string. + Expect.equals("to", "".replaceFirstMapped("", (_) => "to")); + + // Test replacing the empty string. + Expect.equals("toAtoBtoCto", "AtoBtoCto".replaceFirstMapped("", (_) => "to")); + + // Test startIndex. + Expect.equals("foo-AAA-foo-bar", + "foo-bar-foo-bar".replaceFirstMapped("bar", (_) => "AAA", 4)); + + // Test startIndex skipping one case at the beginning. + Expect.equals("foo-bar-AAA-bar", + "foo-bar-foo-bar".replaceFirstMapped("foo", (_) => "AAA", 1)); + + // Test startIndex skipping one case at the beginning. + Expect.equals("foo-bar-foo-AAA", + "foo-bar-foo-bar".replaceFirstMapped("bar", (_) => "AAA", 5)); + + // Test startIndex replacing with the empty string. + Expect.equals("foo-bar--bar", + "foo-bar-foo-bar".replaceFirstMapped("foo", (_) => "", 1)); + + // Test startIndex with a RegExp with carat + Expect.equals("foo-bar-foo-bar", + "foo-bar-foo-bar".replaceFirstMapped(new RegExp(r"^foo"), (_) => "", 8)); + + // Test startIndex with a RegExp + Expect.equals("aaa{3}X{3}", + "aaa{3}aaa{3}".replaceFirstMapped(new RegExp(r"a{3}"), (_) => "X", 1)); + + // Test startIndex with regexp-looking String + Expect.equals( + "aaa{3}aaX", "aaa{3}aaa{3}".replaceFirstMapped("a{3}", (_) => "X", 3)); + + // Test negative startIndex + Expect.throws(() => "hello".replaceFirstMapped("h", (_) => "X", -1), + (e) => e is RangeError); + + // Test startIndex too large + Expect.throws(() => "hello".replaceFirstMapped("h", (_) => "X", 6), + (e) => e is RangeError); + + // Test null startIndex + Expect.throws(() => "hello".replaceFirstMapped("h", (_) => "X", null), + (e) => e is ArgumentError); + + // Test object startIndex + Expect + .throws(() => "hello".replaceFirstMapped("h", (_) => "X", new Object())); + + // Test replacement depending on argument. + Expect.equals("foo-BAR-foo-bar", + "foo-bar-foo-bar".replaceFirstMapped("bar", (v) => v[0].toUpperCase())); + + Expect.equals("foo-[bar]-foo-bar", + "foo-bar-foo-bar".replaceFirstMapped("bar", (v) => "[${v[0]}]")); + + Expect.equals("foo-foo-bar-foo-bar-foo-bar", + "foo-bar-foo-bar".replaceFirstMapped("bar", (v) => v.input)); + + // Test replacement throwing. + Expect.throws(() => "foo-bar".replaceFirstMapped("bar", (v) => throw 42), + (e) => e == 42); + + // Test replacement returning non-String. + var o = new Object(); + Expect.equals( + "foo-$o", + "foo-bar".replaceFirstMapped("bar", (v) { + return o; + })); + + Expect.equals( + "foo-42", + "foo-bar".replaceFirstMapped("bar", (v) { + return 42; + })); + + // Test replacement returning object throwing on string-conversion. + var n = new Naughty(); + Expect.throws(() => "foo-bar".replaceFirstMapped("bar", (v) { + return n; + })); + + for (var string in ["", "x", "foo", "x\u2000z"]) { + for (var replacement in ["", "foo", string]) { + for (int start = 0; start <= string.length; start++) { + var expect; + for (int end = start; end <= string.length; end++) { + expect = + string.substring(0, start) + replacement + string.substring(end); + Expect.equals(expect, string.replaceRange(start, end, replacement), + '"$string"[$start:$end]="$replacement"'); + } + // Reuse expect from "end == string.length" case when omitting end. + Expect.equals(expect, string.replaceRange(start, null, replacement), + '"$string"[$start:]="$replacement"'); + } + } + Expect.throws(() => string.replaceRange(0, 0, null)); + Expect.throws(() => string.replaceRange(0, 0, 42)); + Expect.throws(() => string.replaceRange(0, 0, ["x"])); + Expect.throws(() => string.replaceRange(-1, 0, "x")); + Expect.throws(() => string.replaceRange(0, string.length + 1, "x")); + } +} + +// Fails to return a String on toString, throws if converted by "$naughty". +class Naughty { + toString() => this; +} diff --git a/tests/corelib/string_runes_test.dart b/tests/corelib/string_runes_test.dart new file mode 100644 index 00000000000..fd0f4f3b1e0 --- /dev/null +++ b/tests/corelib/string_runes_test.dart @@ -0,0 +1,84 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + test(String s, List expectedRunes) { + Runes runes = s.runes; + Expect.identical(s, runes.string); + + // for-in + var res = []; + for (int rune in runes) { + res.add(rune); + } + Expect.listEquals(expectedRunes, res); + + // manual iteration, backwards. + res = []; + for (var it = runes.iterator..reset(s.length); it.movePrevious();) { + res.add(it.current); + } + Expect.listEquals(expectedRunes.reversed.toList(), res); + + // Setting rawIndex. + RuneIterator it = runes.iterator; + it.rawIndex = 1; + Expect.equals(expectedRunes[1], it.current); + + it = runes.iterator; + it.moveNext(); + Expect.equals(0, it.rawIndex); + it.moveNext(); + Expect.equals(1, it.rawIndex); + it.moveNext(); + Expect.isTrue(1 < it.rawIndex); + it.rawIndex = 1; + Expect.equals(1, it.rawIndex); + Expect.equals(expectedRunes[1], it.current); + + // Reset, moveNext. + it.reset(1); + Expect.equals(null, it.rawIndex); + Expect.equals(null, it.current); + it.moveNext(); + Expect.equals(1, it.rawIndex); + Expect.equals(expectedRunes[1], it.current); + + // Reset, movePrevious. + it.reset(1); + Expect.equals(null, it.rawIndex); + Expect.equals(null, it.current); + it.movePrevious(); + Expect.equals(0, it.rawIndex); + Expect.equals(expectedRunes[0], it.current); + + // .map + Expect.listEquals(expectedRunes.map((x) => x.toRadixString(16)).toList(), + runes.map((x) => x.toRadixString(16)).toList()); + } + + // First character must be single-code-unit for test. + test("abc", [0x61, 0x62, 0x63]); + test("\x00\u0000\u{000000}", [0, 0, 0]); + test("\u{ffff}\u{10000}\u{10ffff}", [0xffff, 0x10000, 0x10ffff]); + String string = new String.fromCharCodes( + [0xdc00, 0xd800, 61, 0xd800, 0xdc00, 62, 0xdc00, 0xd800]); + test(string, [0xdc00, 0xd800, 61, 0x10000, 62, 0xdc00, 0xd800]); + + // Setting position in the middle of a surrogate pair is not allowed. + var r = new Runes("\u{10000}"); + var it = r.iterator; + it.moveNext(); + Expect.equals(0x10000, it.current); + + // Setting rawIndex inside surrogate pair. + Expect.throws(() { + it.rawIndex = 1; + }, (e) => e is Error); + Expect.throws(() { + it.reset(1); + }, (e) => e is Error); +} diff --git a/tests/corelib/string_source_test.dart b/tests/corelib/string_source_test.dart new file mode 100644 index 00000000000..eb5a633a594 --- /dev/null +++ b/tests/corelib/string_source_test.dart @@ -0,0 +1,35 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// Test that different representations of the same string are all equal. + +import "dart:convert"; + +import "package:expect/expect.dart"; + +main() { + var base = "\u{10412}"; + var strings = [ + "\u{10412}", + "𐐒", + new String.fromCharCodes([0xd801, 0xdc12]), + base[0] + base[1], + "$base", + "${base[0]}${base[1]}", + "${base[0]}${base.substring(1)}", + new String.fromCharCodes([0x10412]), + ("a" + base).substring(1), + (new StringBuffer()..writeCharCode(0xd801)..writeCharCode(0xdc12)) + .toString(), + (new StringBuffer()..writeCharCode(0x10412)).toString(), + JSON.decode('"\u{10412}"'), + (JSON.decode('{"\u{10412}":[]}') as Map).keys.first + ]; + for (String string in strings) { + Expect.equals(base.length, string.length); + Expect.equals(base, string); + Expect.equals(base.hashCode, string.hashCode); + Expect.listEquals(base.codeUnits.toList(), string.codeUnits.toList()); + } +} diff --git a/tests/corelib/string_split_test.dart b/tests/corelib/string_split_test.dart new file mode 100644 index 00000000000..de7b2492eba --- /dev/null +++ b/tests/corelib/string_split_test.dart @@ -0,0 +1,135 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + testSplitString(); + testSplitRegExp(); + testSplitPattern(); +} + +testSplit(List expect, String string, Pattern pattern) { + String patternString; + if (pattern is String) { + patternString = '"$pattern"'; + } else if (pattern is RegExp) { + patternString = "/${pattern.pattern}/"; + } else { + patternString = pattern.toString(); + } + Expect.listEquals( + expect, string.split(pattern), '"$string".split($patternString)'); +} + +/** String patterns. */ +void testSplitString() { + // Normal match. + testSplit(["a", "b", "c"], "a b c", " "); + testSplit(["a", "b", "c"], "adbdc", "d"); + testSplit(["a", "b", "c"], "addbddc", "dd"); + // No match. + testSplit(["abc"], "abc", " "); + testSplit(["a"], "a", "b"); + testSplit([""], "", "b"); + // Empty match matches everywhere except start/end. + testSplit(["a", "b", "c"], "abc", ""); + // All empty parts. + testSplit(["", "", "", "", ""], "aaaa", "a"); + testSplit(["", "", "", "", ""], " ", " "); + testSplit(["", ""], "a", "a"); + // No overlapping matches. Match as early as possible. + testSplit(["", "", "", "a"], "aaaaaaa", "aa"); + // Cannot split the empty string. + testSplit([], "", ""); // Match. + testSplit([""], "", "a"); // No match. +} + +/** RegExp patterns. */ +void testSplitRegExp() { + testSplitWithRegExp((s) => new RegExp(s)); +} + +/** Non-String, non-RegExp patterns. */ +void testSplitPattern() { + testSplitWithRegExp((s) => new RegExpWrap(s)); +} + +void testSplitWithRegExp(makePattern) { + testSplit(["a", "b", "c"], "a b c", makePattern(r" ")); + + testSplit(["a", "b", "c"], "adbdc", makePattern(r"[dz]")); + + testSplit(["a", "b", "c"], "addbddc", makePattern(r"dd")); + + testSplit(["abc"], "abc", makePattern(r"b$")); + + testSplit(["a", "b", "c"], "abc", makePattern(r"")); + + testSplit(["", "", "", ""], " ", makePattern(r"[ ]")); + + // Non-zero-length match at end. + testSplit(["aa", ""], "aaa", makePattern(r"a$")); + + // Zero-length match at end. + testSplit(["aaa"], "aaa", makePattern(r"$")); + + // Non-zero-length match at start. + testSplit(["", "aa"], "aaa", makePattern(r"^a")); + + // Zero-length match at start. + testSplit(["aaa"], "aaa", makePattern(r"^")); + + // Picks first match, not longest or shortest. + testSplit(["", "", "", "a"], "aaaaaaa", makePattern(r"aa|aaa")); + + testSplit(["", "", "", "a"], "aaaaaaa", makePattern(r"aa|")); + + testSplit(["", "", "a"], "aaaaaaa", makePattern(r"aaa|aa")); + + // Zero-width match depending on the following. + testSplit(["a", "bc"], "abc", makePattern(r"(?=[ab])")); + + testSplit(["a", "b", "c"], "abc", makePattern(r"(?!^)")); + + // Cannot split empty string. + testSplit([], "", makePattern(r"")); + + testSplit([], "", makePattern(r"(?:)")); + + testSplit([], "", makePattern(r"$|(?=.)")); + + testSplit([""], "", makePattern(r"a")); + + // Can split singleton string if it matches. + testSplit(["", ""], "a", makePattern(r"a")); + + testSplit(["a"], "a", makePattern(r"b")); + + // Do not include captures. + testSplit(["a", "", "a"], "abba", makePattern(r"(b)")); + + testSplit(["a", "a"], "abba", makePattern(r"(bb)")); + + testSplit(["a", "a"], "abba", makePattern(r"(b*)")); + + testSplit(["a", "a"], "aa", makePattern(r"(b*)")); + + // But captures are still there, and do work with backreferences. + testSplit(["a", "cba"], "abcba", makePattern(r"([bc])(?=.*\1)")); +} + +// A Pattern implementation with the same capabilities as a RegExp, but not +// directly recognizable as a RegExp. +class RegExpWrap implements Pattern { + final regexp; + RegExpWrap(String source) : regexp = new RegExp(source); + Iterable allMatches(String string, [int start = 0]) => + regexp.allMatches(string, start); + + Match matchAsPrefix(String string, [int start = 0]) => + regexp.matchAsPrefix(string, start); + + String toString() => "Wrap(/${regexp.pattern}/)"; +} diff --git a/tests/corelib/string_substring_test.dart b/tests/corelib/string_substring_test.dart new file mode 100644 index 00000000000..883dd46acff --- /dev/null +++ b/tests/corelib/string_substring_test.dart @@ -0,0 +1,31 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + // Test that not providing an optional argument goes to the end. + Expect.equals("".substring(0), ""); + Expect.throws(() => "".substring(1), (e) => e is RangeError); + Expect.throws(() => "".substring(-1), (e) => e is RangeError); + + Expect.equals("abc".substring(0), "abc"); + Expect.equals("abc".substring(1), "bc"); + Expect.equals("abc".substring(2), "c"); + Expect.equals("abc".substring(3), ""); + Expect.throws(() => "abc".substring(4), (e) => e is RangeError); + Expect.throws(() => "abc".substring(-1), (e) => e is RangeError); + + // Test that providing null goes to the end. + Expect.equals("".substring(0, null), ""); + Expect.throws(() => "".substring(1, null), (e) => e is RangeError); + Expect.throws(() => "".substring(-1, null), (e) => e is RangeError); + + Expect.equals("abc".substring(0, null), "abc"); + Expect.equals("abc".substring(1, null), "bc"); + Expect.equals("abc".substring(2, null), "c"); + Expect.equals("abc".substring(3, null), ""); + Expect.throws(() => "abc".substring(4, null), (e) => e is RangeError); + Expect.throws(() => "abc".substring(-1, null), (e) => e is RangeError); +} diff --git a/tests/corelib/string_test.dart b/tests/corelib/string_test.dart new file mode 100644 index 00000000000..d51d88df596 --- /dev/null +++ b/tests/corelib/string_test.dart @@ -0,0 +1,494 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +void main() { + testOutOfRange(); + testIllegalArgument(); + testConcat(); + testIndex(); + testCodeUnitAt(); + testEquals(); + testEndsWith(); + testStartsWith(); + testIndexOf(); + testLastIndexOf(); + testContains(); + testReplaceAll(); + testCompareTo(); + testCharCodes(); + testRepeat(); + testPadLeft(); + testPadRight(); +} + +void testLength() { + String str = ""; + for (var i = 0; i < 20; i++) { + testStringLength(i, str); + str += " "; + } +} + +void testOutOfRange() { + String a = "Hello"; + bool exception_caught = false; + try { + var c = a[20]; // Throw exception. + } on RangeError catch (e) { + exception_caught = true; + } + Expect.isTrue(exception_caught); +} + +void testIllegalArgument() { + String a = "Hello"; + bool exception_caught = false; + try { + var c = a[2.2]; // Throw exception. + Expect.fail("Accepting double as index"); + } on ArgumentError catch (e) { + exception_caught = true; + } on TypeError catch (e) { + // Thrown in checked mode only. + exception_caught = true; + } + Expect.isTrue(exception_caught); +} + +void testIndex() { + String str = "string"; + for (int i = 0; i < str.length; i++) { + Expect.isTrue(str[i] is String); + testStringLength(1, str[i]); + } +} + +void testCodeUnitAt() { + String str = "string"; + for (int i = 0; i < str.length; i++) { + Expect.isTrue(str.codeUnitAt(i) is int); + } +} + +void testConcat() { + var a = "One"; + var b = "Four"; + var c = a + b; + testStringLength(7, c); + Expect.equals("OneFour", c); +} + +void testEquals() { + Expect.equals("str", "str"); + + Expect.equals("str", "s" + "t" + "r"); + Expect.equals("s" + "t" + "r", "str"); + + Expect.isFalse("str" == "s"); + Expect.isFalse("str" == "r"); + Expect.isFalse("str" == "st"); + Expect.isFalse("str" == "tr"); + + Expect.isFalse("s" == "str"); + Expect.isFalse("r" == "str"); + Expect.isFalse("st" == "str"); + Expect.isFalse("tr" == "str"); + + Expect.isFalse("" == "s"); + Expect.equals("", ""); +} + +void testEndsWith() { + Expect.isTrue("str".endsWith("r")); + Expect.isTrue("str".endsWith("tr")); + Expect.isTrue("str".endsWith("str")); + + Expect.isFalse("str".endsWith("stri")); + Expect.isFalse("str".endsWith("t")); + Expect.isFalse("str".endsWith("st")); + Expect.isFalse("str".endsWith("s")); + + Expect.isTrue("".endsWith("")); + Expect.isFalse("".endsWith("s")); +} + +void testStartsWith() { + Expect.isTrue("str".startsWith("s")); + Expect.isTrue("str".startsWith("st")); + Expect.isTrue("str".startsWith("str")); + + Expect.isFalse("str".startsWith("stri")); + Expect.isFalse("str".startsWith("r")); + Expect.isFalse("str".startsWith("tr")); + Expect.isFalse("str".startsWith("t")); + + Expect.isTrue("".startsWith("")); + Expect.isFalse("".startsWith("s")); + + Expect.isFalse("strstr".startsWith("s", 1)); + Expect.isFalse("strstr".startsWith("s", 2)); + Expect.isTrue("strstr".startsWith("s", 3)); + Expect.isFalse("strstr".startsWith("s", 4)); + + Expect.isFalse("strstr".startsWith("st", 1)); + Expect.isFalse("strstr".startsWith("st", 2)); + Expect.isTrue("strstr".startsWith("st", 3)); + Expect.isFalse("strstr".startsWith("st", 4)); + + Expect.isFalse("strstr".startsWith("str", 1)); + Expect.isFalse("strstr".startsWith("str", 2)); + Expect.isTrue("strstr".startsWith("str", 3)); + Expect.isFalse("strstr".startsWith("str", 4)); + + Expect.isTrue("str".startsWith("", 0)); + Expect.isTrue("str".startsWith("", 1)); + Expect.isTrue("str".startsWith("", 2)); + Expect.isTrue("str".startsWith("", 3)); + + Expect.throws(() => "str".startsWith("", -1)); + Expect.throws(() => "str".startsWith("", 4)); + + var regexp = new RegExp("s(?:tr?)?"); + Expect.isTrue("s".startsWith(regexp)); + Expect.isTrue("st".startsWith(regexp)); + Expect.isTrue("str".startsWith(regexp)); + Expect.isTrue("sX".startsWith(regexp)); + Expect.isTrue("stX".startsWith(regexp)); + Expect.isTrue("strX".startsWith(regexp)); + + Expect.isFalse("".startsWith(regexp)); + Expect.isFalse("astr".startsWith(regexp)); + + Expect.isTrue("".startsWith(new RegExp(""))); + Expect.isTrue("".startsWith(new RegExp("a?"))); + + Expect.isFalse("strstr".startsWith(regexp, 1)); + Expect.isFalse("strstr".startsWith(regexp, 2)); + Expect.isTrue("strstr".startsWith(regexp, 3)); + Expect.isFalse("strstr".startsWith(regexp, 4)); + + Expect.isTrue("str".startsWith(new RegExp(""), 0)); + Expect.isTrue("str".startsWith(new RegExp(""), 1)); + Expect.isTrue("str".startsWith(new RegExp(""), 2)); + Expect.isTrue("str".startsWith(new RegExp(""), 3)); + Expect.isTrue("str".startsWith(new RegExp("a?"), 0)); + Expect.isTrue("str".startsWith(new RegExp("a?"), 1)); + Expect.isTrue("str".startsWith(new RegExp("a?"), 2)); + Expect.isTrue("str".startsWith(new RegExp("a?"), 3)); + + Expect.throws(() => "str".startsWith(regexp, -1)); + Expect.throws(() => "str".startsWith(regexp, 4)); + + regexp = new RegExp("^str"); + Expect.isTrue("strstr".startsWith(regexp)); + Expect.isTrue("strstr".startsWith(regexp, 0)); + Expect.isFalse("strstr".startsWith(regexp, 1)); + Expect.isFalse("strstr".startsWith(regexp, 2)); + Expect.isFalse("strstr".startsWith(regexp, 3)); // Second "str" isn't at ^. +} + +void testIndexOf() { + Expect.equals(0, "str".indexOf("", 0)); + Expect.equals(0, "".indexOf("", 0)); + Expect.equals(-1, "".indexOf("a", 0)); + + Expect.equals(1, "str".indexOf("t", 0)); + Expect.equals(1, "str".indexOf("tr", 0)); + Expect.equals(0, "str".indexOf("str", 0)); + Expect.equals(0, "str".indexOf("st", 0)); + Expect.equals(0, "str".indexOf("s", 0)); + Expect.equals(2, "str".indexOf("r", 0)); + Expect.equals(-1, "str".indexOf("string", 0)); + + Expect.equals(1, "strstr".indexOf("t", 0)); + Expect.equals(1, "strstr".indexOf("tr", 0)); + Expect.equals(0, "strstr".indexOf("str", 0)); + Expect.equals(0, "strstr".indexOf("st", 0)); + Expect.equals(0, "strstr".indexOf("s", 0)); + Expect.equals(2, "strstr".indexOf("r", 0)); + Expect.equals(-1, "str".indexOf("string", 0)); + + Expect.equals(4, "strstr".indexOf("t", 2)); + Expect.equals(4, "strstr".indexOf("tr", 2)); + Expect.equals(3, "strstr".indexOf("str", 1)); + Expect.equals(3, "strstr".indexOf("str", 2)); + Expect.equals(3, "strstr".indexOf("str", 3)); + Expect.equals(3, "strstr".indexOf("st", 1)); + Expect.equals(3, "strstr".indexOf("s", 3)); + Expect.equals(5, "strstr".indexOf("r", 3)); + Expect.equals(5, "strstr".indexOf("r", 4)); + Expect.equals(5, "strstr".indexOf("r", 5)); + + String str = "hello"; + for (int i = 0; i < 10; i++) { + if (i > str.length) { + Expect.throws(() => str.indexOf("", i)); + } else { + int result = str.indexOf("", i); + Expect.equals(i, result); + } + } + + var re = new RegExp("an?"); + Expect.equals(1, "banana".indexOf(re)); + Expect.equals(1, "banana".indexOf(re, 0)); + Expect.equals(1, "banana".indexOf(re, 1)); + Expect.equals(3, "banana".indexOf(re, 2)); + Expect.equals(3, "banana".indexOf(re, 3)); + Expect.equals(5, "banana".indexOf(re, 4)); + Expect.equals(5, "banana".indexOf(re, 5)); + Expect.equals(-1, "banana".indexOf(re, 6)); + Expect.throws(() => "banana".indexOf(re, -1)); + Expect.throws(() => "banana".indexOf(re, 7)); + re = new RegExp("x?"); + for (int i = 0; i <= str.length; i++) { + Expect.equals(i, str.indexOf(re, i)); + } +} + +void testLastIndexOf() { + Expect.equals(2, "str".lastIndexOf("", 2)); + Expect.equals(0, "".lastIndexOf("", 0)); + Expect.equals(-1, "".lastIndexOf("a", 0)); + + Expect.equals(1, "str".lastIndexOf("t", 2)); + Expect.equals(1, "str".lastIndexOf("tr", 2)); + Expect.equals(0, "str".lastIndexOf("str", 2)); + Expect.equals(0, "str".lastIndexOf("st", 2)); + Expect.equals(0, "str".lastIndexOf("s", 2)); + Expect.equals(2, "str".lastIndexOf("r", 2)); + Expect.equals(-1, "str".lastIndexOf("string", 2)); + + Expect.equals(4, "strstr".lastIndexOf("t", 5)); + Expect.equals(4, "strstr".lastIndexOf("tr", 5)); + Expect.equals(3, "strstr".lastIndexOf("str", 5)); + Expect.equals(3, "strstr".lastIndexOf("st", 5)); + Expect.equals(3, "strstr".lastIndexOf("s", 5)); + Expect.equals(5, "strstr".lastIndexOf("r", 5)); + Expect.throws(() { + "str".lastIndexOf("string", 5); + }); + Expect.equals(4, "strstr".lastIndexOf("t", 5)); + Expect.equals(4, "strstr".lastIndexOf("tr", 5)); + Expect.equals(3, "strstr".lastIndexOf("str", 5)); + Expect.equals(3, "strstr".lastIndexOf("str", 5)); + Expect.equals(3, "strstr".lastIndexOf("str", 5)); + Expect.equals(3, "strstr".lastIndexOf("st", 5)); + Expect.equals(3, "strstr".lastIndexOf("s", 5)); + Expect.equals(5, "strstr".lastIndexOf("r", 5)); + Expect.equals(2, "strstr".lastIndexOf("r", 4)); + Expect.equals(2, "strstr".lastIndexOf("r", 3)); + Expect.equals(5, "strstr".lastIndexOf("r")); + Expect.equals(5, "strstr".lastIndexOf("r", null)); + + String str = "hello"; + for (int i = 0; i < 10; i++) { + if (i > str.length) { + Expect.throws(() => str.indexOf("", i)); + } else { + int result = str.lastIndexOf("", i); + Expect.equals(i, result); + } + } + + var re = new RegExp("an?"); + Expect.equals(5, "banana".lastIndexOf(re)); + Expect.equals(5, "banana".lastIndexOf(re, 6)); + Expect.equals(5, "banana".lastIndexOf(re, 5)); + Expect.equals(3, "banana".lastIndexOf(re, 4)); + Expect.equals(3, "banana".lastIndexOf(re, 3)); + Expect.equals(1, "banana".lastIndexOf(re, 2)); + Expect.equals(1, "banana".lastIndexOf(re, 1)); + Expect.equals(-1, "banana".lastIndexOf(re, 0)); + Expect.throws(() => "banana".lastIndexOf(re, -1)); + Expect.throws(() => "banana".lastIndexOf(re, 7)); + re = new RegExp("x?"); + for (int i = 0; i <= str.length; i++) { + Expect.equals(i, str.indexOf(re, i)); + } +} + +void testContains() { + Expect.isTrue("str".contains("s", 0)); + Expect.isTrue("str".contains("st", 0)); + Expect.isTrue("str".contains("str", 0)); + Expect.isTrue("str".contains("t", 0)); + Expect.isTrue("str".contains("r", 0)); + Expect.isTrue("str".contains("tr", 0)); + + Expect.isFalse("str".contains("sr", 0)); + Expect.isFalse("str".contains("string", 0)); + + Expect.isTrue("str".contains("", 0)); + Expect.isTrue("".contains("", 0)); + Expect.isFalse("".contains("s", 0)); +} + +void testReplaceAll() { + Expect.equals("AtoBtoCDtoE", "AfromBfromCDfromE".replaceAll("from", "to")); + + // Test with the replaced string at the beginning. + Expect.equals("toABtoCDtoE", "fromABfromCDfromE".replaceAll("from", "to")); + + // Test with the replaced string at the end. + Expect.equals( + "toABtoCDtoEto", "fromABfromCDfromEfrom".replaceAll("from", "to")); + + // Test when there are no occurence of the string to replace. + Expect.equals("ABC", "ABC".replaceAll("from", "to")); + + // Test when the string to change is the empty string. + Expect.equals("", "".replaceAll("from", "to")); + + // Test when the string to change is a substring of the string to + // replace. + Expect.equals("fro", "fro".replaceAll("from", "to")); + + // Test when the string to change is the replaced string. + Expect.equals("to", "from".replaceAll("from", "to")); + + // Test when the string to change is the replacement string. + Expect.equals("to", "to".replaceAll("from", "to")); + + // Test replacing by the empty string. + Expect.equals("", "from".replaceAll("from", "")); + Expect.equals("AB", "AfromB".replaceAll("from", "")); + + // Test changing the empty string. + Expect.equals("to", "".replaceAll("", "to")); + + // Test replacing the empty string. + Expect.equals("toAtoBtoCto", "ABC".replaceAll("", "to")); +} + +void testCompareTo() { + Expect.equals(0, "".compareTo("")); + Expect.equals(0, "str".compareTo("str")); + Expect.equals(-1, "str".compareTo("string")); + Expect.equals(1, "string".compareTo("str")); + Expect.equals(1, "string".compareTo("")); + Expect.equals(-1, "".compareTo("string")); +} + +void testCharCodes() { + test(str) { + var list = str.codeUnits; + Expect.equals(str.length, list.length); + for (int i = 0; i < str.length; i++) { + Expect.equals(str.codeUnitAt(i), list[i]); + } + } + + test("abc"); + test(""); + test(" "); +} + +void testStringLength(int length, String str) { + Expect.equals(length, str.length); + (length == 0 ? Expect.isTrue : Expect.isFalse)(str.isEmpty); + (length != 0 ? Expect.isTrue : Expect.isFalse)(str.isNotEmpty); +} + +void testRepeat() { + List testStrings = [ + "", + "\x00", + "a", + "ab", + "\x80", + "\xff", + "\u2028", + "abcdef\u2028", + "\u{10002}", + "abcdef\u{10002}" + ]; + List counts = [ + 0, + 1, + 2, + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 16, + 17, + 127, + 128, + 129 + ]; + void testRepeat(str, repeat) { + String expect; + if (repeat <= 0) { + expect = ""; + } else if (repeat == 1) { + expect = str; + } else { + StringBuffer buf = new StringBuffer(); + for (int i = 0; i < repeat; i++) { + buf.write(str); + } + expect = buf.toString(); + } + String actual = str * repeat; + Expect.equals(expect, actual, "$str#${str.length} * $repeat"); + } + + for (String str in testStrings) { + for (int repeat in counts) { + testRepeat(str, repeat); + } + } +} + +void testPadLeft() { + Expect.equals(" 1", "1".padLeft(5, ' ')); + Expect.equals(" 11", "11".padLeft(5, ' ')); + Expect.equals(" 111", "111".padLeft(5, ' ')); + Expect.equals(" 1111", "1111".padLeft(5, ' ')); + Expect.equals("11111", "11111".padLeft(5, ' ')); + Expect.equals("111111", "111111".padLeft(5, ' ')); + Expect.equals(" \u{10002}", "\u{10002}".padLeft(5, ' ')); + Expect.equals('', ''.padLeft(0, 'a')); + Expect.equals('a', ''.padLeft(1, 'a')); + Expect.equals('aaaaa', ''.padLeft(5, 'a')); + Expect.equals('', ''.padLeft(-2, 'a')); + + Expect.equals('xyzxyzxyzxyzxyz', ''.padLeft(5, 'xyz')); + Expect.equals('xyzxyzxyzxyza', 'a'.padLeft(5, 'xyz')); + Expect.equals('xyzxyzxyzaa', 'aa'.padLeft(5, 'xyz')); + Expect.equals('\u{10002}\u{10002}\u{10002}aa', 'aa'.padLeft(5, '\u{10002}')); + Expect.equals('a', 'a'.padLeft(10, '')); +} + +void testPadRight() { + Expect.equals("1 ", "1".padRight(5, ' ')); + Expect.equals("11 ", "11".padRight(5, ' ')); + Expect.equals("111 ", "111".padRight(5, ' ')); + Expect.equals("1111 ", "1111".padRight(5, ' ')); + Expect.equals("11111", "11111".padRight(5, ' ')); + Expect.equals("111111", "111111".padRight(5, ' ')); + Expect.equals("\u{10002} ", "\u{10002}".padRight(5, ' ')); + Expect.equals('', ''.padRight(0, 'a')); + Expect.equals('a', ''.padRight(1, 'a')); + Expect.equals('aaaaa', ''.padRight(5, 'a')); + Expect.equals('', ''.padRight(-2, 'a')); + + Expect.equals('xyzxyzxyzxyzxyz', ''.padRight(5, 'xyz')); + Expect.equals('axyzxyzxyzxyz', 'a'.padRight(5, 'xyz')); + Expect.equals('aaxyzxyzxyz', 'aa'.padRight(5, 'xyz')); + Expect.equals('aa\u{10002}\u{10002}\u{10002}', 'aa'.padRight(5, '\u{10002}')); + Expect.equals('a', 'a'.padRight(10, '')); +} diff --git a/tests/corelib/string_to_lower_case_test.dart b/tests/corelib/string_to_lower_case_test.dart new file mode 100644 index 00000000000..e761c1c908b --- /dev/null +++ b/tests/corelib/string_to_lower_case_test.dart @@ -0,0 +1,19 @@ +// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +void testOneByteSting() { + // Compare one-byte-string toLowerCase with a two-byte-string toLowerCase. + var oneByteString = + new String.fromCharCodes(new List.generate(256, (i) => i)).toLowerCase(); + var twoByteString = + new String.fromCharCodes(new List.generate(512, (i) => i)).toLowerCase(); + Expect.isTrue(twoByteString.codeUnits.any((u) => u >= 256)); + Expect.equals(oneByteString, twoByteString.substring(0, 256)); +} + +void main() { + testOneByteSting(); +} diff --git a/tests/corelib/string_trim2_test.dart b/tests/corelib/string_trim2_test.dart new file mode 100644 index 00000000000..eb7956afa4b --- /dev/null +++ b/tests/corelib/string_trim2_test.dart @@ -0,0 +1,48 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +const WHITESPACE = const [ + 0x09, + 0x0A, + 0x0B, + 0x0C, + 0x0D, + 0x20, + 0x85, + 0xA0, + 0x1680, + 0x2000, + 0x2001, + 0x2002, + 0x2003, + 0x2004, + 0x2005, + 0x2006, + 0x2007, + 0x2008, + 0x2009, + 0x200A, + 0x202F, + 0x205F, + 0x3000, + 0x2028, + 0x2029, + 0xFEFF, +]; + +main() { + for (var ws in WHITESPACE) { + var name = ws.toRadixString(16); + var c = new String.fromCharCode(ws); + Expect.equals("", c.trim(), "$name"); + Expect.equals("a", ("a" + c).trim(), "a-$name"); + Expect.equals("a", (c + "a").trim(), "$name-a"); + Expect.equals("a", (c + c + "a" + c + c).trim(), "$name around"); + Expect.equals( + "a" + c + "a", (c + c + "a" + c + "a" + c + c).trim(), "$name many"); + } + Expect.equals("", new String.fromCharCodes(WHITESPACE).trim(), "ALL"); +} diff --git a/tests/corelib/string_trim_test.dart b/tests/corelib/string_trim_test.dart new file mode 100644 index 00000000000..6049af9e1c7 --- /dev/null +++ b/tests/corelib/string_trim_test.dart @@ -0,0 +1,25 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +class StringTrimTest { + static testMain() { + Expect.equals("", " ".trim()); + Expect.equals("", " ".trim()); + var a = " lots of space on the left"; + Expect.equals("lots of space on the left", a.trim()); + a = "lots of space on the right "; + Expect.equals("lots of space on the right", a.trim()); + a = " lots of space "; + Expect.equals("lots of space", a.trim()); + a = " x "; + Expect.equals("x", a.trim()); + Expect.equals("", " \t \n \r ".trim()); + } +} + +main() { + StringTrimTest.testMain(); +} diff --git a/tests/corelib/string_trimlr_test.dart b/tests/corelib/string_trimlr_test.dart new file mode 100644 index 00000000000..90eb02ddd4e --- /dev/null +++ b/tests/corelib/string_trimlr_test.dart @@ -0,0 +1,111 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +// Characters with Whitespace property (Unicode 6.3). +// 0009..000D ; White_Space # Cc .. +// 0020 ; White_Space # Zs SPACE +// 0085 ; White_Space # Cc +// 00A0 ; White_Space # Zs NO-BREAK SPACE +// 1680 ; White_Space # Zs OGHAM SPACE MARK +// 2000..200A ; White_Space # Zs EN QUAD..HAIR SPACE +// 2028 ; White_Space # Zl LINE SEPARATOR +// 2029 ; White_Space # Zp PARAGRAPH SEPARATOR +// 202F ; White_Space # Zs NARROW NO-BREAK SPACE +// 205F ; White_Space # Zs MEDIUM MATHEMATICAL SPACE +// 3000 ; White_Space # Zs IDEOGRAPHIC SPACE +// And BOM: +// FEFF ; Byte order mark. +const WHITESPACE = const [ + 0x09, + 0x0A, + 0x0B, + 0x0C, + 0x0D, + 0x20, + 0x85, + 0xA0, + 0x1680, + 0x2000, + 0x2001, + 0x2002, + 0x2003, + 0x2004, + 0x2005, + 0x2006, + 0x2007, + 0x2008, + 0x2009, + 0x200A, + 0x2028, + 0x2029, + 0x202F, + 0x205F, + 0x3000, + 0xFEFF, +]; + +main() { + // Test the whitespace in different positions. + test(ws) { + // trimLeft + Expect.equals("", ws.trimLeft(), "K1"); + Expect.equals("", (ws + ws).trimLeft(), "L2"); + Expect.equals("a" + ws, ("a" + ws).trimLeft(), "L3"); + Expect.equals("a", (ws + "a").trimLeft(), "L4"); + Expect.equals("a" + ws + ws, (ws + ws + "a" + ws + ws).trimLeft(), "L5"); + Expect.equals("a" + ws + "a", (ws + ws + "a" + ws + "a").trimLeft(), "L6"); + var untrimmable = "a" + ws + "a"; + Expect.identical(untrimmable, untrimmable.trimLeft(), "L7"); + // trimRight + Expect.equals("", ws.trimRight(), "R1"); + Expect.equals("", (ws + ws).trimRight(), "R2"); + Expect.equals("a", ("a" + ws).trimRight(), "R3"); + Expect.equals(ws + "a", (ws + "a").trimRight(), "R4"); + Expect.equals(ws + ws + "a", (ws + ws + "a" + ws + ws).trimRight(), "R5"); + Expect.equals("a" + ws + "a", ("a" + ws + "a" + ws + ws).trimRight(), "R6"); + Expect.identical(untrimmable, untrimmable.trimRight(), "R7"); + } + + // Test each whitespace at different locations. + for (var ws in WHITESPACE) { + var c = new String.fromCharCode(ws); + test(c); + } + // Test all whitespaces at once at different locations. + test(new String.fromCharCodes(WHITESPACE)); + + // Empty strings. + Expect.identical("", "".trimLeft()); + Expect.identical("", "".trimRight()); + + // Test all BMP chars and one surrogate pair. + for (int i = 0, j = 0; i <= 0x10000; i++) { + if (j < WHITESPACE.length && i == WHITESPACE[j]) { + j++; + continue; + } + // See below for these exceptions. + if (i == 0x180E) continue; + if (i == 0x200B) continue; + + var s = new String.fromCharCode(i); + Expect.identical(s, s.trimLeft()); + Expect.identical(s, s.trimRight()); + } + + // U+200b is currently being treated as whitespace by some JS engines. + // string_trimlr_test/01 fails on these engines. + // Should be fixed in tip-of-tree V8 per 2014-02-10. + var s200B = new String.fromCharCode(0x200B); + Expect.identical(s200B, s200B.trimLeft()); // //# 01: ok + Expect.identical(s200B, s200B.trimRight()); // //# 01: ok + + // U+180E ceased to be whitespace in Unicode version 6.3.0 + // string_trimlr_test/02 fails on implementations using earlier versions. + var s180E = new String.fromCharCode(0x180E); + Expect.identical(s180E, s180E.trimLeft()); // //# 02: ok + Expect.identical(s180E, s180E.trimRight()); // //# 02: ok +} diff --git a/tests/corelib/strings_test.dart b/tests/corelib/strings_test.dart new file mode 100644 index 00000000000..9603b17da5c --- /dev/null +++ b/tests/corelib/strings_test.dart @@ -0,0 +1,33 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +// Dart test program for testing class 'Strings'. + +class StringsTest { + StringsTest() {} + + toString() { + return "Strings Tester"; + } + + static testCreation() { + String s = "Hello"; + List l = new List(s.length); + for (int i = 0; i < l.length; i++) { + l[i] = s.codeUnitAt(i); + } + String s2 = new String.fromCharCodes(l); + Expect.equals(s, s2); + } + + static void testMain() { + testCreation(); + } +} + +main() { + StringsTest.testMain(); +} diff --git a/tests/corelib/symbol_map_helper.dart b/tests/corelib/symbol_map_helper.dart new file mode 100644 index 00000000000..da9e7e5a385 --- /dev/null +++ b/tests/corelib/symbol_map_helper.dart @@ -0,0 +1,15 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +library dart.test.symbol_map_helper; + +// TODO(ahe): Update map literals to avoid this method. +Map symbolMapToStringMap(Map map) { + if (map == null) return null; + Map result = new Map(); + map.forEach((name, value) { + result[new Symbol(name)] = value; + }); + return result; +} diff --git a/tests/corelib/symbol_operator_test.dart b/tests/corelib/symbol_operator_test.dart new file mode 100644 index 00000000000..1899f6fbce3 --- /dev/null +++ b/tests/corelib/symbol_operator_test.dart @@ -0,0 +1,81 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// Test of Symbol class for operators.. + +var $ = new Symbolize(); + +main() { + testSymbol(#+, $ + $, "+"); + testSymbol(#-, $ - $, "-"); + testSymbol(#*, $ * $, "*"); + testSymbol(#/, $ / $, "/"); + testSymbol(#~/, $ ~/ $, "~/"); + testSymbol(#%, $ % $, "%"); + testSymbol(#<<, $ << $, "<<"); + testSymbol(#>>, $ >> $, ">>"); + testSymbol(#~, ~$, "~"); + testSymbol(#|, $ | $, "|"); + testSymbol(#&, $ & $, "&"); + testSymbol(#^, $ ^ $, "^"); + testSymbol(#<, $ < $, "<"); + testSymbol(#<=, $ <= $, "<="); + testSymbol(#>, $ > $, ">"); + testSymbol(#>=, $ >= $, ">="); + testSymbol(#==, new Symbol("=="), "=="); // Can't hit noSuchMethod. + testSymbol(#[], $[$], "[]"); + testSymbol(#[]=, ($[$] = $).lastMember, "[]="); + testSymbol(const Symbol("unary-"), -$, "unary-"); + + testSymbolThrows(">>>"); // //# 03: ok + testSymbolThrows("!"); // //# 03: continued + testSymbolThrows("&&"); // //# 03: continued + testSymbolThrows("||"); // //# 03: continued + testSymbolThrows("?"); // //# 03: continued + testSymbolThrows("?:"); // //# 03: continued + testSymbolThrows("#"); // //# 03: continued + testSymbolThrows("//"); // //# 03: continued +} + +void testSymbol(Symbol constSymbol, var mirrorSymbol, String name) { + Symbol dynamicSymbol = new Symbol(name); + if (constSymbol != mirrorSymbol) { + throw "Not equal #$name, \$$name: $constSymbol, $mirrorSymbol"; + } + if (constSymbol != dynamicSymbol) { + throw "Not equal #$name, new Symbol('$name'): $constSymbol, $dynamicSymbol"; + } + if (mirrorSymbol != dynamicSymbol) { + throw "Not equal \$$name, new Symbol('$name'): " + "$mirrorSymbol, $dynamicSymbol"; + } + if (constSymbol.hashCode != mirrorSymbol.hashCode) { + throw "HashCode not equal #$name, \$$name: $constSymbol, $mirrorSymbol"; + } + if (constSymbol.hashCode != dynamicSymbol.hashCode) { + throw "HashCode not equal #$name, new Symbol('$name'): " + "$constSymbol, $dynamicSymbol"; + } + if (mirrorSymbol.hashCode != dynamicSymbol.hashCode) { + throw "HashCode not equal \$$name, new Symbol('$name'): " + "$mirrorSymbol, $dynamicSymbol"; + } +} + +void testSymbolThrows(name) { + bool fails = false; + try { + new Symbol(name); + } catch (e) { + fails = true; + } + if (!fails) { + throw "Didn't throw: $name"; + } +} + +class Symbolize { + Symbol lastMember; + noSuchMethod(m) => lastMember = m.memberName; +} diff --git a/tests/corelib/symbol_reserved_word_test.dart b/tests/corelib/symbol_reserved_word_test.dart new file mode 100644 index 00000000000..c6a585b3715 --- /dev/null +++ b/tests/corelib/symbol_reserved_word_test.dart @@ -0,0 +1,124 @@ +// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +void checkBadSymbol(String s) { + Expect.throws(() => new Symbol(s), (e) => e is ArgumentError); +} + +main() { + var x; + + // 'void' is allowed as a symbol name. + x = const Symbol('void'); // //# 01: ok + x = #void; // //# 02: ok + x = new Symbol('void'); // //# 03: ok + + // However, it is not allowed as a part of a symbol name. + x = const Symbol('void.foo'); // //# 04: compile-time error + Expect.throws(() { x = #void.foo; }, (e) => e is NoSuchMethodError); //# 05: static type warning + checkBadSymbol('void.foo'); // //# 06: ok + x = const Symbol('foo.void'); // //# 07: compile-time error + x = #foo.void; // //# 08: compile-time error + checkBadSymbol('foo.void'); // //# 09: ok + + // All other reserved words are disallowed. + x = const Symbol('assert'); // //# 10: compile-time error + x = const Symbol('break'); // //# 10: continued + x = const Symbol('case'); // //# 10: continued + x = const Symbol('catch'); // //# 10: continued + x = const Symbol('class'); // //# 10: continued + x = const Symbol('const'); // //# 10: continued + x = const Symbol('continue'); // //# 10: continued + x = const Symbol('default'); // //# 10: continued + x = const Symbol('do'); // //# 10: continued + x = const Symbol('else'); // //# 10: continued + x = const Symbol('enum'); // //# 10: continued + x = const Symbol('extends'); // //# 10: continued + x = const Symbol('false'); // //# 10: continued + x = const Symbol('final'); // //# 10: continued + x = const Symbol('finally'); // //# 10: continued + x = const Symbol('for'); // //# 10: continued + x = const Symbol('if'); // //# 10: continued + x = const Symbol('in'); // //# 10: continued + x = const Symbol('is'); // //# 10: continued + x = const Symbol('new'); // //# 10: continued + x = const Symbol('null'); // //# 10: continued + x = const Symbol('rethrow'); // //# 10: continued + x = const Symbol('return'); // //# 10: continued + x = const Symbol('super'); // //# 10: continued + x = const Symbol('switch'); // //# 10: continued + x = const Symbol('this'); // //# 10: continued + x = const Symbol('throw'); // //# 10: continued + x = const Symbol('true'); // //# 10: continued + x = const Symbol('try'); // //# 10: continued + x = const Symbol('var'); // //# 10: continued + x = const Symbol('while'); // //# 10: continued + x = const Symbol('with'); // //# 10: continued + x = #assert; // //# 11: compile-time error + x = #break; // //# 11: continued + x = #case; // //# 11: continued + x = #catch; // //# 11: continued + x = #class; // //# 11: continued + x = #const; // //# 11: continued + x = #continue; // //# 11: continued + x = #default; // //# 11: continued + x = #do; // //# 11: continued + x = #else; // //# 11: continued + x = #enum; // //# 11: continued + x = #extends; // //# 11: continued + x = #false; // //# 11: continued + x = #final; // //# 11: continued + x = #finally; // //# 11: continued + x = #for; // //# 11: continued + x = #if; // //# 11: continued + x = #in; // //# 11: continued + x = #is; // //# 11: continued + x = #new; // //# 11: continued + x = #null; // //# 11: continued + x = #rethrow; // //# 11: continued + x = #return; // //# 11: continued + x = #super; // //# 11: continued + x = #switch; // //# 11: continued + x = #this; // //# 11: continued + x = #throw; // //# 11: continued + x = #true; // //# 11: continued + x = #try; // //# 11: continued + x = #var; // //# 11: continued + x = #while; // //# 11: continued + x = #with; // //# 11: continued + checkBadSymbol('assert'); // //# 12: ok + checkBadSymbol('break'); // //# 12: continued + checkBadSymbol('case'); // //# 12: continued + checkBadSymbol('catch'); // //# 12: continued + checkBadSymbol('class'); // //# 12: continued + checkBadSymbol('const'); // //# 12: continued + checkBadSymbol('continue'); // //# 12: continued + checkBadSymbol('default'); // //# 12: continued + checkBadSymbol('do'); // //# 12: continued + checkBadSymbol('else'); // //# 12: continued + checkBadSymbol('enum'); // //# 12: continued + checkBadSymbol('extends'); // //# 12: continued + checkBadSymbol('false'); // //# 12: continued + checkBadSymbol('final'); // //# 12: continued + checkBadSymbol('finally'); // //# 12: continued + checkBadSymbol('for'); // //# 12: continued + checkBadSymbol('if'); // //# 12: continued + checkBadSymbol('in'); // //# 12: continued + checkBadSymbol('is'); // //# 12: continued + checkBadSymbol('new'); // //# 12: continued + checkBadSymbol('null'); // //# 12: continued + checkBadSymbol('rethrow'); // //# 12: continued + checkBadSymbol('return'); // //# 12: continued + checkBadSymbol('super'); // //# 12: continued + checkBadSymbol('switch'); // //# 12: continued + checkBadSymbol('this'); // //# 12: continued + checkBadSymbol('throw'); // //# 12: continued + checkBadSymbol('true'); // //# 12: continued + checkBadSymbol('try'); // //# 12: continued + checkBadSymbol('var'); // //# 12: continued + checkBadSymbol('while'); // //# 12: continued + checkBadSymbol('with'); // //# 12: continued +} diff --git a/tests/corelib/symbol_test.dart b/tests/corelib/symbol_test.dart new file mode 100644 index 00000000000..6b97092a670 --- /dev/null +++ b/tests/corelib/symbol_test.dart @@ -0,0 +1,90 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// Basic test of Symbol class. + +main() { + var x; + print(x = const Symbol('fisk')); + + try { + print(const Symbol(0)); //# 01: compile-time error + } on NoSuchMethodError { + print('Caught NoSuchMethodError'); + } on TypeError { + print('Caught TypeError'); + } + + try { + print(const Symbol('0')); //# 02: compile-time error + } on ArgumentError catch (e) { + print('Caught $e'); + } + + try { + print(const Symbol('_')); //# 03: compile-time error + } on ArgumentError catch (e) { + print('Caught $e'); + } + + try { + var y = 0; + print(new Symbol(y)); + throw 'Expected a NoSuchMethodError or a TypeError'; + } on NoSuchMethodError { + print('Caught NoSuchMethodError'); + } on TypeError { + print('Caught TypeError'); + } + + try { + print(new Symbol('0')); + throw 'Expected an ArgumentError'; + } on ArgumentError catch (e) { + print('Caught $e'); + } + + try { + print(new Symbol('_')); + throw 'Expected an ArgumentError'; + } on ArgumentError catch (e) { + print('Caught $e'); + } + + if (!identical(const Symbol('fisk'), x)) { + throw 'Symbol constant is not canonicalized'; + } + + if (const Symbol('fisk') != x) { + throw 'Symbol constant is not equal to itself'; + } + + if (const Symbol('fisk') != new Symbol('fisk')) { + throw 'Symbol constant is not equal to its non-const equivalent'; + } + + if (new Symbol('fisk') != new Symbol('fisk')) { + throw 'new Symbol is not equal to its equivalent'; + } + + if (new Symbol('fisk') == new Symbol('hest')) { + throw 'unrelated Symbols are equal'; + } + + if (new Symbol('fisk') == new Object()) { + throw 'unrelated objects are equal'; + } + + x.hashCode as int; + + new Symbol('fisk').hashCode as int; + + if (new Symbol('fisk').hashCode != x.hashCode) { + throw "non-const Symbol's hashCode not equal to its const equivalent"; + } + + if (new Symbol('') != const Symbol('')) { + throw 'empty Symbol not equals to itself'; + } +} diff --git a/tests/corelib/throw_half_surrogate_pair_test.dart b/tests/corelib/throw_half_surrogate_pair_test.dart new file mode 100644 index 00000000000..f500cb1a143 --- /dev/null +++ b/tests/corelib/throw_half_surrogate_pair_test.dart @@ -0,0 +1,12 @@ +// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +main() { + var trebleClef = "\u{1D11E}"; + if (trebleClef.length != 2) throw "String should be a surrogate pair"; + // These uncaught exceptions should not cause the VM to crash attempting to + // print a malformed string. + throw trebleClef[0]; // //# 01: runtime error + throw trebleClef[1]; // //# 02: runtime error +} diff --git a/tests/corelib/toInt_test.dart b/tests/corelib/toInt_test.dart new file mode 100644 index 00000000000..0261d7da0a6 --- /dev/null +++ b/tests/corelib/toInt_test.dart @@ -0,0 +1,20 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + Expect.equals(-0x80000001, (-0x80000001).toInt()); + Expect.equals(-0x80000000, (-0x80000000 - 0.7).toInt()); + Expect.equals(-0x80000000, (-0x80000000 - 0.3).toInt()); + Expect.equals(-0x7FFFFFFF, (-0x80000000 + 0.3).toInt()); + Expect.equals(-0x7FFFFFFF, (-0x80000000 + 0.7).toInt()); + Expect.equals(-0x7FFFFFFF, (-0x7FFFFFFF).toInt()); + Expect.equals(0x7FFFFFFE, (0x7FFFFFFE).toInt()); + Expect.equals(0x7FFFFFFE, (0x7FFFFFFF - 0.7).toInt()); + Expect.equals(0x7FFFFFFE, (0x7FFFFFFF - 0.3).toInt()); + Expect.equals(0x7FFFFFFF, (0x7FFFFFFF + 0.3).toInt()); + Expect.equals(0x7FFFFFFF, (0x7FFFFFFF + 0.7).toInt()); + Expect.equals(0x80000000, 0x80000000.toInt()); +} diff --git a/tests/corelib/unicode2_test.dart b/tests/corelib/unicode2_test.dart new file mode 100755 index 00000000000..c939a1d1b9a --- /dev/null +++ b/tests/corelib/unicode2_test.dart @@ -0,0 +1,77 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:expect/expect.dart'; + +const String testPhrase = "The quick brown fox jumps over the lazy dog."; + +const List testCodepoints = const [ + 84, + 104, + 101, + 32, + 113, + 117, + 105, + 99, + 107, + 32, + 98, + 114, + 111, + 119, + 110, + 32, + 102, + 111, + 120, + 32, + 106, + 117, + 109, + 112, + 115, + 32, + 111, + 118, + 101, + 114, + 32, + 116, + 104, + 101, + 32, + 108, + 97, + 122, + 121, + 32, + 100, + 111, + 103, + 46 +]; + +main() { + testCodepointsToString(); + testStringCharCodes(); + testEmptyStringFromCharCodes(); + testEmptyStringCharCodes(); +} + +void testStringCharCodes() { + Expect.listEquals(testCodepoints, testPhrase.codeUnits); +} + +void testCodepointsToString() { + Expect.stringEquals(testPhrase, new String.fromCharCodes(testCodepoints)); +} + +void testEmptyStringFromCharCodes() { + Expect.stringEquals("", new String.fromCharCodes([])); +} + +void testEmptyStringCharCodes() { + Expect.listEquals([], "".codeUnits); +} diff --git a/tests/corelib/unicode_test.dart b/tests/corelib/unicode_test.dart new file mode 100644 index 00000000000..8b029131589 --- /dev/null +++ b/tests/corelib/unicode_test.dart @@ -0,0 +1,16 @@ +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +class UnicodeTest { + static testMain() { + var lowerStrasse = new String.fromCharCodes([115, 116, 114, 97, 223, 101]); + Expect.equals("STRASSE", lowerStrasse.toUpperCase()); + } +} + +main() { + UnicodeTest.testMain(); +} diff --git a/tests/corelib/uri_base_test.dart b/tests/corelib/uri_base_test.dart new file mode 100644 index 00000000000..a54a28774a5 --- /dev/null +++ b/tests/corelib/uri_base_test.dart @@ -0,0 +1,14 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +main() { + try { + Uri base = Uri.base; + Expect.isTrue(Uri.base.scheme == "file" || Uri.base.scheme == "http"); + } on UnsupportedError catch (e) { + Expect.isTrue(e.toString().contains("'Uri.base' is not supported")); + } +} diff --git a/tests/corelib/uri_example_test.dart b/tests/corelib/uri_example_test.dart new file mode 100644 index 00000000000..388f717a657 --- /dev/null +++ b/tests/corelib/uri_example_test.dart @@ -0,0 +1,96 @@ +// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +library uri.examples; + +// Examples from the Uri class documentation. +// Get an error if the documentation starts to be wrong. +// REMEMBER TO UPDATE BOTH. + +import "package:expect/expect.dart"; +import 'dart:convert'; + +main() { + // Uri.http + test("http://example.org/path?q=dart", + new Uri.http("example.org", "/path", {"q": "dart"})); + test("http://user:pass@localhost:8080", + new Uri.http("user:pass@localhost:8080", "")); + test("http://example.org/a%20b", new Uri.http("example.org", "a b")); + test("http://example.org/a%252F", new Uri.http("example.org", "/a%2F")); + + // Uri.file + test("xxx/yyy", new Uri.file("xxx/yyy", windows: false)); + test("xxx/yyy/", new Uri.file("xxx/yyy/", windows: false)); + test("file:///xxx/yyy", new Uri.file("/xxx/yyy", windows: false)); + test("file:///xxx/yyy/", new Uri.file("/xxx/yyy/", windows: false)); + test("C%3A", new Uri.file("C:", windows: false)); + test("xxx/yyy", new Uri.file(r"xxx\yyy", windows: true)); + test("xxx/yyy/", new Uri.file(r"xxx\yyy\", windows: true)); + test("file:///xxx/yyy", new Uri.file(r"\xxx\yyy", windows: true)); + test("file:///xxx/yyy/", new Uri.file(r"\xxx\yyy/", windows: true)); + test("file:///C:/xxx/yyy", new Uri.file(r"C:\xxx\yyy", windows: true)); + test("file://server/share/file", + new Uri.file(r"\\server\share\file", windows: true)); + Expect.throws(() => new Uri.file(r"C:", windows: true)); + Expect.throws(() => new Uri.file(r"C:xxx\yyy", windows: true)); + + // isScheme. + var uri = Uri.parse("http://example.com/"); + Expect.isTrue(uri.isScheme("HTTP")); + + // toFilePath. + Expect.equals(r"xxx/yyy", Uri.parse("xxx/yyy").toFilePath(windows: false)); + Expect.equals(r"xxx/yyy/", Uri.parse("xxx/yyy/").toFilePath(windows: false)); + Expect.equals( + r"/xxx/yyy", Uri.parse("file:///xxx/yyy").toFilePath(windows: false)); + Expect.equals( + r"/xxx/yyy/", Uri.parse("file:///xxx/yyy/").toFilePath(windows: false)); + Expect.equals(r"/C:", Uri.parse("file:///C:").toFilePath(windows: false)); + Expect.equals(r"/C:a", Uri.parse("file:///C:a").toFilePath(windows: false)); + + Expect.equals(r"xxx\yyy", Uri.parse("xxx/yyy").toFilePath(windows: true)); + Expect.equals(r"xxx\yyy\", Uri.parse("xxx/yyy/").toFilePath(windows: true)); + Expect.equals( + r"\xxx\yyy", Uri.parse("file:///xxx/yyy").toFilePath(windows: true)); + Expect.equals( + r"\xxx\yyy\", Uri.parse("file:///xxx/yyy/").toFilePath(windows: true)); + Expect.equals( + r"C:\xxx\yyy", Uri.parse("file:///C:/xxx/yyy").toFilePath(windows: true)); + Expect.throws(() => Uri.parse("file:C:xxx/yyy").toFilePath(windows: true)); + Expect.equals(r"\\server\share\file", + Uri.parse("file://server/share/file").toFilePath(windows: true)); // + + // replace. + Uri uri1 = Uri.parse("a://b@c:4/d/e?f#g"); + Uri uri2 = uri1.replace(scheme: "A", path: "D/E/E", fragment: "G"); + Expect.equals("a://b@c:4/D/E/E?f#G", "$uri2"); + Uri uri3 = new Uri( + scheme: "A", + userInfo: uri1.userInfo, + host: uri1.host, + port: uri1.port, + path: "D/E/E", + query: uri1.query, + fragment: "G"); + Expect.equals("a://b@c:4/D/E/E?f#G", "$uri3"); + Expect.equals(uri2, uri3); + + // UriData.mimeType + var data = UriData.parse("data:text/plain;charset=utf-8,Hello%20World!"); + Expect.equals("text/plain", data.mimeType); + Expect.equals("utf-8", data.charset); + + // Uri.parseIPv6Address - shouldn't throw. + Uri.parseIPv6Address("::1"); + Uri.parseIPv6Address("FEDC:BA98:7654:3210:FEDC:BA98:7654:3210"); + Uri.parseIPv6Address("3ffe:2a00:100:7031::1"); + Uri.parseIPv6Address("::FFFF:129.144.52.38"); + Uri.parseIPv6Address("2010:836B:4179::836B:4179"); +} + +test(String result, Uri value) { + Expect.equals(Uri.parse(result), value); + Expect.equals(result, value.toString()); +} diff --git a/tests/corelib/uri_file_test.dart b/tests/corelib/uri_file_test.dart new file mode 100644 index 00000000000..355015700f5 --- /dev/null +++ b/tests/corelib/uri_file_test.dart @@ -0,0 +1,325 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +testFileUri() { + final unsupported = new UnsupportedError(""); + + var tests = [ + ["", "", ""], + ["relative", "relative", "relative"], + ["relative/", "relative/", "relative\\"], + ["a%20b", "a b", "a b"], + ["a%20b/", "a b/", "a b\\"], + ["a/b", "a/b", "a\\b"], + ["a/b/", "a/b/", "a\\b\\"], + ["a%20b/c%20d", "a b/c d", "a b\\c d"], + ["a%20b/c%20d/", "a b/c d/", "a b\\c d\\"], + ["file:///absolute", "/absolute", "\\absolute"], + ["file:///absolute", "/absolute", "\\absolute"], + ["file:///a/b", "/a/b", "\\a\\b"], + ["file:///a/b", "/a/b", "\\a\\b"], + ["file://server/a/b", unsupported, "\\\\server\\a\\b"], + ["file://server/a/b/", unsupported, "\\\\server\\a\\b\\"], + ["file:///C:/", "/C:/", "C:\\"], + ["file:///C:/a/b", "/C:/a/b", "C:\\a\\b"], + ["file:///C:/a/b/", "/C:/a/b/", "C:\\a\\b\\"], + ["http:/a/b", unsupported, unsupported], + ["https:/a/b", unsupported, unsupported], + ["urn:a:b", unsupported, unsupported], + ]; + + void check(String s, filePath, bool windows) { + Uri uri = Uri.parse(s); + if (filePath is Error) { + if (filePath is UnsupportedError) { + Expect.throws(() => uri.toFilePath(windows: windows), + (e) => e is UnsupportedError); + } else { + Expect.throws(() => uri.toFilePath(windows: windows)); + } + } else { + Expect.equals(filePath, uri.toFilePath(windows: windows)); + Expect.equals(s, new Uri.file(filePath, windows: windows).toString()); + } + } + + for (var test in tests) { + check(test[0], test[1], false); + check(test[0], test[2], true); + } + + Uri uri; + uri = Uri.parse("file:a"); + Expect.equals("/a", uri.toFilePath(windows: false)); + Expect.equals("\\a", uri.toFilePath(windows: true)); + uri = Uri.parse("file:a/"); + Expect.equals("/a/", uri.toFilePath(windows: false)); + Expect.equals("\\a\\", uri.toFilePath(windows: true)); +} + +testFileUriWindowsSlash() { + var tests = [ + ["", "", ""], + ["relative", "relative", "relative"], + ["relative/", "relative/", "relative\\"], + ["a%20b", "a b", "a b"], + ["a%20b/", "a b/", "a b\\"], + ["a/b", "a/b", "a\\b"], + ["a/b/", "a/b/", "a\\b\\"], + ["a%20b/c%20d", "a b/c d", "a b\\c d"], + ["a%20b/c%20d/", "a b/c d/", "a b\\c d\\"], + ["file:///absolute", "/absolute", "\\absolute"], + ["file:///absolute", "/absolute", "\\absolute"], + ["file:///a/b", "/a/b", "\\a\\b"], + ["file:///a/b", "/a/b", "\\a\\b"], + ["file://server/a/b", "//server/a/b", "\\\\server\\a\\b"], + ["file://server/a/b/", "//server/a/b/", "\\\\server\\a\\b\\"], + ["file:///C:/", "C:/", "C:\\"], + ["file:///C:/a/b", "C:/a/b", "C:\\a\\b"], + ["file:///C:/a/b/", "C:/a/b/", "C:\\a\\b\\"], + ["file:///C:/xxx/yyy", "C:\\xxx\\yyy", "C:\\xxx\\yyy"], + ]; + + for (var test in tests) { + Uri uri = new Uri.file(test[1], windows: true); + Expect.equals(test[0], uri.toString()); + Expect.equals(test[2], uri.toFilePath(windows: true)); + bool couldBeDir = uri.path.isEmpty || uri.path.endsWith('\\'); + Uri dirUri = new Uri.directory(test[1], windows: true); + Expect.isTrue(dirUri.path.isEmpty || dirUri.path.endsWith('/')); + if (couldBeDir) { + Expect.equals(uri, dirUri); + } + } +} + +testFileUriWindowsWin32Namespace() { + var tests = [ + ["\\\\?\\C:\\", "file:///C:/", "C:\\"], + ["\\\\?\\C:\\", "file:///C:/", "C:\\"], + [ + "\\\\?\\UNC\\server\\share\\file", + "file://server/share/file", + "\\\\server\\share\\file" + ], + ]; + + for (var test in tests) { + Uri uri = new Uri.file(test[0], windows: true); + Expect.equals(test[1], uri.toString()); + Expect.equals(test[2], uri.toFilePath(windows: true)); + } + + Expect.throws(() => new Uri.file("\\\\?\\file", windows: true), + (e) => e is ArgumentError); + Expect.throws( + () => new Uri.file("\\\\?\\UNX\\server\\share\\file", windows: true), + (e) => e is ArgumentError); + Expect.throws(() => new Uri.directory("\\\\?\\file", windows: true), + (e) => e is ArgumentError); + Expect.throws( + () => new Uri.directory("\\\\?\\UNX\\server\\share\\file", windows: true), + (e) => e is ArgumentError); +} + +testFileUriDriveLetter() { + check(String s, String nonWindows, String windows) { + Uri uri; + uri = Uri.parse(s); + Expect.equals(nonWindows, uri.toFilePath(windows: false)); + if (windows != null) { + Expect.equals(windows, uri.toFilePath(windows: true)); + } else { + Expect.throws( + () => uri.toFilePath(windows: true), (e) => e is UnsupportedError); + } + } + + check("file:///C:", "/C:", "C:\\"); + check("file:///C:/", "/C:/", "C:\\"); + check("file:///C:a", "/C:a", null); + check("file:///C:a/", "/C:a/", null); + + Expect.throws( + () => new Uri.file("C:", windows: true), (e) => e is ArgumentError); + Expect.throws( + () => new Uri.file("C:a", windows: true), (e) => e is ArgumentError); + Expect.throws( + () => new Uri.file("C:a\b", windows: true), (e) => e is ArgumentError); + Expect.throws( + () => new Uri.directory("C:", windows: true), (e) => e is ArgumentError); + Expect.throws( + () => new Uri.directory("C:a", windows: true), (e) => e is ArgumentError); + Expect.throws(() => new Uri.directory("C:a\b", windows: true), + (e) => e is ArgumentError); +} + +testFileUriResolve() { + var tests = [ + ["file:///a", "/a", "", "\\a", ""], + ["file:///a/", "/a/", "", "\\a\\", ""], + ["file:///b", "/a", "b", "\\a", "b"], + ["file:///b/", "/a", "b/", "\\a", "b\\"], + ["file:///a/b", "/a/", "b", "\\a\\", "b"], + ["file:///a/b/", "/a/", "b/", "\\a\\", "b\\"], + ["file:///a/c/d", "/a/b", "c/d", "\\a\\b", "c\\d"], + ["file:///a/c/d/", "/a/b", "c/d/", "\\a\\b", "c\\d\\"], + ["file:///a/b/c/d", "/a/b/", "c/d", "\\a\\b\\", "c\\d"], + ["file:///a/b/c/d/", "/a/b/", "c/d/", "\\a\\b\\", "c\\d\\"], + ]; + + check(String s, String absolute, String relative, bool windows) { + Uri absoluteUri = new Uri.file(absolute, windows: windows); + Uri relativeUri = new Uri.file(relative, windows: windows); + String relativeString = windows ? relative.replaceAll("\\", "/") : relative; + Expect.equals(s, absoluteUri.resolve(relativeString).toString()); + Expect.equals(s, absoluteUri.resolveUri(relativeUri).toString()); + } + + for (var test in tests) { + check(test[0], test[1], test[2], false); + check(test[0], test[1], test[2], true); + check(test[0], test[1], test[4], true); + check(test[0], test[3], test[2], true); + check(test[0], test[3], test[4], true); + } +} + +testFileUriIllegalCharacters() { + // Slash is an invalid character in file names on both non-Windows + // and Windows. + Uri uri = Uri.parse("file:///a%2Fb"); + Expect.throws( + () => uri.toFilePath(windows: false), (e) => e is UnsupportedError); + Expect.throws( + () => uri.toFilePath(windows: true), (e) => e is UnsupportedError); + + // Illegal characters in windows file names. + var illegalWindowsPaths = [ + "ab", + "a:b", + "a\"b", + "a|b", + "a?b", + "a*b", + "\\\\?\\c:\\a/b" + ]; + + for (var test in illegalWindowsPaths) { + Expect.throws( + () => new Uri.file(test, windows: true), (e) => e is ArgumentError); + Expect.throws(() => new Uri.file("\\$test", windows: true), + (e) => e is ArgumentError); + Expect.throws(() => new Uri.directory(test, windows: true), + (e) => e is ArgumentError); + Expect.throws(() => new Uri.directory("\\$test", windows: true), + (e) => e is ArgumentError); + + // It is possible to create non-Windows URIs, but not Windows URIs. + Uri uri = new Uri.file(test, windows: false); + Uri absoluteUri = new Uri.file("/$test", windows: false); + Uri dirUri = new Uri.directory(test, windows: false); + Uri dirAbsoluteUri = new Uri.directory("/$test", windows: false); + Expect.throws( + () => new Uri.file(test, windows: true), (e) => e is ArgumentError); + Expect.throws(() => new Uri.file("\\$test", windows: true), + (e) => e is ArgumentError); + Expect.throws(() => new Uri.directory(test, windows: true), + (e) => e is ArgumentError); + Expect.throws(() => new Uri.directory("\\$test", windows: true), + (e) => e is ArgumentError); + + // It is possible to extract non-Windows file path, but not + // Windows file path. + Expect.equals(test, uri.toFilePath(windows: false)); + Expect.equals("/$test", absoluteUri.toFilePath(windows: false)); + Expect.equals("$test/", dirUri.toFilePath(windows: false)); + Expect.equals("/$test/", dirAbsoluteUri.toFilePath(windows: false)); + Expect.throws( + () => uri.toFilePath(windows: true), (e) => e is UnsupportedError); + Expect.throws(() => absoluteUri.toFilePath(windows: true), + (e) => e is UnsupportedError); + Expect.throws( + () => dirUri.toFilePath(windows: true), (e) => e is UnsupportedError); + Expect.throws(() => dirAbsoluteUri.toFilePath(windows: true), + (e) => e is UnsupportedError); + } + + // Backslash + illegalWindowsPaths = ["a\\b", "a\\b\\"]; + for (var test in illegalWindowsPaths) { + // It is possible to create both non-Windows URIs, and Windows URIs. + Uri uri = new Uri.file(test, windows: false); + Uri absoluteUri = new Uri.file("/$test", windows: false); + Uri dirUri = new Uri.directory(test, windows: false); + Uri dirAbsoluteUri = new Uri.directory("/$test", windows: false); + new Uri.file(test, windows: true); + new Uri.file("\\$test", windows: true); + + // It is possible to extract non-Windows file path, but not + // Windows file path from the non-Windows URI (it has a backslash + // in a path segment). + Expect.equals(test, uri.toFilePath(windows: false)); + Expect.equals("/$test", absoluteUri.toFilePath(windows: false)); + Expect.equals("$test/", dirUri.toFilePath(windows: false)); + Expect.equals("/$test/", dirAbsoluteUri.toFilePath(windows: false)); + Expect.throws( + () => uri.toFilePath(windows: true), (e) => e is UnsupportedError); + Expect.throws(() => absoluteUri.toFilePath(windows: true), + (e) => e is UnsupportedError); + Expect.throws( + () => dirUri.toFilePath(windows: true), (e) => e is UnsupportedError); + Expect.throws(() => dirAbsoluteUri.toFilePath(windows: true), + (e) => e is UnsupportedError); + } +} + +testFileUriIllegalDriveLetter() { + Expect.throws( + () => new Uri.file("1:\\", windows: true), (e) => e is ArgumentError); + Expect.throws(() => new Uri.directory("1:\\", windows: true), + (e) => e is ArgumentError); + Uri uri = new Uri.file("1:\\", windows: false); + Uri dirUri = new Uri.directory("1:\\", windows: false); + Expect.equals("1:\\", uri.toFilePath(windows: false)); + Expect.equals("1:\\/", dirUri.toFilePath(windows: false)); + Expect.throws( + () => uri.toFilePath(windows: true), (e) => e is UnsupportedError); + Expect.throws( + () => dirUri.toFilePath(windows: true), (e) => e is UnsupportedError); +} + +testAdditionalComponents() { + check(String s, {bool windowsOk: false}) { + Uri uri = Uri.parse(s); + Expect.throws( + () => uri.toFilePath(windows: false), (e) => e is UnsupportedError); + if (windowsOk) { + Expect.isTrue(uri.toFilePath(windows: true) is String); + } else { + Expect.throws( + () => uri.toFilePath(windows: true), (e) => e is UnsupportedError); + } + } + + check("file:///path?query"); + check("file:///path#fragment"); + check("file:///path?query#fragment"); + check("file://host/path", windowsOk: true); + check("file://user:password@host/path", windowsOk: true); +} + +main() { + testFileUri(); + testFileUriWindowsSlash(); + testFileUriDriveLetter(); + testFileUriWindowsWin32Namespace(); + testFileUriResolve(); + testFileUriIllegalCharacters(); + testFileUriIllegalDriveLetter(); + testAdditionalComponents(); +} diff --git a/tests/corelib/uri_http_test.dart b/tests/corelib/uri_http_test.dart new file mode 100644 index 00000000000..60d9732049d --- /dev/null +++ b/tests/corelib/uri_http_test.dart @@ -0,0 +1,82 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +testHttpUri() { + void check(Uri uri, String expected) { + Expect.equals(expected, uri.toString()); + } + + check(new Uri.http("", ""), "http:"); + check(new Uri.http("@:", ""), "http://"); + check(new Uri.http("@:8080", ""), "http://:8080"); + check(new Uri.http("@host:", ""), "http://host"); + check(new Uri.http("@host:", ""), "http://host"); + check(new Uri.http("xxx:yyy@host:8080", ""), "http://xxx:yyy@host:8080"); + check(new Uri.http("host", "a"), "http://host/a"); + check(new Uri.http("host", "/a"), "http://host/a"); + check(new Uri.http("host", "a/"), "http://host/a/"); + check(new Uri.http("host", "/a/"), "http://host/a/"); + check(new Uri.http("host", "a/b"), "http://host/a/b"); + check(new Uri.http("host", "/a/b"), "http://host/a/b"); + check(new Uri.http("host", "a/b/"), "http://host/a/b/"); + check(new Uri.http("host", "/a/b/"), "http://host/a/b/"); + check(new Uri.http("host", "a b"), "http://host/a%20b"); + check(new Uri.http("host", "/a b"), "http://host/a%20b"); + check(new Uri.http("host", "/a b/"), "http://host/a%20b/"); + check(new Uri.http("host", "/a%2F"), "http://host/a%252F"); + check(new Uri.http("host", "/a%2F/"), "http://host/a%252F/"); + check(new Uri.http("host", "/a/b", {"c": "d"}), "http://host/a/b?c=d"); + check( + new Uri.http("host", "/a/b", {"c=": "&d"}), "http://host/a/b?c%3D=%26d"); + check(new Uri.http("[::]", "a"), "http://[::]/a"); + check(new Uri.http("[::127.0.0.1]", "a"), "http://[::127.0.0.1]/a"); +} + +testHttpsUri() { + void check(Uri uri, String expected) { + Expect.equals(expected, uri.toString()); + } + + check(new Uri.https("", ""), "https:"); + check(new Uri.https("@:", ""), "https://"); + check(new Uri.https("@:8080", ""), "https://:8080"); + check(new Uri.https("@host:", ""), "https://host"); + check(new Uri.https("@host:", ""), "https://host"); + check(new Uri.https("xxx:yyy@host:8080", ""), "https://xxx:yyy@host:8080"); + check(new Uri.https("host", "a"), "https://host/a"); + check(new Uri.https("host", "/a"), "https://host/a"); + check(new Uri.https("host", "a/"), "https://host/a/"); + check(new Uri.https("host", "/a/"), "https://host/a/"); + check(new Uri.https("host", "a/b"), "https://host/a/b"); + check(new Uri.https("host", "/a/b"), "https://host/a/b"); + check(new Uri.https("host", "a/b/"), "https://host/a/b/"); + check(new Uri.https("host", "/a/b/"), "https://host/a/b/"); + check(new Uri.https("host", "a b"), "https://host/a%20b"); + check(new Uri.https("host", "/a b"), "https://host/a%20b"); + check(new Uri.https("host", "/a b/"), "https://host/a%20b/"); + check(new Uri.https("host", "/a%2F"), "https://host/a%252F"); + check(new Uri.https("host", "/a%2F/"), "https://host/a%252F/"); + check(new Uri.https("host", "/a/b", {"c": "d"}), "https://host/a/b?c=d"); + check(new Uri.https("host", "/a/b", {"c=": "&d"}), + "https://host/a/b?c%3D=%26d"); + check(new Uri.https("[::]", "a"), "https://[::]/a"); + check(new Uri.https("[::127.0.0.1]", "a"), "https://[::127.0.0.1]/a"); +} + +testResolveHttpScheme() { + String s = "//myserver:1234/path/some/thing"; + Uri uri = Uri.parse(s); + Uri http = new Uri(scheme: "http"); + Uri https = new Uri(scheme: "https"); + Expect.equals("http:$s", http.resolveUri(uri).toString()); + Expect.equals("https:$s", https.resolveUri(uri).toString()); +} + +main() { + testHttpUri(); + testHttpsUri(); + testResolveHttpScheme(); +} diff --git a/tests/corelib/uri_ipv4_test.dart b/tests/corelib/uri_ipv4_test.dart new file mode 100644 index 00000000000..830e9ef2f2c --- /dev/null +++ b/tests/corelib/uri_ipv4_test.dart @@ -0,0 +1,31 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:expect/expect.dart'; + +void testParseIPv4Address() { + void pass(String host, List out) { + Expect.listEquals(Uri.parseIPv4Address(host), out); + } + + void fail(String host) { + Expect.throws( + () => Uri.parseIPv4Address(host), (e) => e is FormatException); + } + + pass('127.0.0.1', [127, 0, 0, 1]); + pass('128.0.0.1', [128, 0, 0, 1]); + pass('255.255.255.255', [255, 255, 255, 255]); + pass('0.0.0.0', [0, 0, 0, 0]); + fail('127.0.0.-1'); + fail('255.255.255.256'); + fail('0.0.0.0.'); + fail('0.0.0.0.0'); + fail('a.0.0.0'); + fail('0.0..0'); +} + +void main() { + testParseIPv4Address(); +} diff --git a/tests/corelib/uri_ipv6_test.dart b/tests/corelib/uri_ipv6_test.dart new file mode 100644 index 00000000000..25e99577998 --- /dev/null +++ b/tests/corelib/uri_ipv6_test.dart @@ -0,0 +1,148 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:expect/expect.dart'; + +void testValidIpv6Uri() { + var path = 'http://[::1]:1234/path?query=5#now'; + var uri = Uri.parse(path); + Expect.equals('http', uri.scheme); + Expect.equals('::1', uri.host); + Expect.equals(1234, uri.port); + Expect.equals('/path', uri.path); + Expect.equals('query=5', uri.query); + Expect.equals('now', uri.fragment); + Expect.equals(path, uri.toString()); + + path = 'http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:8080/index.html'; + uri = Uri.parse(path); + Expect.equals('http', uri.scheme); + Expect.equals('fedc:ba98:7654:3210:fedc:ba98:7654:3210', uri.host); + Expect.equals(8080, uri.port); + Expect.equals('/index.html', uri.path); + Expect.equals(path.toLowerCase(), uri.toString()); + + path = 'http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html'; + uri = Uri.parse(path); + Expect.equals('http', uri.scheme); + Expect.equals('fedc:ba98:7654:3210:fedc:ba98:7654:3210', uri.host); + Expect.equals(80, uri.port); + Expect.equals('/index.html', uri.path); + Expect.equals('http://[fedc:ba98:7654:3210:fedc:ba98:7654:3210]/index.html', + uri.toString()); + + path = 'https://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:443/index.html'; + uri = Uri.parse(path); + Expect.equals('https', uri.scheme); + Expect.equals('fedc:ba98:7654:3210:fedc:ba98:7654:3210', uri.host); + Expect.equals(443, uri.port); + Expect.equals('/index.html', uri.path); + Expect.equals('https://[fedc:ba98:7654:3210:fedc:ba98:7654:3210]/index.html', + uri.toString()); + + path = 'http://[1080:0:0:0:8:800:200C:417A]/index.html'; + uri = Uri.parse(path); + Expect.equals('http', uri.scheme); + Expect.equals('1080:0:0:0:8:800:200c:417a', uri.host); + Expect.equals(80, uri.port); + Expect.equals('/index.html', uri.path); + Expect.equals(path.toLowerCase(), uri.toString()); + + path = 'http://[3ffe:2a00:100:7031::1]'; + uri = Uri.parse(path); + Expect.equals('http', uri.scheme); + Expect.equals('3ffe:2a00:100:7031::1', uri.host); + Expect.equals(80, uri.port); + Expect.equals('', uri.path); + Expect.equals(path, uri.toString()); + + path = 'http://[1080::8:800:200C:417A]/foo'; + uri = Uri.parse(path); + Expect.equals('http', uri.scheme); + Expect.equals('1080::8:800:200c:417a', uri.host); + Expect.equals(80, uri.port); + Expect.equals('/foo', uri.path); + Expect.equals(path.toLowerCase(), uri.toString()); + + path = 'http://[::192.9.5.5]/ipng'; + uri = Uri.parse(path); + Expect.equals('http', uri.scheme); + Expect.equals('::192.9.5.5', uri.host); + Expect.equals(80, uri.port); + Expect.equals('/ipng', uri.path); + Expect.equals(path, uri.toString()); + + path = 'http://[::FFFF:129.144.52.38]:8080/index.html'; + uri = Uri.parse(path); + Expect.equals('http', uri.scheme); + Expect.equals('::ffff:129.144.52.38', uri.host); + Expect.equals(8080, uri.port); + Expect.equals('/index.html', uri.path); + Expect.equals(path.toLowerCase(), uri.toString()); + + path = 'http://[::FFFF:129.144.52.38]:80/index.html'; + uri = Uri.parse(path); + Expect.equals('http', uri.scheme); + Expect.equals('::ffff:129.144.52.38', uri.host); + Expect.equals(80, uri.port); + Expect.equals('/index.html', uri.path); + Expect.equals('http://[::ffff:129.144.52.38]/index.html', uri.toString()); + + path = 'https://[::FFFF:129.144.52.38]:443/index.html'; + uri = Uri.parse(path); + Expect.equals('https', uri.scheme); + Expect.equals('::ffff:129.144.52.38', uri.host); + Expect.equals(443, uri.port); + Expect.equals('/index.html', uri.path); + Expect.equals('https://[::ffff:129.144.52.38]/index.html', uri.toString()); + + path = 'http://[2010:836B:4179::836B:4179]'; + uri = Uri.parse(path); + Expect.equals('http', uri.scheme); + Expect.equals('2010:836b:4179::836b:4179', uri.host); + Expect.equals(80, uri.port); + Expect.equals('', uri.path); + Expect.equals(path.toLowerCase(), uri.toString()); +} + +void testParseIPv6Address() { + void pass(String host, List expected) { + Expect.listEquals(expected, Uri.parseIPv6Address(host)); + } + + void fail(String host) { + Expect.throws( + () => Uri.parseIPv6Address(host), (e) => e is FormatException); + } + + pass('::127.0.0.1', [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127, 0, 0, 1]); + pass('0::127.0.0.1', [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127, 0, 0, 1]); + pass('::', [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); + pass('0::', [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]); + fail(':0::127.0.0.1'); + fail('0:::'); + fail(':::'); + fail('::0:'); + fail('::0::'); + fail('::0::0'); + fail('00000::0'); + fail('-1::0'); + fail('-AAA::0'); + fail('0::127.0.0.1:0'); + fail('0::127.0.0'); + pass('0::1111', [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, 17]); + pass('2010:836B:4179::836B:4179', + [32, 16, 131, 107, 65, 121, 0, 0, 0, 0, 0, 0, 131, 107, 65, 121]); + fail('2010:836B:4179:0000:127.0.0.1'); + fail('2010:836B:4179:0000:0000:127.0.0.1'); + fail('2010:836B:4179:0000:0000:0000::127.0.0.1'); + fail('2010:836B:4179:0000:0000:0000:0000:127.0.0.1'); + pass('2010:836B:4179:0000:0000:0000:127.0.0.1', + [32, 16, 131, 107, 65, 121, 0, 0, 0, 0, 0, 0, 127, 0, 0, 1]); +} + +void main() { + testValidIpv6Uri(); + testParseIPv6Address(); +} diff --git a/tests/corelib/uri_normalize_path_test.dart b/tests/corelib/uri_normalize_path_test.dart new file mode 100644 index 00000000000..07b7c2654a4 --- /dev/null +++ b/tests/corelib/uri_normalize_path_test.dart @@ -0,0 +1,59 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +library uriNormalizePathTest; + +import "package:expect/expect.dart"; + +test(String path, String normalizedPath) { + for (var scheme in ["http", "file", "unknown"]) { + for (var auth in [ + [null, "hostname", null], + ["userinfo", "hostname", 1234], + [null, null, null] + ]) { + for (var query in [null, "query"]) { + for (var fragment in [null, "fragment"]) { + var base = new Uri( + scheme: scheme, + userInfo: auth[0], + host: auth[1], + port: auth[2], + path: path, + query: query, + fragment: fragment); + var expected = base.replace( + path: (base.hasAuthority && normalizedPath.isEmpty) + ? "/" + : normalizedPath); + var actual = base.normalizePath(); + Expect.equals(expected, actual, "$base"); + } + } + } + } +} + +testNoChange(String path) { + test(path, path); +} + +main() { + testNoChange("foo/bar/baz"); + testNoChange("/foo/bar/baz"); + testNoChange("foo/bar/baz/"); + test("foo/bar/..", "foo/"); + test("foo/bar/.", "foo/bar/"); + test("foo/./bar/../baz", "foo/baz"); + test("../../foo", "foo"); + test("./../foo", "foo"); + test("./../", ""); + test("./../.", ""); + test("foo/bar/baz/../../../../qux", "/qux"); + test("/foo/bar/baz/../../../../qux", "/qux"); + test(".", ""); + test("..", ""); + test("/.", "/"); + test("/..", "/"); +} diff --git a/tests/corelib/uri_normalize_test.dart b/tests/corelib/uri_normalize_test.dart new file mode 100644 index 00000000000..af97653fc74 --- /dev/null +++ b/tests/corelib/uri_normalize_test.dart @@ -0,0 +1,77 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +testNormalizePath() { + test(String expected, String path, {String scheme, String host}) { + var uri = new Uri(scheme: scheme, host: host, path: path); + Expect.equals(expected, uri.toString()); + if (scheme == null && host == null) { + Expect.equals(expected, uri.path); + } + } + + var unreserved = "-._~0123456789" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz"; + + test("A", "%41"); + test("AB", "%41%42"); + test("%40AB", "%40%41%42"); + test("a", "%61"); + test("ab", "%61%62"); + test("%60ab", "%60%61%62"); + test(unreserved, unreserved); + + var x = new StringBuffer(); + for (int i = 32; i < 128; i++) { + if (unreserved.indexOf(new String.fromCharCode(i)) != -1) { + x.writeCharCode(i); + } else { + x.write("%"); + x.write(i.toRadixString(16)); + } + } + Expect.equals(x.toString().toUpperCase(), + new Uri(path: x.toString()).toString().toUpperCase()); + + // Normalized paths. + + // Full absolute path normalization for absolute paths. + test("/a/b/c/", "/../a/./b/z/../c/d/.."); + test("/a/b/c/", "/./a/b/c/"); + test("/a/b/c/", "/./../a/b/c/"); + test("/a/b/c/", "/./../a/b/c/."); + test("/a/b/c/", "/./../a/b/c/z/./.."); + test("/", "/a/.."); + // Full absolute path normalization for URIs with scheme. + test("s:a/b/c/", "../a/./b/z/../c/d/..", scheme: "s"); + test("s:a/b/c/", "./a/b/c/", scheme: "s"); + test("s:a/b/c/", "./../a/b/c/", scheme: "s"); + test("s:a/b/c/", "./../a/b/c/.", scheme: "s"); + test("s:a/b/c/", "./../a/b/c/z/./..", scheme: "s"); + test("s:/", "/a/..", scheme: "s"); + test("s:/", "a/..", scheme: "s"); + // Full absolute path normalization for URIs with authority. + test("//h/a/b/c/", "../a/./b/z/../c/d/..", host: "h"); + test("//h/a/b/c/", "./a/b/c/", host: "h"); + test("//h/a/b/c/", "./../a/b/c/", host: "h"); + test("//h/a/b/c/", "./../a/b/c/.", host: "h"); + test("//h/a/b/c/", "./../a/b/c/z/./..", host: "h"); + test("//h/", "/a/..", host: "h"); + test("//h/", "a/..", host: "h"); + // Partial relative normalization (allowing leading .. or ./ for current dir). + test("../a/b/c/", "../a/./b/z/../c/d/.."); + test("a/b/c/", "./a/b/c/"); + test("../a/b/c/", "./../a/b/c/"); + test("../a/b/c/", "./../a/b/c/."); + test("../a/b/c/", "./../a/b/c/z/./.."); + test("/", "/a/.."); + test("./", "a/.."); +} + +main() { + testNormalizePath(); +} diff --git a/tests/corelib/uri_parameters_all_test.dart b/tests/corelib/uri_parameters_all_test.dart new file mode 100644 index 00000000000..f3f6dfc4ffd --- /dev/null +++ b/tests/corelib/uri_parameters_all_test.dart @@ -0,0 +1,51 @@ +// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; +import 'dart:convert'; + +main() { + testAll(["a", "b", "c"]); + testAll([""]); + testAll(["a"]); + testAll(["", ""]); + testAll(["baz"]); + + testParse("z&y&w&z", { + "z": ["", ""], + "y": [""], + "w": [""] + }); + testParse("x=42&y=42&x=37&y=37", { + "x": ["42", "37"], + "y": ["42", "37"] + }); + testParse("x&x&x&x&x", { + "x": ["", "", "", "", ""] + }); + testParse("x=&&y", { + "x": [""], + "y": [""] + }); +} + +testAll(List values) { + var uri = + new Uri(scheme: "foo", path: "bar", queryParameters: {"baz": values}); + var list = uri.queryParametersAll["baz"]; + Expect.listEquals(values, list); +} + +testParse(query, results) { + var uri = new Uri(scheme: "foo", path: "bar", query: query); + var params = uri.queryParametersAll; + for (var k in results.keys) { + Expect.listEquals(results[k], params[k]); + } + uri = new Uri(scheme: "foo", path: "bar", queryParameters: results); + params = uri.queryParametersAll; + for (var k in results.keys) { + Expect.listEquals(results[k], params[k]); + } +} diff --git a/tests/corelib/uri_parse_test.dart b/tests/corelib/uri_parse_test.dart new file mode 100644 index 00000000000..4c93b2be0e2 --- /dev/null +++ b/tests/corelib/uri_parse_test.dart @@ -0,0 +1,72 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +void testUriCombi() { + var schemes = ["", "file", "ws", "ftp"]; + var fragments = ["", "#", "#f", "#fragment", "#l:?/"]; + var queries = ["", "?", "?q", "?query", "?q:/"]; + var paths = ["/", "/x", "/x/y", "/x/y/", "/x:y", "x", "x/y", "x/y/"]; + var userInfos = ["", "x", "xxx", "x:4", "xxx:444", "x:4:x"]; + var hosts = ["", "h", "hhh", "h:4", "hhh:444", "[::1.2.3.4]"]; + + void check(uriString, scheme, fragment, query, path, user, host) { + for (var uri in [ + Uri.parse(uriString), + Uri.parse(">\u{10000}>$uriString<\u{10000}<", 4, uriString.length + 4), + Uri.parse( + "http://example.com/$uriString#?:/[]\"", 19, uriString.length + 19), + Uri.parse(uriString * 3, uriString.length, uriString.length * 2) + ]) { + String name = "$uriString -> $uri"; + Expect.equals(scheme, uri.scheme, name); + var uriFragment = uri.fragment; + if (fragment.startsWith('#')) uriFragment = "#$uriFragment"; + Expect.equals(fragment, uriFragment, name); + var uriQuery = uri.query; + if (query.startsWith('?')) uriQuery = "?$uriQuery"; + Expect.equals(query, uriQuery, name); + Expect.equals(path, uri.path, name); + Expect.equals(user, uri.userInfo, name); + var uriHost = uri.host; + if (host.startsWith("[")) uriHost = "[$uriHost]"; + if (uri.port != 0) uriHost += ":${uri.port}"; + Expect.equals(host, uriHost, name); + } + } + + for (var scheme in schemes) { + for (var fragment in fragments) { + for (var query in queries) { + for (var path in paths) { + // File scheme URIs always get a leading slash. + if (scheme == "file" && !path.startsWith('/')) continue; + for (var user in userInfos) { + for (var host in hosts) { + var auth = host; + var s = scheme; + if (user.isNotEmpty) auth = "$user@$auth"; + if (auth.isNotEmpty) auth = "//$auth"; + if (auth.isNotEmpty && !path.startsWith('/')) continue; + check( + "$scheme${scheme.isEmpty ? "" : ":"}" + "$auth$path$query$fragment", + scheme, + fragment, + query, + path, + user, + host); + } + } + } + } + } + } +} + +void main() { + testUriCombi(); +} diff --git a/tests/corelib/uri_path_test.dart b/tests/corelib/uri_path_test.dart new file mode 100644 index 00000000000..d46c3a7fcb4 --- /dev/null +++ b/tests/corelib/uri_path_test.dart @@ -0,0 +1,188 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "dart:collection"; + +import "package:expect/expect.dart"; + +void testInvalidArguments() {} + +void testPath() { + void test(s, uri) { + Expect.equals(s, uri.toString()); + Expect.equals(uri, Uri.parse(s)); + } + + test("http:", new Uri(scheme: "http")); + test("http://host/xxx", new Uri(scheme: "http", host: "host", path: "xxx")); + test("http://host/xxx", new Uri(scheme: "http", host: "host", path: "/xxx")); + test("http://host/xxx", + new Uri(scheme: "http", host: "host", pathSegments: ["xxx"])); + test("http://host/xxx/yyy", + new Uri(scheme: "http", host: "host", path: "xxx/yyy")); + test("http://host/xxx/yyy", + new Uri(scheme: "http", host: "host", path: "/xxx/yyy")); + test("http://host/xxx/yyy", + new Uri(scheme: "http", host: "host", pathSegments: ["xxx", "yyy"])); + + test("urn:", new Uri(scheme: "urn")); + test("urn:xxx", new Uri(scheme: "urn", path: "xxx")); + test("urn:xxx:yyy", new Uri(scheme: "urn", path: "xxx:yyy")); + + Expect.equals(3, new Uri(path: "xxx/yyy/zzz").pathSegments.length); + Expect.equals(3, new Uri(path: "/xxx/yyy/zzz").pathSegments.length); + Expect.equals(3, Uri.parse("http://host/xxx/yyy/zzz").pathSegments.length); + Expect.equals(3, Uri.parse("file:///xxx/yyy/zzz").pathSegments.length); +} + +void testPathSegments() { + void test(String path, List segments) { + void check(uri) { + Expect.equals(path, uri.path); + Expect.equals(path, uri.toString()); + Expect.listEquals(segments, uri.pathSegments); + } + + var uri1 = new Uri(pathSegments: segments); + var uri2 = new Uri(path: path); + check(uri1); + check(uri2); + Expect.equals(uri1, uri2); + } + + test("", []); + test("%20", [" "]); + test("%20/%20%20", [" ", " "]); + test("A", ["A"]); + test("%C3%B8", ["ø"]); + test("%C3%B8/%C3%A5", ["ø", "å"]); + test("%C8%A4/%E5%B9%B3%E4%BB%AE%E5%90%8D", ["Ȥ", "平仮名"]); + test("A/b", ["A", "b"]); + test("A/%25", ["A", "%"]); + test("%2F/a%2Fb", ["/", "a/b"]); + test("name;v=1.1", ["name;v=1.1"]); + test("name,v=1.1", ["name,v=1.1"]); + test("name;v=1.1/name,v=1.1", ["name;v=1.1", "name,v=1.1"]); + + var unreserved = "-._~0123456789" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz"; + var subDelimiters = r"!$&'()*+,;="; + var additionalPathChars = ":@"; + var pchar = unreserved + subDelimiters + additionalPathChars; + + var encoded = new StringBuffer(); + var unencoded = new StringBuffer(); + for (int i = 32; i < 128; i++) { + if (pchar.indexOf(new String.fromCharCode(i)) != -1) { + encoded.writeCharCode(i); + } else { + encoded.write("%"); + encoded.write(i.toRadixString(16).toUpperCase()); + } + unencoded.writeCharCode(i); + } + encoded = encoded.toString(); + unencoded = unencoded.toString(); + test(encoded, [unencoded]); + test(encoded + "/" + encoded, [unencoded, unencoded]); + + Uri uri; + List pathSegments = ["xxx", "yyy", "zzz"]; + + uri = new Uri(pathSegments: pathSegments); + Expect.equals(3, uri.pathSegments.length); + uri = new Uri(pathSegments: pathSegments.where((_) => true)); + Expect.equals(3, uri.pathSegments.length); + uri = new Uri(pathSegments: new DoubleLinkedQueue.from(pathSegments)); + Expect.equals(3, uri.pathSegments.length); + + uri = new Uri(scheme: "http", host: "host", pathSegments: pathSegments); + Expect.equals(3, uri.pathSegments.length); + uri = new Uri( + scheme: "http", + host: "host", + pathSegments: pathSegments.where((_) => true)); + Expect.equals(3, uri.pathSegments.length); + uri = new Uri( + scheme: "http", + host: "host", + pathSegments: new DoubleLinkedQueue.from(pathSegments)); + Expect.equals(3, uri.pathSegments.length); + + uri = new Uri(scheme: "file", pathSegments: pathSegments); + Expect.equals(3, uri.pathSegments.length); + uri = new Uri(scheme: "file", pathSegments: pathSegments.where((_) => true)); + Expect.equals(3, uri.pathSegments.length); + uri = new Uri( + scheme: "file", pathSegments: new DoubleLinkedQueue.from(pathSegments)); + Expect.equals(3, uri.pathSegments.length); +} + +void testPathCompare() { + void test(Uri uri1, Uri uri2) { + Expect.equals(uri1, uri2); + Expect.equals(uri2, uri1); + } + + test(new Uri(scheme: "http", host: "host", path: "xxx"), + new Uri(scheme: "http", host: "host", path: "/xxx")); + test(new Uri(scheme: "http", host: "host", pathSegments: ["xxx"]), + new Uri(scheme: "http", host: "host", path: "/xxx")); + test(new Uri(scheme: "http", host: "host", pathSegments: ["xxx"]), + new Uri(scheme: "http", host: "host", path: "xxx")); + test(new Uri(scheme: "file", path: "xxx"), + new Uri(scheme: "file", path: "/xxx")); + test(new Uri(scheme: "file", pathSegments: ["xxx"]), + new Uri(scheme: "file", path: "/xxx")); + test(new Uri(scheme: "file", pathSegments: ["xxx"]), + new Uri(scheme: "file", path: "xxx")); +} + +testPathSegmentsUnmodifiableList() { + void test(list) { + bool isUnsupported(e) => e is UnsupportedError; + + Expect.equals("a", list[0]); + Expect.throws(() => list[0] = "c", isUnsupported); + Expect.equals(2, list.length); + Expect.throws(() => list.length = 1, isUnsupported); + Expect.throws(() => list.add("c"), isUnsupported); + Expect.throws(() => list.addAll(["c", "d"]), isUnsupported); + Expect.listEquals(["b", "a"], list.reversed.toList()); + Expect.throws(() => list.sort(), isUnsupported); + Expect.equals(0, list.indexOf("a")); + Expect.equals(0, list.lastIndexOf("a")); + Expect.throws(() => list.clear(), isUnsupported); + Expect.throws(() => list.insert(1, "c"), isUnsupported); + Expect.throws(() => list.insertAll(1, ["c", "d"]), isUnsupported); + Expect.throws(() => list.setAll(1, ["c", "d"]), isUnsupported); + Expect.throws(() => list.remove("a"), isUnsupported); + Expect.throws(() => list.removeAt(0), isUnsupported); + Expect.throws(() => list.removeLast(), isUnsupported); + Expect.throws(() => list.removeWhere((e) => true), isUnsupported); + Expect.throws(() => list.retainWhere((e) => false), isUnsupported); + Expect.listEquals(["a"], list.sublist(0, 1)); + Expect.listEquals(["a"], list.getRange(0, 1).toList()); + Expect.throws(() => list.setRange(0, 1, ["c"]), isUnsupported); + Expect.throws(() => list.removeRange(0, 1), isUnsupported); + Expect.throws(() => list.fillRange(0, 1, "c"), isUnsupported); + Expect.throws(() => list.replaceRange(0, 1, ["c"]), isUnsupported); + Map map = new Map(); + map[0] = "a"; + map[1] = "b"; + Expect.mapEquals(list.asMap(), map); + } + + test(Uri.parse("a/b").pathSegments); + test(new Uri(pathSegments: ["a", "b"]).pathSegments); +} + +main() { + testInvalidArguments(); + testPath(); + testPathSegments(); + testPathCompare(); + testPathSegmentsUnmodifiableList(); +} diff --git a/tests/corelib/uri_query_test.dart b/tests/corelib/uri_query_test.dart new file mode 100644 index 00000000000..e015cb3245b --- /dev/null +++ b/tests/corelib/uri_query_test.dart @@ -0,0 +1,182 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +void testInvalidArguments() {} + +void testEncodeQueryComponent() { + // This exact data is from posting a form in Chrome 26 with the one + // exception that * is encoded as %30 and ~ is not encoded as %7E. + Expect.equals( + "%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F%" + "3A%3B%3C%3D%3E%3F%40%5B%5C%5D%5E_%60%7B%7C%7D~", + Uri.encodeQueryComponent("!\"#\$%&'()*+,-./:;<=>?@[\\]^_`{|}~")); + Expect.equals("+%2B+", Uri.encodeQueryComponent(" + ")); + Expect.equals("%2B+%2B", Uri.encodeQueryComponent("+ +")); +} + +void testQueryParameters() { + test(String query, Map parameters, [String normalizedQuery]) { + if (normalizedQuery == null) normalizedQuery = query; + check(uri) { + Expect.isTrue(uri.hasQuery); + Expect.equals(normalizedQuery, uri.query); + Expect.equals("?$normalizedQuery", uri.toString()); + if (parameters.containsValue(null)) { + var map = new Map.from(parameters); + map.forEach((k, v) { + if (v == null) map[k] = ""; + }); + Expect.mapEquals(map, uri.queryParameters); + } else { + Expect.mapEquals(parameters, uri.queryParameters); + } + } + + var uri1 = new Uri(queryParameters: parameters); + var uri2 = new Uri(query: query); + var uri3 = Uri.parse("?$query"); + check(uri1); + if (query != "") { + check(uri2); + } else { + Expect.isFalse(uri2.hasQuery); + } + check(uri3); + Expect.equals(uri1, uri3); + if (query != "") Expect.equals(uri2, uri3); + if (parameters.containsValue(null)) { + var map = new Map.from(parameters); + map.forEach((k, v) { + if (v == null) map[k] = ""; + }); + Expect.mapEquals(map, Uri.splitQueryString(query)); + } else { + Expect.mapEquals(parameters, Uri.splitQueryString(query)); + } + } + + test("", {}); + test("A", {"A": null}); + test("%25", {"%": null}); + test("%41", {"A": null}, "A"); + test("%41A", {"AA": null}, "AA"); + test("A", {"A": ""}); + test("%25", {"%": ""}); + test("%41", {"A": ""}, "A"); + test("%41A", {"AA": ""}, "AA"); + test("A=a", {"A": "a"}); + test("%25=a", {"%": "a"}); + test("%41=%61", {"A": "a"}, "A=a"); + test("A=+", {"A": " "}); + test("A=%2B", {"A": "+"}); + test("A=a&B", {"A": "a", "B": null}); + test("A=a&B", {"A": "a", "B": ""}); + test("A=a&B=b", {"A": "a", "B": "b"}); + test("%41=%61&%42=%62", {"A": "a", "B": "b"}, "A=a&B=b"); + + var unreserved = "-._~0123456789" + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz"; + var encoded = new StringBuffer(); + var allEncoded = new StringBuffer(); + var unencoded = new StringBuffer(); + for (int i = 32; i < 128; i++) { + if (i == 32) { + encoded.write("+"); + } else if (unreserved.indexOf(new String.fromCharCode(i)) != -1) { + encoded.writeCharCode(i); + } else { + encoded.write("%"); + encoded.write(i.toRadixString(16).toUpperCase()); + } + if (i == 32) { + allEncoded.write("+"); + } else { + allEncoded.write("%"); + allEncoded.write(i.toRadixString(16).toUpperCase()); + } + unencoded.writeCharCode(i); + } + encoded = encoded.toString(); + unencoded = unencoded.toString(); + test("a=$encoded", {"a": unencoded}); + test("a=$encoded&b=$encoded", {"a": unencoded, "b": unencoded}); + + var map = new Map(); + map[unencoded] = unencoded; + test("$encoded=$encoded", map); + test("$encoded=$allEncoded", map, "$encoded=$encoded"); + test("$allEncoded=$encoded", map, "$encoded=$encoded"); + test("$allEncoded=$allEncoded", map, "$encoded=$encoded"); + map[unencoded] = null; + test("$encoded", map); + map[unencoded] = ""; + test("$encoded", map); +} + +testInvalidQueryParameters() { + test(String query, Map parameters) { + check(uri) { + Expect.equals(query, uri.query); + if (query.isEmpty) { + Expect.equals(query, uri.toString()); + } else { + Expect.equals("?$query", uri.toString()); + } + if (parameters.containsValue(null)) {} else { + Expect.mapEquals(parameters, uri.queryParameters); + } + } + + var uri1 = new Uri(query: query); + var uri2 = Uri.parse("?$query"); + check(uri1); + check(uri2); + Expect.equals(uri1, uri2); + } + + test("=", {}); + test("=xxx", {}); + test("===", {}); + test("=xxx=yyy=zzz", {}); + test("=&=&=", {}); + test("=xxx&=yyy&=zzz", {}); + test("&=&=&", {}); + test("&=xxx&=xxx&", {}); +} + +testQueryParametersImmutableMap() { + test(map) { + bool isUnsupported(e) => e is UnsupportedError; + + Expect.isTrue(map.containsValue("b")); + Expect.isTrue(map.containsKey("a")); + Expect.equals("b", map["a"]); + Expect.throws(() => map["a"] = "c", isUnsupported); + Expect.throws(() => map.putIfAbsent("b", () => "e"), isUnsupported); + Expect.throws(() => map.remove("a"), isUnsupported); + Expect.throws(() => map.clear(), isUnsupported); + var count = 0; + map.forEach((key, value) => count++); + Expect.equals(2, count); + Expect.equals(2, map.keys.length); + Expect.equals(2, map.values.length); + Expect.equals(2, map.length); + Expect.isFalse(map.isEmpty); + Expect.isTrue(map.isNotEmpty); + } + + test(Uri.parse("?a=b&c=d").queryParameters); + test(new Uri(queryParameters: {"a": "b", "c": "d"}).queryParameters); +} + +main() { + testInvalidArguments(); + testEncodeQueryComponent(); + testQueryParameters(); + testInvalidQueryParameters(); + testQueryParametersImmutableMap(); +} diff --git a/tests/corelib/uri_scheme_test.dart b/tests/corelib/uri_scheme_test.dart new file mode 100644 index 00000000000..1868ca62957 --- /dev/null +++ b/tests/corelib/uri_scheme_test.dart @@ -0,0 +1,37 @@ +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import "package:expect/expect.dart"; + +void testInvalidArguments() { + Expect.throws(() => new Uri(scheme: "_"), (e) => e is FormatException); + Expect.throws(() => new Uri(scheme: "http_s"), (e) => e is FormatException); + Expect.throws( + () => new Uri(scheme: "127.0.0.1:80"), (e) => e is FormatException); +} + +void testScheme() { + test(String expectedScheme, String expectedUri, String scheme) { + var uri = new Uri(scheme: scheme); + Expect.equals(expectedScheme, uri.scheme); + Expect.equals(expectedUri, uri.toString()); + uri = Uri.parse("$scheme:"); + Expect.equals(expectedScheme, uri.scheme); + Expect.equals(expectedUri, uri.toString()); + } + + test("http", "http:", "http"); + test("http", "http:", "HTTP"); + test("http", "http:", "hTTP"); + test("http", "http:", "Http"); + test("http+ssl", "http+ssl:", "HTTP+ssl"); + test("urn", "urn:", "urn"); + test("urn", "urn:", "UrN"); + test("a123.432", "a123.432:", "a123.432"); +} + +main() { + testInvalidArguments(); + testScheme(); +} diff --git a/tests/corelib/uri_test.dart b/tests/corelib/uri_test.dart new file mode 100644 index 00000000000..158037a5a9a --- /dev/null +++ b/tests/corelib/uri_test.dart @@ -0,0 +1,975 @@ +// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +library uriTest; + +import "package:expect/expect.dart"; +import 'dart:convert'; + +testUri(String uriText, bool isAbsolute) { + var uri = Uri.parse(uriText); + + // Test that parsing a substring works the same as parsing the string. + String wrapper = "://@[]:/%?#"; + var embeddedUri = Uri.parse( + "$wrapper$uri$wrapper", wrapper.length, uriText.length + wrapper.length); + + Expect.equals(uri, embeddedUri); + Expect.equals(isAbsolute, uri.isAbsolute); + Expect.stringEquals(uriText, uri.toString()); + + // Test equals and hashCode members. + var uri2 = Uri.parse(uriText); + Expect.equals(uri, uri2); + Expect.equals(uri.hashCode, uri2.hashCode); + + // Test that removeFragment doesn't change anything else. + if (uri.hasFragment) { + Expect.equals(Uri.parse(uriText.substring(0, uriText.indexOf('#'))), + uri.removeFragment()); + } else { + Expect.equals(uri, Uri.parse(uriText + "#fragment").removeFragment()); + } + + Expect.isTrue(uri.isScheme(uri.scheme)); + Expect.isTrue(uri.isScheme(uri.scheme.toLowerCase())); + Expect.isTrue(uri.isScheme(uri.scheme.toUpperCase())); + if (uri.hasScheme) { + // Capitalize + Expect.isTrue( + uri.isScheme(uri.scheme[0].toUpperCase() + uri.scheme.substring(1))); + Expect + .isFalse(uri.isScheme(uri.scheme.substring(0, uri.scheme.length - 1))); + Expect.isFalse(uri.isScheme(uri.scheme + ":")); + Expect.isFalse(uri.isScheme(uri.scheme + "\x00")); + } else { + Expect.isTrue(uri.isScheme(null)); + Expect.isFalse(uri.isScheme(":")); + } +} + +testEncodeDecode(String orig, String encoded) { + var e = Uri.encodeFull(orig); + Expect.stringEquals(encoded, e); + var d = Uri.decodeFull(encoded); + Expect.stringEquals(orig, d); +} + +testEncodeDecodeComponent(String orig, String encoded) { + var e = Uri.encodeComponent(orig); + Expect.stringEquals(encoded, e); + var d = Uri.decodeComponent(encoded); + Expect.stringEquals(orig, d); +} + +testEncodeDecodeQueryComponent(String orig, String encodedUTF8, + String encodedLatin1, String encodedAscii) { + var e, d; + e = Uri.encodeQueryComponent(orig); + Expect.stringEquals(encodedUTF8, e); + d = Uri.decodeQueryComponent(encodedUTF8); + Expect.stringEquals(orig, d); + + e = Uri.encodeQueryComponent(orig, encoding: UTF8); + Expect.stringEquals(encodedUTF8, e); + d = Uri.decodeQueryComponent(encodedUTF8, encoding: UTF8); + Expect.stringEquals(orig, d); + + e = Uri.encodeQueryComponent(orig, encoding: LATIN1); + Expect.stringEquals(encodedLatin1, e); + d = Uri.decodeQueryComponent(encodedLatin1, encoding: LATIN1); + Expect.stringEquals(orig, d); + + if (encodedAscii != null) { + e = Uri.encodeQueryComponent(orig, encoding: ASCII); + Expect.stringEquals(encodedAscii, e); + d = Uri.decodeQueryComponent(encodedAscii, encoding: ASCII); + Expect.stringEquals(orig, d); + } else { + Expect.throws(() => Uri.encodeQueryComponent(orig, encoding: ASCII), + (e) => e is ArgumentError); + } +} + +testUriPerRFCs() { + // Convert a Uri to a guaranteed "non simple" URI with the same content. + toComplex(Uri uri) { + Uri complex = new Uri( + scheme: uri.scheme, + userInfo: uri.hasAuthority ? uri.userInfo : null, + host: uri.hasAuthority ? uri.host : null, + port: uri.hasAuthority ? uri.port : null, + path: uri.path, + query: uri.hasQuery ? uri.query : null, + fragment: uri.hasFragment ? uri.fragment : null, + ); + assert(complex.toString() == uri.toString()); + return complex; + } + + Uri base; + Uri complexBase; + // Sets the [base] and [complexBase] to the parse of the URI and a + // guaranteed non-simple version of the same URI. + setBase(String uri) { + base = Uri.parse(uri); + complexBase = toComplex(base); + } + + testResolve(expect, relative) { + String name = "$base << $relative"; + Expect.stringEquals(expect, base.resolve(relative).toString(), name); + + Expect.stringEquals(expect, complexBase.resolve(relative).toString(), + name + " (complex base)"); + } + + // From RFC 3986. + final urisSample = "http://a/b/c/d;p?q"; + setBase(urisSample); + + testResolve("g:h", "g:h"); + testResolve("http://a/b/c/g", "g"); + testResolve("http://a/b/c/g", "./g"); + testResolve("http://a/b/c/g/", "g/"); + testResolve("http://a/g", "/g"); + testResolve("http://g", "//g"); + testResolve("http://a/b/c/d;p?y", "?y"); + testResolve("http://a/b/c/g?y", "g?y"); + testResolve("http://a/b/c/d;p?q#s", "#s"); + testResolve("http://a/b/c/g#s", "g#s"); + testResolve("http://a/b/c/g?y#s", "g?y#s"); + testResolve("http://a/b/c/;x", ";x"); + testResolve("http://a/b/c/g;x", "g;x"); + testResolve("http://a/b/c/g;x?y#s", "g;x?y#s"); + testResolve("http://a/b/c/d;p?q", ""); + testResolve("http://a/b/c/", "."); + testResolve("http://a/b/c/", "./"); + testResolve("http://a/b/", ".."); + testResolve("http://a/b/", "../"); + testResolve("http://a/b/g", "../g"); + testResolve("http://a/", "../.."); + testResolve("http://a/", "../../"); + testResolve("http://a/g", "../../g"); + testResolve("http://a/g", "../../../g"); + testResolve("http://a/g", "../../../../g"); + testResolve("http://a/g", "/./g"); + testResolve("http://a/g", "/../g"); + testResolve("http://a/b/c/g.", "g."); + testResolve("http://a/b/c/.g", ".g"); + testResolve("http://a/b/c/g..", "g.."); + testResolve("http://a/b/c/..g", "..g"); + testResolve("http://a/b/g", "./../g"); + testResolve("http://a/b/c/g/", "./g/."); + testResolve("http://a/b/c/g/h", "g/./h"); + testResolve("http://a/b/c/h", "g/../h"); + testResolve("http://a/b/c/g;x=1/y", "g;x=1/./y"); + testResolve("http://a/b/c/y", "g;x=1/../y"); + testResolve("http://a/b/c/g?y/./x", "g?y/./x"); + testResolve("http://a/b/c/g?y/../x", "g?y/../x"); + testResolve("http://a/b/c/g#s/./x", "g#s/./x"); + testResolve("http://a/b/c/g#s/../x", "g#s/../x"); + testResolve("http:g", "http:g"); + + // Additional tests (not from RFC 3986). + testResolve("http://a/b/g;p/h;s", "../g;p/h;s"); + + setBase("s:a/b"); + testResolve("s:a/c", "c"); + testResolve("s:/c", "../c"); + + setBase("S:a/b"); + testResolve("s:a/c", "c"); + testResolve("s:/c", "../c"); + + setBase("s:foo"); + testResolve("s:bar", "bar"); + testResolve("s:bar", "../bar"); + + setBase("S:foo"); + testResolve("s:bar", "bar"); + testResolve("s:bar", "../bar"); + + // Special-case (deliberate non-RFC behavior). + setBase("foo/bar"); + testResolve("foo/baz", "baz"); + testResolve("baz", "../baz"); + + setBase("s:/foo"); + testResolve("s:/bar", "bar"); + testResolve("s:/bar", "../bar"); + + setBase("S:/foo"); + testResolve("s:/bar", "bar"); + testResolve("s:/bar", "../bar"); + + // Test non-URI base (no scheme, no authority, relative path). + setBase("a/b/c?_#_"); + testResolve("a/b/g?q#f", "g?q#f"); + testResolve("./", "../.."); + testResolve("../", "../../.."); + testResolve("a/b/", "."); + testResolve("c", "../../c"); // Deliberate non-RFC behavior. + setBase("../../a/b/c?_#_"); // Initial ".." in base url. + testResolve("../../a/d", "../d"); + testResolve("../../d", "../../d"); + testResolve("../../../d", "../../../d"); + setBase("../../a/b"); + testResolve("../../a/d", "d"); + testResolve("../../d", "../d"); + testResolve("../../../d", "../../d"); + setBase("../../a"); + testResolve("../../d", "d"); + testResolve("../../../d", "../d"); + testResolve("../../../../d", "../../d"); + + // Absolute path, not scheme or authority. + setBase("/a"); + testResolve("/b", "b"); + testResolve("/b", "../b"); + testResolve("/b", "../../b"); + setBase("/a/b"); + testResolve("/a/c", "c"); + testResolve("/c", "../c"); + testResolve("/c", "../../c"); + + setBase("s://h/p?q#f"); // A simple base. + // Simple references: + testResolve("s2://h2/P?Q#F", "s2://h2/P?Q#F"); + testResolve("s://h2/P?Q#F", "//h2/P?Q#F"); + testResolve("s://h/P?Q#F", "/P?Q#F"); + testResolve("s://h/p?Q#F", "?Q#F"); + testResolve("s://h/p?q#F", "#F"); + testResolve("s://h/p?q", ""); + // Non-simple references: + testResolve("s2://I@h2/P?Q#F%20", "s2://I@h2/P?Q#F%20"); + testResolve("s://I@h2/P?Q#F%20", "//I@h2/P?Q#F%20"); + testResolve("s://h2/P?Q#F%20", "//h2/P?Q#F%20"); + testResolve("s://h/P?Q#F%20", "/P?Q#F%20"); + testResolve("s://h/p?Q#F%20", "?Q#F%20"); + testResolve("s://h/p?q#F%20", "#F%20"); + + setBase("s://h/p1/p2/p3"); // A simple base with a path. + testResolve("s://h/p1/p2/", "."); + testResolve("s://h/p1/p2/", "./"); + testResolve("s://h/p1/", ".."); + testResolve("s://h/p1/", "../"); + testResolve("s://h/", "../.."); + testResolve("s://h/", "../../"); + testResolve("s://h/p1/%20", "../%20"); + testResolve("s://h/", "../../../.."); + testResolve("s://h/", "../../../../"); + + setBase("s://h/p?q#f%20"); // A non-simpe base. + // Simple references: + testResolve("s2://h2/P?Q#F", "s2://h2/P?Q#F"); + testResolve("s://h2/P?Q#F", "//h2/P?Q#F"); + testResolve("s://h/P?Q#F", "/P?Q#F"); + testResolve("s://h/p?Q#F", "?Q#F"); + testResolve("s://h/p?q#F", "#F"); + testResolve("s://h/p?q", ""); + // Non-simple references: + testResolve("s2://I@h2/P?Q#F%20", "s2://I@h2/P?Q#F%20"); + testResolve("s://I@h2/P?Q#F%20", "//I@h2/P?Q#F%20"); + testResolve("s://h2/P?Q#F%20", "//h2/P?Q#F%20"); + testResolve("s://h/P?Q#F%20", "/P?Q#F%20"); + testResolve("s://h/p?Q#F%20", "?Q#F%20"); + testResolve("s://h/p?q#F%20", "#F%20"); + + setBase("S://h/p1/p2/p3"); // A non-simple base with a path. + testResolve("s://h/p1/p2/", "."); + testResolve("s://h/p1/p2/", "./"); + testResolve("s://h/p1/", ".."); + testResolve("s://h/p1/", "../"); + testResolve("s://h/", "../.."); + testResolve("s://h/", "../../"); + testResolve("s://h/p1/%20", "../%20"); + testResolve("s://h/", "../../../.."); + testResolve("s://h/", "../../../../"); + + setBase("../../../"); // A simple relative path. + testResolve("../../../a", "a"); + testResolve("../../../../a", "../a"); + testResolve("../../../a%20", "a%20"); + testResolve("../../../../a%20", "../a%20"); + + // Tests covering the branches of the merge algorithm in RFC 3986 + // with both simple and complex base URIs. + for (var b in ["s://a/pa/pb?q#f", "s://a/pa/pb?q#f%20"]) { + setBase(b); + + // if defined(R.scheme) then ... + testResolve("s2://a2/p2?q2#f2", "s2://a2/p2?q2#f2"); + // else, if defined(R.authority) then ... + testResolve("s://a2/p2?q2#f2", "//a2/p2?q2#f2"); + testResolve("s://a2/?q2#f2", "//a2/../?q2#f2"); + testResolve("s://a2?q2#f2", "//a2?q2#f2"); + testResolve("s://a2#f2", "//a2#f2"); + testResolve("s://a2", "//a2"); + // else, if (R.path == "") then ... + // if defined(R.query) then + testResolve("s://a/pa/pb?q2#f2", "?q2#f2"); + testResolve("s://a/pa/pb?q2", "?q2"); + // else + testResolve("s://a/pa/pb?q#f2", "#f2"); + testResolve("s://a/pa/pb?q", ""); + // else, if (R.path starts-with "/") then ... + testResolve("s://a/p2?q2#f2", "/p2?q2#f2"); + testResolve("s://a/?q2#f2", "/?q2#f2"); + testResolve("s://a/#f2", "/#f2"); + testResolve("s://a/", "/"); + testResolve("s://a/", "/../"); + // else ... T.path = merge(Base.path, R.path) + // ... remove-dot-fragments(T.path) ... + // (Cover the merge function and the remove-dot-fragments functions too). + + // If base has authority and empty path ... + var emptyPathBase = b.replaceFirst("/pa/pb", ""); + setBase(emptyPathBase); + testResolve("s://a/p2?q2#f2", "p2?q2#f2"); + testResolve("s://a/p2#f2", "p2#f2"); + testResolve("s://a/p2", "p2"); + + setBase(b); + // otherwise + // (Cover both no authority and non-empty path and both). + var noAuthEmptyPathBase = b.replaceFirst("//a/pa/pb", ""); + var noAuthAbsPathBase = b.replaceFirst("//a", ""); + var noAuthRelPathBase = b.replaceFirst("//a/", ""); + var noAuthRelSinglePathBase = b.replaceFirst("//a/pa/", ""); + + testResolve("s://a/pa/p2?q2#f2", "p2?q2#f2"); + testResolve("s://a/pa/p2#f2", "p2#f2"); + testResolve("s://a/pa/p2", "p2"); + + setBase(noAuthEmptyPathBase); + testResolve("s:p2?q2#f2", "p2?q2#f2"); + testResolve("s:p2#f2", "p2#f2"); + testResolve("s:p2", "p2"); + + setBase(noAuthAbsPathBase); + testResolve("s:/pa/p2?q2#f2", "p2?q2#f2"); + testResolve("s:/pa/p2#f2", "p2#f2"); + testResolve("s:/pa/p2", "p2"); + + setBase(noAuthRelPathBase); + testResolve("s:pa/p2?q2#f2", "p2?q2#f2"); + testResolve("s:pa/p2#f2", "p2#f2"); + testResolve("s:pa/p2", "p2"); + + setBase(noAuthRelSinglePathBase); + testResolve("s:p2?q2#f2", "p2?q2#f2"); + testResolve("s:p2#f2", "p2#f2"); + testResolve("s:p2", "p2"); + + // Then remove dot segments. + + // A. if input buffer starts with "../" or "./". + // This only happens if base has only a single (may be empty) segment and + // no slash. + setBase(emptyPathBase); + testResolve("s://a/p2", "../p2"); + testResolve("s://a/", "../"); + testResolve("s://a/", ".."); + testResolve("s://a/p2", "./p2"); + testResolve("s://a/", "./"); + testResolve("s://a/", "."); + testResolve("s://a/p2", "../../p2"); + testResolve("s://a/p2", "../../././p2"); + + setBase(noAuthRelSinglePathBase); + testResolve("s:p2", "../p2"); + testResolve("s:", "../"); + testResolve("s:", ".."); + testResolve("s:p2", "./p2"); + testResolve("s:", "./"); + testResolve("s:", "."); + testResolve("s:p2", "../../p2"); + testResolve("s:p2", "../../././p2"); + + // B. if input buffer starts with "/./" or is "/.". replace with "/". + // (The URI implementation removes the "." path segments when parsing, + // so this case isn't handled by merge). + setBase(b); + testResolve("s://a/pa/p2", "./p2"); + + // C. if input buffer starts with "/../" or is "/..", replace with "/" + // and remove preceeding segment. + testResolve("s://a/p2", "../p2"); + var longPathBase = b.replaceFirst("/pb", "/pb/pc/pd"); + setBase(longPathBase); + testResolve("s://a/pa/pb/p2", "../p2"); + testResolve("s://a/pa/p2", "../../p2"); + testResolve("s://a/p2", "../../../p2"); + testResolve("s://a/p2", "../../../../p2"); + var noAuthRelLongPathBase = b.replaceFirst("//a/pa/pb", "pa/pb/pc/pd"); + setBase(noAuthRelLongPathBase); + testResolve("s:pa/pb/p2", "../p2"); + testResolve("s:pa/p2", "../../p2"); + testResolve("s:/p2", "../../../p2"); + testResolve("s:/p2", "../../../../p2"); + + // D. if the input buffer contains only ".." or ".", remove it. + setBase(noAuthEmptyPathBase); + testResolve("s:", ".."); + testResolve("s:", "."); + setBase(noAuthRelSinglePathBase); + testResolve("s:", ".."); + testResolve("s:", "."); + } +} + +void testResolvePath(String expected, String path) { + Expect.equals( + expected, new Uri(path: '/').resolveUri(new Uri(path: path)).path); + Expect.equals("http://localhost$expected", + Uri.parse("http://localhost").resolveUri(new Uri(path: path)).toString()); +} + +const ALPHA = r"abcdefghijklmnopqrstuvwxuzABCDEFGHIJKLMNOPQRSTUVWXUZ"; +const DIGIT = r"0123456789"; +const PERCENT_ENCODED = "%00%ff"; +const SUBDELIM = r"!$&'()*+,;="; + +const SCHEMECHAR = "$ALPHA$DIGIT+-."; +const UNRESERVED = "$ALPHA$DIGIT-._~"; +const REGNAMECHAR = "$UNRESERVED$SUBDELIM$PERCENT_ENCODED"; +const USERINFOCHAR = "$REGNAMECHAR:"; + +const PCHAR_NC = "$UNRESERVED$SUBDELIM$PERCENT_ENCODED@"; +const PCHAR = "$PCHAR_NC:"; +const QUERYCHAR = "$PCHAR/?"; + +void testValidCharacters() { + // test that all valid characters are accepted. + + for (var scheme in ["", "$SCHEMECHAR$SCHEMECHAR:"]) { + for (var userinfo in [ + "", + "@", + "$USERINFOCHAR$USERINFOCHAR@", + "$USERINFOCHAR:$DIGIT@" + ]) { + for (var host in [ + "", "$REGNAMECHAR$REGNAMECHAR", + "255.255.255.256", // valid reg-name. + "[ffff::ffff:ffff]", "[ffff::255.255.255.255]" + ]) { + for (var port in ["", ":", ":$DIGIT$DIGIT"]) { + var auth = "$userinfo$host$port"; + if (auth.isNotEmpty) auth = "//$auth"; + var paths = ["", "/", "/$PCHAR", "/$PCHAR/"]; // Absolute or empty. + if (auth.isNotEmpty) { + // Initial segment may be empty. + paths..add("//$PCHAR"); + } else { + // Path may begin with non-slash. + if (scheme.isEmpty) { + // Initial segment must not contain colon. + paths + ..add(PCHAR_NC) + ..add("$PCHAR_NC/$PCHAR") + ..add("$PCHAR_NC/$PCHAR/"); + } else { + paths..add(PCHAR)..add("$PCHAR/$PCHAR")..add("$PCHAR/$PCHAR/"); + } + } + for (var path in paths) { + for (var query in ["", "?", "?$QUERYCHAR"]) { + for (var fragment in ["", "#", "#$QUERYCHAR"]) { + var uri = "$scheme$auth$path$query$fragment"; + // Should not throw. + var result = Uri.parse(uri); + } + } + } + } + } + } + } +} + +void testInvalidUrls() { + void checkInvalid(uri) { + try { + var result = Uri.parse(uri); + Expect.fail("Invalid URI `$uri` parsed to $result\n" + dump(result)); + } on FormatException { + // Success. + } + } + + checkInvalid("s%41://x.x/"); // No escapes in scheme, + // and no colon before slash in path. + checkInvalid("1a://x.x/"); // Scheme must start with letter, + // and no colon before slash in path. + checkInvalid(".a://x.x/"); // Scheme must start with letter, + // and no colon before slash in path. + checkInvalid("_:"); // Character not valid in scheme, + // and no colon before slash in path. + checkInvalid(":"); // Scheme must start with letter, + // and no colon before slash in path. + + void checkInvalidReplaced(uri, invalid, replacement) { + var source = uri.replaceAll('{}', invalid); + var expected = uri.replaceAll('{}', replacement); + var result = Uri.parse(source); + Expect.equals(expected, "$result", "Source: $source\n${dump(result)}"); + } + + // Regression test for http://dartbug.com/16081 + checkInvalidReplaced( + "http://www.example.org/red%09ros{}#red)", "\u00e9", "%C3%A9"); + checkInvalidReplaced("http://r{}sum\{}.example.org", "\u00E9", "%C3%A9"); + + // Invalid characters. The characters must be rejected, even if normalizing + // the input would cause them to be valid (normalization happens after + // validation). + var invalidCharsAndReplacements = [ + "\xe7", "%C3%A7", // Arbitrary non-ASCII letter + " ", "%20", // Space, not allowed anywhere. + '"', "%22", // Quote, not allowed anywhere + "<>", "%3C%3E", // Less/greater-than, not allowed anywhere. + "\x7f", "%7F", // DEL, not allowed anywhere + "\xdf", "%C3%9F", // German lower-case scharf-S. + // Becomes ASCII when upper-cased. + "\u0130", "%C4%B0", // Latin capital dotted I, + // becomes ASCII lower-case in Turkish. + "%\uFB03", "%25%EF%AC%83", // % + Ligature ffi, + // becomes ASCII when upper-cased, + // should not be read as "%FFI". + "\u212a", "%E2%84%AA", // Kelvin sign. Becomes ASCII when lower-cased. + "%1g", "%251g", // Invalid escape. + "\u{10000}", "%F0%90%80%80", // Non-BMP character as surrogate pair. + ]; + for (int i = 0; i < invalidCharsAndReplacements.length; i += 2) { + var invalid = invalidCharsAndReplacements[i]; + var valid = invalidCharsAndReplacements[i + 1]; + checkInvalid("A{}b:///".replaceAll('{}', invalid)); + checkInvalid("{}b:///".replaceAll('{}', invalid)); + checkInvalidReplaced("s://user{}info@x.x/", invalid, valid); + checkInvalidReplaced("s://reg{}name/", invalid, valid); + checkInvalid("s://regname:12{}45/".replaceAll("{}", invalid)); + checkInvalidReplaced("s://regname/p{}ath/", invalid, valid); + checkInvalidReplaced("/p{}ath/", invalid, valid); + checkInvalidReplaced("p{}ath/", invalid, valid); + checkInvalidReplaced("s://regname/path/?x{}x", invalid, valid); + checkInvalidReplaced("s://regname/path/#x{}x", invalid, valid); + checkInvalidReplaced("s://regname/path/??#x{}x", invalid, valid); + } + + // At most one @ in userinfo. + checkInvalid("s://x@x@x.x/"); + // No colon in host except before a port. + checkInvalid("s://x@x:x/"); + // At most one port. + checkInvalid("s://x@x:9:9/"); + // At most one #. + checkInvalid("s://x/x#foo#bar"); + // @ not allowed in scheme. + checkInvalid("s@://x:9/x?x#x"); + // ] not allowed alone in host. + checkInvalid("s://xx]/"); + // ] not allowed anywhere except in host. + checkInvalid("s://xx/]"); + checkInvalid("s://xx/?]"); + checkInvalid("s://xx/#]"); + checkInvalid("s:/]"); + checkInvalid("s:/?]"); + checkInvalid("s:/#]"); + // IPv6 must be enclosed in [ and ] for Uri.parse. + // It is allowed un-enclosed as argument to `Uri(host:...)` because we don't + // need to delimit. + checkInvalid("s://ffff::ffff:1234/"); +} + +void testNormalization() { + // The Uri constructor and the Uri.parse function performs RFC-3986 + // syntax based normalization. + + var uri; + + // Scheme: Only case normalization. Schemes cannot contain escapes. + uri = Uri.parse("A:"); + Expect.equals("a", uri.scheme); + uri = Uri.parse("Z:"); + Expect.equals("z", uri.scheme); + uri = Uri.parse("$SCHEMECHAR:"); + Expect.equals(SCHEMECHAR.toLowerCase(), uri.scheme); + + // Percent escape normalization. + // Escapes of unreserved characters are converted to the character, + // subject to case normalization in reg-name. + for (var i = 0; i < UNRESERVED.length; i++) { + var char = UNRESERVED[i]; + var escape = "%" + char.codeUnitAt(0).toRadixString(16); // all > 0xf. + + uri = Uri.parse("s://xX${escape}xX@yY${escape}yY/zZ${escape}zZ" + "?vV${escape}vV#wW${escape}wW"); + Expect.equals("xX${char}xX", uri.userInfo); + Expect.equals("yY${char}yY".toLowerCase(), uri.host); + Expect.equals("/zZ${char}zZ", uri.path); + Expect.equals("vV${char}vV", uri.query); + Expect.equals("wW${char}wW", uri.fragment); + + uri = Uri.parse("s://yY${escape}yY/zZ${escape}zZ" + "?vV${escape}vV#wW${escape}wW"); + Expect.equals("yY${char}yY".toLowerCase(), uri.host); + Expect.equals("/zZ${char}zZ", uri.path); + Expect.equals("vV${char}vV", uri.query); + Expect.equals("wW${char}wW", uri.fragment); + } + + // Escapes of reserved characters are kept, but upper-cased. + for (var escape in ["%00", "%1f", "%7F", "%fF"]) { + uri = Uri.parse("s://xX${escape}xX@yY${escape}yY/zZ${escape}zZ" + "?vV${escape}vV#wW${escape}wW"); + var normalizedEscape = escape.toUpperCase(); + Expect.equals("xX${normalizedEscape}xX", uri.userInfo); + Expect.equals("yy${normalizedEscape}yy", uri.host); + Expect.equals("/zZ${normalizedEscape}zZ", uri.path); + Expect.equals("vV${normalizedEscape}vV", uri.query); + Expect.equals("wW${normalizedEscape}wW", uri.fragment); + } + + // Some host normalization edge cases. + uri = Uri.parse("x://x%61X%41x%41X%61x/"); + Expect.equals("xaxaxaxax", uri.host); + + uri = Uri.parse("x://Xxxxxxxx/"); + Expect.equals("xxxxxxxx", uri.host); + + uri = Uri.parse("x://xxxxxxxX/"); + Expect.equals("xxxxxxxx", uri.host); + + uri = Uri.parse("x://xxxxxxxx%61/"); + Expect.equals("xxxxxxxxa", uri.host); + + uri = Uri.parse("x://%61xxxxxxxx/"); + Expect.equals("axxxxxxxx", uri.host); + + uri = Uri.parse("x://X/"); + Expect.equals("x", uri.host); + + uri = Uri.parse("x://%61/"); + Expect.equals("a", uri.host); + + uri = new Uri(scheme: "x", path: "//y"); + Expect.equals("//y", uri.path); + Expect.equals("x:////y", uri.toString()); + + uri = new Uri(scheme: "file", path: "//y"); + Expect.equals("//y", uri.path); + Expect.equals("file:////y", uri.toString()); + + // File scheme noralizes to always showing authority, even if empty. + uri = new Uri(scheme: "file", path: "/y"); + Expect.equals("file:///y", uri.toString()); + uri = new Uri(scheme: "file", path: "y"); + Expect.equals("file:///y", uri.toString()); + + // Empty host/query/fragment ensures the delimiter is there. + // Different from not being there. + Expect.equals("scheme:/", Uri.parse("scheme:/").toString()); + Expect.equals("scheme:/", new Uri(scheme: "scheme", path: "/").toString()); + + Expect.equals("scheme:///?#", Uri.parse("scheme:///?#").toString()); + Expect.equals( + "scheme:///#", + new Uri(scheme: "scheme", host: "", path: "/", query: "", fragment: "") + .toString()); +} + +void testReplace() { + var uris = [ + Uri.parse(""), + Uri.parse("a://@:/?#"), + Uri.parse("a://:/?#"), // Parsed as simple URI. + Uri.parse("a://b@c:4/e/f?g#h"), + Uri.parse("a://c:4/e/f?g#h"), // Parsed as simple URI. + Uri.parse("$SCHEMECHAR://$REGNAMECHAR:$DIGIT/$PCHAR/$PCHAR" + "?$QUERYCHAR#$QUERYCHAR"), // Parsed as simple URI. + Uri.parse("$SCHEMECHAR://$USERINFOCHAR@$REGNAMECHAR:$DIGIT/$PCHAR/$PCHAR" + "?$QUERYCHAR#$QUERYCHAR"), + ]; + for (var uri1 in uris) { + for (var uri2 in uris) { + if (identical(uri1, uri2)) continue; + var scheme = uri1.scheme; + var userInfo = uri1.hasAuthority ? uri1.userInfo : ""; + var host = uri1.hasAuthority ? uri1.host : null; + var port = uri1.hasAuthority ? uri1.port : 0; + var path = uri1.path; + var query = uri1.hasQuery ? uri1.query : null; + var fragment = uri1.hasFragment ? uri1.fragment : null; + + var tmp1 = uri1; + + void test() { + var tmp2 = new Uri( + scheme: scheme, + userInfo: userInfo, + host: host, + port: port, + path: path, + query: query == "" ? null : query, + queryParameters: query == "" ? {} : null, + fragment: fragment); + Expect.equals(tmp1, tmp2); + } + + test(); + + scheme = uri2.scheme; + tmp1 = tmp1.replace(scheme: scheme); + test(); + + if (uri2.hasAuthority) { + userInfo = uri2.userInfo; + host = uri2.host; + port = uri2.port; + tmp1 = tmp1.replace(userInfo: userInfo, host: host, port: port); + test(); + } + + path = uri2.path; + tmp1 = tmp1.replace(path: path); + test(); + + if (uri2.hasQuery) { + query = uri2.query; + tmp1 = tmp1.replace(query: query); + test(); + } + + if (uri2.hasFragment) { + fragment = uri2.fragment; + tmp1 = tmp1.replace(fragment: fragment); + test(); + } + } + } + + // Regression test, http://dartbug.com/20814 + var uri = Uri.parse("/no-authorty/"); + uri = uri.replace(fragment: "fragment"); + Expect.isFalse(uri.hasAuthority); + + uri = new Uri(scheme: "foo", path: "bar"); + uri = uri.replace(queryParameters: { + "x": ["42", "37"], + "y": ["43", "38"] + }); + var params = uri.queryParametersAll; + Expect.equals(2, params.length); + Expect.listEquals(["42", "37"], params["x"]); + Expect.listEquals(["43", "38"], params["y"]); + + // Test replacing with empty strings. + uri = Uri.parse("s://a:1/b/c?d#e"); + Expect.equals("s://a:1/b/c?d#", uri.replace(fragment: "").toString()); + Expect.equals("s://a:1/b/c?#e", uri.replace(query: "").toString()); + Expect.equals("s://a:1?d#e", uri.replace(path: "").toString()); + Expect.equals("s://:1/b/c?d#e", uri.replace(host: "").toString()); + + // Test uri.replace on uri with fragment + uri = Uri.parse('http://hello.com/fake#fragment'); + uri = uri.replace(path: "D/E/E"); + Expect.stringEquals('http://hello.com/D/E/E#fragment', uri.toString()); +} + +void testRegression28359() { + var uri = new Uri(path: "//"); + // This is an invalid path for a URI reference with no authority + // since it looks like an authority. + // Normalized to have an authority. + Expect.equals("////", "$uri"); + Expect.equals("//", uri.path); + Expect.isTrue(uri.hasAuthority, "$uri has authority"); + + uri = new Uri(path: "file:///wat"); + // This is an invalid path for a URI reference with no authority or scheme + // since the path looks like it starts with a scheme. + // Normalized by escaping the ":". + Expect.equals("file%3A///wat", uri.path); + Expect.equals("file%3A///wat", "$uri"); + Expect.isFalse(uri.hasAuthority); + Expect.isFalse(uri.hasScheme); +} + +main() { + testUri("http:", true); + testUri("file:///", true); + testUri("file", false); + testUri("http://user@example.com:8080/fisk?query=89&hest=silas", true); + testUri( + "http://user@example.com:8080/fisk?query=89&hest=silas#fragment", false); + Expect.stringEquals( + "http://user@example.com/a/b/c?query#fragment", + new Uri( + scheme: "http", + userInfo: "user", + host: "example.com", + port: 80, + path: "/a/b/c", + query: "query", + fragment: "fragment") + .toString()); + Expect.stringEquals( + "/a/b/c/", + new Uri( + scheme: null, + userInfo: null, + host: null, + port: 0, + path: "/a/b/c/", + query: null, + fragment: null) + .toString()); + Expect.stringEquals("file:///", Uri.parse("file:").toString()); + Expect.stringEquals("file:///", Uri.parse("file:/").toString()); + Expect.stringEquals("file:///", Uri.parse("file:").toString()); + Expect.stringEquals("file:///foo", Uri.parse("file:foo").toString()); + Expect.stringEquals("file:///foo", Uri.parse("file:/foo").toString()); + Expect.stringEquals("file://foo/", Uri.parse("file://foo").toString()); + + testResolvePath("/a/g", "/a/b/c/./../../g"); + testResolvePath("/a/g", "/a/b/c/./../../g"); + testResolvePath("/mid/6", "mid/content=5/../6"); + testResolvePath("/a/b/e", "a/b/c/d/../../e"); + testResolvePath("/a/b/e", "../a/b/c/d/../../e"); + testResolvePath("/a/b/e", "./a/b/c/d/../../e"); + testResolvePath("/a/b/e", "../a/b/./c/d/../../e"); + testResolvePath("/a/b/e", "./a/b/./c/d/../../e"); + testResolvePath("/a/b/e/", "./a/b/./c/d/../../e/."); + testResolvePath("/a/b/e/", "./a/b/./c/d/../../e/./."); + testResolvePath("/a/b/e/", "./a/b/./c/d/../../e/././."); + + testUriPerRFCs(); + + Expect.stringEquals( + "http://example.com", Uri.parse("http://example.com/a/b/c").origin); + Expect.stringEquals( + "https://example.com", Uri.parse("https://example.com/a/b/c").origin); + Expect.stringEquals("http://example.com:1234", + Uri.parse("http://example.com:1234/a/b/c").origin); + Expect.stringEquals("https://example.com:1234", + Uri.parse("https://example.com:1234/a/b/c").origin); + Expect.throws(() => Uri.parse("http:").origin, (e) { + return e is StateError; + }, "origin for URI with empty host should fail"); + Expect.throws( + () => new Uri( + scheme: "http", + userInfo: null, + host: "", + port: 80, + path: "/a/b/c", + query: "query", + fragment: "fragment") + .origin, (e) { + return e is StateError; + }, "origin for URI with empty host should fail"); + Expect.throws( + () => new Uri( + scheme: null, + userInfo: null, + host: "", + port: 80, + path: "/a/b/c", + query: "query", + fragment: "fragment") + .origin, (e) { + return e is StateError; + }, "origin for URI with empty scheme should fail"); + Expect.throws( + () => new Uri( + scheme: "http", + userInfo: null, + host: null, + port: 80, + path: "/a/b/c", + query: "query", + fragment: "fragment") + .origin, (e) { + return e is StateError; + }, "origin for URI with empty host should fail"); + Expect.throws(() => Uri.parse("http://:80").origin, (e) { + return e is StateError; + }, "origin for URI with empty host should fail"); + Expect.throws(() => Uri.parse("file://localhost/test.txt").origin, (e) { + return e is StateError; + }, "origin for non-http/https uri should fail"); + + // URI encode tests + // Create a string with code point 0x10000 encoded as a surrogate pair. + var s = UTF8.decode([0xf0, 0x90, 0x80, 0x80]); + + Expect.stringEquals("\u{10000}", s); + + testEncodeDecode("A + B", "A%20+%20B"); + testEncodeDecode("\uFFFE", "%EF%BF%BE"); + testEncodeDecode("\uFFFF", "%EF%BF%BF"); + testEncodeDecode("\uFFFE", "%EF%BF%BE"); + testEncodeDecode("\uFFFF", "%EF%BF%BF"); + testEncodeDecode("\x7f", "%7F"); + testEncodeDecode("\x80", "%C2%80"); + testEncodeDecode("\u0800", "%E0%A0%80"); + // All characters not escaped by encodeFull. + var unescapedFull = r"abcdefghijklmnopqrstuvwxyz" + r"ABCDEFGHIJKLMNOPQRSTUVWXYZ" + r"0123456789!#$&'()*+,-./:;=?@_~"; + // ASCII characters escaped by encodeFull: + var escapedFull = + "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" + r' "%<>[\]^`{|}' + "\x7f"; + var escapedTo = "%00%01%02%03%04%05%06%07%08%09%0A%0B%0C%0D%0E%0F" + "%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F" + "%20%22%25%3C%3E%5B%5C%5D%5E%60%7B%7C%7D%7F"; + testEncodeDecode(unescapedFull, unescapedFull); + testEncodeDecode(escapedFull, escapedTo); + var nonAscii = + "\x80-\xff-\u{100}-\u{7ff}-\u{800}-\u{ffff}-\u{10000}-\u{10ffff}"; + var nonAsciiEncoding = "%C2%80-%C3%BF-%C4%80-%DF%BF-%E0%A0%80-%EF%BF%BF-" + "%F0%90%80%80-%F4%8F%BF%BF"; + testEncodeDecode(nonAscii, nonAsciiEncoding); + testEncodeDecode(s, "%F0%90%80%80"); + testEncodeDecodeComponent("A + B", "A%20%2B%20B"); + testEncodeDecodeComponent("\uFFFE", "%EF%BF%BE"); + testEncodeDecodeComponent("\uFFFF", "%EF%BF%BF"); + testEncodeDecodeComponent("\uFFFE", "%EF%BF%BE"); + testEncodeDecodeComponent("\uFFFF", "%EF%BF%BF"); + testEncodeDecodeComponent("\x7f", "%7F"); + testEncodeDecodeComponent("\x80", "%C2%80"); + testEncodeDecodeComponent("\u0800", "%E0%A0%80"); + testEncodeDecodeComponent(":/@',;?&=+\$", "%3A%2F%40'%2C%3B%3F%26%3D%2B%24"); + testEncodeDecodeComponent(s, "%F0%90%80%80"); + testEncodeDecodeQueryComponent("A + B", "A+%2B+B", "A+%2B+B", "A+%2B+B"); + testEncodeDecodeQueryComponent( + "æ ø å", "%C3%A6+%C3%B8+%C3%A5", "%E6+%F8+%E5", null); + testEncodeDecodeComponent(nonAscii, nonAsciiEncoding); + + // Invalid URI - : and @ is swapped, port ("host") should be numeric. + Expect.throws(() => Uri.parse("file://user@password:host/path"), + (e) => e is FormatException); + + testValidCharacters(); + testInvalidUrls(); + testNormalization(); + testReplace(); + testRegression28359(); +} + +String dump(Uri uri) { + return "URI: $uri\n" + " Scheme: ${uri.scheme} #${uri.scheme.length}\n" + " User-info: ${uri.userInfo} #${uri.userInfo.length}\n" + " Host: ${uri.host} #${uri.host.length}\n" + " Port: ${uri.port}\n" + " Path: ${uri.path} #${uri.path.length}\n" + " Query: ${uri.query} #${uri.query.length}\n" + " Fragment: ${uri.fragment} #${uri.fragment.length}\n"; +} diff --git a/tools/gardening/test/parse_build_results_test.dart b/tools/gardening/test/parse_build_results_test.dart index 09104093805..f40e5935002 100644 --- a/tools/gardening/test/parse_build_results_test.dart +++ b/tools/gardening/test/parse_build_results_test.dart @@ -35,6 +35,7 @@ main(List args) async { expectedStatus, status.status, "Unexpected status for '$testName'."); } + checkTest('corelib/list_growable_test', 'pass'); checkTest('corelib_2/map_keys2_test', 'fail'); client.close(); } diff --git a/tools/status_clean.dart b/tools/status_clean.dart index 13f81570d83..e5c11e2c59f 100644 --- a/tools/status_clean.dart +++ b/tools/status_clean.dart @@ -20,6 +20,7 @@ import "testing/dart/utils.dart" show Path; // [STATUS_TUPLES] is a list of (suite-name, directory, status-file)-tuples. final STATUS_TUPLES = [ ["corelib_2", "tests/corelib_2", "tests/corelib_2/corelib_2.status"], + ["corelib", "tests/corelib", "tests/corelib/corelib.status"], ["html", "tests/html", "tests/html/html.status"], ["isolate", "tests/isolate", "tests/isolate/isolate.status"], ["language", "tests/language", "tests/language/language.status"], diff --git a/tools/testing/dart/options.dart b/tools/testing/dart/options.dart index af7a543dfd6..de0e5ce0219 100644 --- a/tools/testing/dart/options.dart +++ b/tools/testing/dart/options.dart @@ -12,6 +12,7 @@ import 'utils.dart'; const _defaultTestSelectors = const [ 'samples', 'standalone', + 'corelib', 'corelib_2', 'co19', 'language', diff --git a/tools/testing/dart/test_configurations.dart b/tools/testing/dart/test_configurations.dart index 30afd722514..d1ef501c877 100644 --- a/tools/testing/dart/test_configurations.dart +++ b/tools/testing/dart/test_configurations.dart @@ -36,6 +36,7 @@ final TEST_SUITE_DIRECTORIES = [ new Path('tests/compiler/dart2js'), new Path('tests/compiler/dart2js_extra'), new Path('tests/compiler/dart2js_native'), + new Path('tests/corelib'), new Path('tests/corelib_2'), new Path('tests/html'), new Path('tests/isolate'),

p", "p"]); +} diff --git a/tests/corelib/regexp/ascii-regexp-subject_test.dart b/tests/corelib/regexp/ascii-regexp-subject_test.dart new file mode 100644 index 00000000000..67ff6072737 --- /dev/null +++ b/tests/corelib/regexp/ascii-regexp-subject_test.dart @@ -0,0 +1,54 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2008 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +/** +* @fileoverview Check that an initial ^ will result in a faster match fail. +*/ + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + var s = "foo"; + var i; + + for (i = 0; i < 18; i++) { + s = s + s; + } + + dynamic repeatRegexp(re) { + for (i = 0; i < 1000; i++) { + re.hasMatch(s); + } + } + + repeatRegexp(new RegExp(r"^bar")); + repeatRegexp(new RegExp(r"^foo|^bar|^baz")); + repeatRegexp(new RegExp(r"(^bar)")); + repeatRegexp(new RegExp(r"(?=^bar)\w+")); +} diff --git a/tests/corelib/regexp/assertion_test.dart b/tests/corelib/regexp/assertion_test.dart new file mode 100644 index 00000000000..43ee1ca6f2c --- /dev/null +++ b/tests/corelib/regexp/assertion_test.dart @@ -0,0 +1,117 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + description("This page tests handling of parenthetical assertions."); + + var regex1 = new RegExp(r"(x)(?=\1)x"); + shouldBe(regex1.firstMatch('xx'), ['xx', 'x']); + + var regex2 = new RegExp(r"(.*?)a(?!(a+)b\2c)\2(.*)"); + shouldBe(regex2.firstMatch('baaabaac'), ['baaabaac', 'ba', null, 'abaac']); + + var regex3 = new RegExp(r"(?=(a+?))(\1ab)"); + shouldBe(regex3.firstMatch('aaab'), ['aab', 'a', 'aab']); + + var regex4 = new RegExp(r"(?=(a+?))(\1ab)"); + shouldBe(regex4.firstMatch('aaab'), ['aab', 'a', 'aab']); + + var regex5 = new RegExp(r"^P([1-6])(?=\1)([1-6])$"); + shouldBe(regex5.firstMatch('P11'), ['P11', '1', '1']); + + var regex6 = new RegExp(r"(([a-c])b*?\2)*"); + shouldBe(regex6.firstMatch('ababbbcbc'), ['ababb', 'bb', 'b']); + + var regex7 = new RegExp(r"(x)(?=x)x"); + shouldBe(regex7.firstMatch('xx'), ['xx', 'x']); + + var regex8 = new RegExp(r"(x)(\1)"); + shouldBe(regex8.firstMatch('xx'), ['xx', 'x', 'x']); + + var regex9 = new RegExp(r"(x)(?=\1)x"); + shouldBeNull(regex9.firstMatch('xy')); + + var regex10 = new RegExp(r"(x)(?=x)x"); + shouldBeNull(regex10.firstMatch('xy')); + + var regex11 = new RegExp(r"(x)(\1)"); + shouldBeNull(regex11.firstMatch('xy')); + + var regex12 = new RegExp(r"(x)(?=\1)x"); + shouldBeNull(regex12.firstMatch('x')); + shouldBe(regex12.firstMatch('xx'), ['xx', 'x']); + shouldBe(regex12.firstMatch('xxy'), ['xx', 'x']); + + var regex13 = new RegExp(r"(x)zzz(?=\1)x"); + shouldBe(regex13.firstMatch('xzzzx'), ['xzzzx', 'x']); + shouldBe(regex13.firstMatch('xzzzxy'), ['xzzzx', 'x']); + + var regex14 = new RegExp(r"(a)\1(?=(b*c))bc"); + shouldBe(regex14.firstMatch('aabc'), ['aabc', 'a', 'bc']); + shouldBe(regex14.firstMatch('aabcx'), ['aabc', 'a', 'bc']); + + var regex15 = new RegExp(r"(a)a(?=(b*c))bc"); + shouldBe(regex15.firstMatch('aabc'), ['aabc', 'a', 'bc']); + shouldBe(regex15.firstMatch('aabcx'), ['aabc', 'a', 'bc']); + + var regex16 = new RegExp(r"a(?=(b*c))bc"); + shouldBeNull(regex16.firstMatch('ab')); + shouldBe(regex16.firstMatch('abc'), ['abc', 'bc']); + + var regex17 = new RegExp(r"(?=((?:ab)*))a"); + shouldBe(regex17.firstMatch('ab'), ['a', 'ab']); + shouldBe(regex17.firstMatch('abc'), ['a', 'ab']); + + var regex18 = new RegExp(r"(?=((?:xx)*))x"); + shouldBe(regex18.firstMatch('x'), ['x', '']); + shouldBe(regex18.firstMatch('xx'), ['x', 'xx']); + shouldBe(regex18.firstMatch('xxx'), ['x', 'xx']); + + var regex19 = new RegExp(r"(?=((xx)*))x"); + shouldBe(regex19.firstMatch('x'), ['x', '', null]); + shouldBe(regex19.firstMatch('xx'), ['x', 'xx', 'xx']); + shouldBe(regex19.firstMatch('xxx'), ['x', 'xx', 'xx']); + + var regex20 = new RegExp(r"(?=(xx))+x"); + shouldBeNull(regex20.firstMatch('x')); + shouldBe(regex20.firstMatch('xx'), ['x', 'xx']); + shouldBe(regex20.firstMatch('xxx'), ['x', 'xx']); + + var regex21 = new RegExp(r"(?=a+b)aab"); + shouldBe(regex21.firstMatch('aab'), ['aab']); + + var regex22 = new RegExp( + r"(?!(u|m{0,}g+)u{1,}|2{2,}!1%n|(?!K|(?=y)|(?=ip))+?)(?=(?=(((?:7))*?)*?))p", + multiLine: true); + shouldBeNull(regex22.firstMatch('55up')); + + var regex23 = new RegExp(r"(?=(a)b|c?)()*d"); + shouldBeNull(regex23.firstMatch('ax')); + + var regex24 = new RegExp(r"(?=a|b?)c"); + shouldBeNull(regex24.firstMatch('x')); +} diff --git a/tests/corelib/regexp/backreferences_test.dart b/tests/corelib/regexp/backreferences_test.dart new file mode 100644 index 00000000000..64710207a60 --- /dev/null +++ b/tests/corelib/regexp/backreferences_test.dart @@ -0,0 +1,47 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + description( + "Test to ensure correct behaviour when using backreferences in a RegExp"); + + shouldBeTrue(new RegExp(r"(...)\1$").hasMatch('abcabc')); + shouldBeFalse(new RegExp(r"(...)\1$").hasMatch('abcdef')); + shouldBeFalse(new RegExp(r"(...)\2$").hasMatch('abcabc')); + shouldBeFalse(new RegExp(r"(...)\2$").hasMatch('abc')); + shouldBeTrue(new RegExp(r"\1(...)$").hasMatch('abcabc')); + shouldBeTrue(new RegExp(r"\1(...)$").hasMatch('abcdef')); + shouldBeFalse(new RegExp(r"\2(...)$").hasMatch('abcabc')); + shouldBeFalse(new RegExp(r"\2(...)$").hasMatch('abc')); + shouldBeTrue(new RegExp(r"\1?(...)$").hasMatch('abc')); + shouldBeTrue(new RegExp(r"\1?(...)$").hasMatch('abc')); + + var re = new RegExp(r"[^b]*((..)|(\2))+Sz", caseSensitive: false); + + shouldBeFalse(re.hasMatch('axabcd')); + shouldBeTrue(re.hasMatch('axabcsz')); +} diff --git a/tests/corelib/regexp/bol-with-multiline_test.dart b/tests/corelib/regexp/bol-with-multiline_test.dart new file mode 100644 index 00000000000..e43a618102e --- /dev/null +++ b/tests/corelib/regexp/bol-with-multiline_test.dart @@ -0,0 +1,40 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + description( + 'Test for beginning of line (BOL or ^) matching in a multiline string'); + + var s = "aced\nabc"; + shouldBeNull(firstMatch(s, new RegExp(r"^abc"))); + shouldBe(firstMatch(s, new RegExp(r"^abc", multiLine: true)), ["abc"]); + shouldBeNull(firstMatch(s, new RegExp(r"(^|X)abc"))); + shouldBe( + firstMatch(s, new RegExp(r"(^|X)abc", multiLine: true)), ["abc", ""]); + shouldBe( + firstMatch(s, new RegExp(r"(^a|Xa)bc", multiLine: true)), ["abc", "a"]); +} diff --git a/tests/corelib/regexp/bol_test.dart b/tests/corelib/regexp/bol_test.dart new file mode 100644 index 00000000000..f3c363e653b --- /dev/null +++ b/tests/corelib/regexp/bol_test.dart @@ -0,0 +1,54 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + description('Test for beginning of line (BOL or ^) matching'); + + var s = "abc123def456xyzabc789abc999"; + shouldBeNull(firstMatch(s, new RegExp(r"^notHere"))); + shouldBe(firstMatch(s, new RegExp(r"^abc")), ["abc"]); + shouldBe(firstMatch(s, new RegExp(r"(^|X)abc")), ["abc", ""]); + shouldBe(firstMatch(s, new RegExp(r"^longer|123")), ["123"]); + shouldBe(firstMatch(s, new RegExp(r"(^abc|c)123")), ["abc123", "abc"]); + shouldBe(firstMatch(s, new RegExp(r"(c|^abc)123")), ["abc123", "abc"]); + shouldBe(firstMatch(s, new RegExp(r"(^ab|abc)123")), ["abc123", "abc"]); + shouldBe(firstMatch(s, new RegExp(r"(bc|^abc)([0-9]*)a")), + ["bc789a", "bc", "789"]); + shouldBeNull(new RegExp(r"(?:(Y)X)|(X)").firstMatch("abc")); + shouldBeNull(new RegExp(r"(?:(?:^|Y)X)|(X)").firstMatch("abc")); + shouldBeNull(new RegExp(r"(?:(?:^|Y)X)|(X)").firstMatch("abcd")); + shouldBe(new RegExp(r"(?:(?:^|Y)X)|(X)").firstMatch("Xabcd"), ["X", null]); + shouldBe(new RegExp(r"(?:(?:^|Y)X)|(X)").firstMatch("aXbcd"), ["X", "X"]); + shouldBe(new RegExp(r"(?:(?:^|Y)X)|(X)").firstMatch("abXcd"), ["X", "X"]); + shouldBe(new RegExp(r"(?:(?:^|Y)X)|(X)").firstMatch("abcXd"), ["X", "X"]); + shouldBe(new RegExp(r"(?:(?:^|Y)X)|(X)").firstMatch("abcdX"), ["X", "X"]); + shouldBe(new RegExp(r"(?:(?:^|Y)X)|(X)").firstMatch("YXabcd"), ["YX", null]); + shouldBe(new RegExp(r"(?:(?:^|Y)X)|(X)").firstMatch("aYXbcd"), ["YX", null]); + shouldBe(new RegExp(r"(?:(?:^|Y)X)|(X)").firstMatch("abYXcd"), ["YX", null]); + shouldBe(new RegExp(r"(?:(?:^|Y)X)|(X)").firstMatch("abcYXd"), ["YX", null]); + shouldBe(new RegExp(r"(?:(?:^|Y)X)|(X)").firstMatch("abcdYX"), ["YX", null]); +} diff --git a/tests/corelib/regexp/capture-3_test.dart b/tests/corelib/regexp/capture-3_test.dart new file mode 100644 index 00000000000..06cfbdcfa8f --- /dev/null +++ b/tests/corelib/regexp/capture-3_test.dart @@ -0,0 +1,130 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2009 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + dynamic oneMatch(re) { + assertEquals("acd", "abcd".replaceAll(re, "")); + } + + oneMatch(new RegExp(r"b")); + oneMatch(new RegExp(r"b")); + + assertEquals("acdacd", "abcdabcd".replaceAll(new RegExp(r"b"), "")); + + dynamic captureMatch(re) { + var match = firstMatch("abcd", re); + assertEquals("b", match.group(1)); + assertEquals("c", match.group(2)); + } + + captureMatch(new RegExp(r"(b)(c)")); + captureMatch(new RegExp(r"(b)(c)")); + + // A test that initially does a zero width match, but later does a non-zero + // width match. + var a = "foo bar baz".replaceAll(new RegExp(r"^|bar"), ""); + assertEquals("foo baz", a); + + a = "foo bar baz".replaceAll(new RegExp(r"^|bar"), "*"); + assertEquals("*foo * baz", a); + + // We test FilterASCII using regexps that will backtrack forever. Since + // a regexp with a non-ASCII character in it can never match an ASCII + // string we can test that the relevant node is removed by verifying that + // there is no hang. + dynamic NoHang(re) { + firstMatch("This is an ASCII string that could take forever", re); + } + + NoHang(new RegExp( + r"(((.*)*)*x)Ā")); // Continuation after loop is filtered, so is loop. + NoHang(new RegExp(r"(((.*)*)*Ā)foo")); // Body of loop filtered. + NoHang(new RegExp( + r"Ā(((.*)*)*x)")); // Everything after a filtered character is filtered. + NoHang(new RegExp( + r"(((.*)*)*x)Ā")); // Everything before a filtered character is filtered. + NoHang(new RegExp( + r"[ćăĀ](((.*)*)*x)")); // Everything after a filtered class is filtered. + NoHang(new RegExp( + r"(((.*)*)*x)[ćăĀ]")); // Everything before a filtered class is filtered. + NoHang(new RegExp(r"[^\x00-\xff](((.*)*)*x)")); // After negated class. + NoHang(new RegExp(r"(((.*)*)*x)[^\x00-\xff]")); // Before negated class. + NoHang(new RegExp(r"(?!(((.*)*)*x)Ā)foo")); // Negative lookahead is filtered. + NoHang(new RegExp( + r"(?!(((.*)*)*x))Ā")); // Continuation branch of negative lookahead. + NoHang(new RegExp(r"(?=(((.*)*)*x)Ā)foo")); // Positive lookahead is filtered. + NoHang(new RegExp( + r"(?=(((.*)*)*x))Ā")); // Continuation branch of positive lookahead. + NoHang(new RegExp( + r"(?=Ā)(((.*)*)*x)")); // Positive lookahead also prunes continuation. + NoHang(new RegExp( + r"(æ|ø|Ā)(((.*)*)*x)")); // All branches of alternation are filtered. + NoHang(new RegExp(r"(a|b|(((.*)*)*x))Ā")); // 1 out of 3 branches pruned. + NoHang(new RegExp( + r"(a|(((.*)*)*x)ă|(((.*)*)*x)Ā)")); // 2 out of 3 branches pruned. + + var s = "Don't prune based on a repetition of length 0"; + assertEquals(null, firstMatch(s, new RegExp(r"å{1,1}prune"))); + assertEquals("prune", (firstMatch(s, new RegExp(r"å{0,0}prune"))[0])); + + // Some very deep regexps where FilterASCII gives up in order not to make the + // stack overflow. + var regex6 = new RegExp(r"a*\u0100*\w"); + var input0 = "a"; + regex6.firstMatch(input0); + + var re = "\u0100*\\w"; + + for (var i = 0; i < 200; i++) re = "a*" + re; + + var regex7 = new RegExp(re); + regex7.firstMatch(input0); + + var regex8 = new RegExp(re, caseSensitive: false); + regex8.firstMatch(input0); + + re = "[\u0100]*\\w"; + for (var i = 0; i < 200; i++) re = "a*" + re; + + var regex9 = new RegExp(re); + regex9.firstMatch(input0); + + var regex10 = new RegExp(re, caseSensitive: false); + regex10.firstMatch(input0); + + var regex11 = new RegExp(r"^(?:[^\u0000-\u0080]|[0-9a-z?,.!&\s#()])+$", + caseSensitive: false); + regex11.firstMatch(input0); + + var regex12 = new RegExp( + r"u(\xf0{8}?\D*?|( ? !)$h??(|)*?(||)+?\6((?:\W\B|--\d-*-|)?$){0, }?|^Y( ? !1)\d+)+a"); + regex12.firstMatch(""); +} diff --git a/tests/corelib/regexp/capture_test.dart b/tests/corelib/regexp/capture_test.dart new file mode 100644 index 00000000000..aa1ff8d026a --- /dev/null +++ b/tests/corelib/regexp/capture_test.dart @@ -0,0 +1,57 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2009 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + // Tests from http://blog.stevenlevithan.com/archives/npcg-javascript + + assertEquals(true, new RegExp(r"(x)?\1y").hasMatch("y")); + shouldBe(new RegExp(r"(x)?\1y").firstMatch("y"), ["y", null]); + shouldBe(new RegExp(r"(x)?y").firstMatch("y"), ["y", null]); + shouldBe(firstMatch("y", new RegExp(r"(x)?\1y")), ["y", null]); + shouldBe(firstMatch("y", new RegExp(r"(x)?y")), ["y", null]); + shouldBe(firstMatch("y", new RegExp(r"(x)?\1y")), ["y", null]); + Expect.listEquals(["", ""], "y".split(new RegExp(r"(x)?\1y"))); + Expect.listEquals(["", ""], "y".split(new RegExp(r"(x)?y"))); + assertEquals(0, "y".indexOf(new RegExp(r"(x)?\1y"))); + assertEquals("z", "y".replaceAll(new RegExp(r"(x)?\1y"), "z")); + + // See https://bugzilla.mozilla.org/show_bug.cgi?id=476146 + shouldBe(new RegExp(r"^(b+|a){1,2}?bc").firstMatch("bbc"), ["bbc", "b"]); + shouldBe( + new RegExp(r"((\3|b)\2(a)){2,}").firstMatch("bbaababbabaaaaabbaaaabba"), + ["bbaa", "a", "", "a"]); + + // From crbug.com/128821 - don't hang: + firstMatch( + "", + new RegExp( + r"((a|i|A|I|u|o|U|O)(s|c|b|c|d|f|g|h|j|k|l|m|n|p|q|r|s|t|v|w|x|y|z|B|C|D|F|G|H|J|K|L|M|N|P|Q|R|S|T|V|W|X|Y|Z)*) de\/da([.,!?\s]|$)")); +} diff --git a/tests/corelib/regexp/captures_test.dart b/tests/corelib/regexp/captures_test.dart new file mode 100644 index 00000000000..c7aa44b561c --- /dev/null +++ b/tests/corelib/regexp/captures_test.dart @@ -0,0 +1,37 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2009 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + var re = new RegExp( + r"^(((N({)?)|(R)|(U)|(V)|(B)|(H)|(n((n)|(r)|(v)|(h))?)|(r(r)?)|(v)|(b((n)|(b))?)|(h))|((Y)|(A)|(E)|(o(u)?)|(p(u)?)|(q(u)?)|(s)|(t)|(u)|(w)|(x(u)?)|(y)|(z)|(a((T)|(A)|(L))?)|(c)|(e)|(f(u)?)|(g(u)?)|(i)|(j)|(l)|(m(u)?)))+"); + var str = "Avtnennan gunzvmu pubExnY nEvln vaTxh rmuhguhaTxnY"; + assertTrue(re.hasMatch(str)); +} diff --git a/tests/corelib/regexp/char-insensitive_test.dart b/tests/corelib/regexp/char-insensitive_test.dart new file mode 100644 index 00000000000..7a81ff86c71 --- /dev/null +++ b/tests/corelib/regexp/char-insensitive_test.dart @@ -0,0 +1,68 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + description( + "This test checks the case-insensitive matching of character literals."); + + shouldBeTrue(new RegExp(r"\u00E5", caseSensitive: false) + .hasMatch('new RegExp(r"\u00E5")')); + shouldBeTrue(new RegExp(r"\u00E5", caseSensitive: false) + .hasMatch('new RegExp(r"\u00C5")')); + shouldBeTrue(new RegExp(r"\u00C5", caseSensitive: false) + .hasMatch('new RegExp(r"\u00E5")')); + shouldBeTrue(new RegExp(r"\u00C5", caseSensitive: false) + .hasMatch('new RegExp(r"\u00C5")')); + + shouldBeFalse(new RegExp(r"\u00E5", caseSensitive: false).hasMatch('P')); + shouldBeFalse(new RegExp(r"\u00E5", caseSensitive: false).hasMatch('PASS')); + shouldBeFalse(new RegExp(r"\u00C5", caseSensitive: false).hasMatch('P')); + shouldBeFalse(new RegExp(r"\u00C5", caseSensitive: false).hasMatch('PASS')); + + shouldBeNull(firstMatch('PASS', new RegExp(r"\u00C5", caseSensitive: false))); + shouldBeNull(firstMatch('PASS', new RegExp(r"\u00C5", caseSensitive: false))); + + assertEquals( + 'PAS\u00E5'.replaceAll(new RegExp(r"\u00E5", caseSensitive: false), 'S'), + 'PASS'); + assertEquals( + 'PAS\u00E5'.replaceAll(new RegExp(r"\u00C5", caseSensitive: false), 'S'), + 'PASS'); + assertEquals( + 'PAS\u00C5'.replaceAll(new RegExp(r"\u00E5", caseSensitive: false), 'S'), + 'PASS'); + assertEquals( + 'PAS\u00C5'.replaceAll(new RegExp(r"\u00C5", caseSensitive: false), 'S'), + 'PASS'); + + assertEquals( + 'PASS'.replaceAll(new RegExp(r"\u00E5", caseSensitive: false), '%C3%A5'), + 'PASS'); + assertEquals( + 'PASS'.replaceAll(new RegExp(r"\u00C5", caseSensitive: false), '%C3%A5'), + 'PASS'); +} diff --git a/tests/corelib/regexp/character-match-out-of-order_test.dart b/tests/corelib/regexp/character-match-out-of-order_test.dart new file mode 100644 index 00000000000..863c36b80bc --- /dev/null +++ b/tests/corelib/regexp/character-match-out-of-order_test.dart @@ -0,0 +1,33 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + description( + 'Test to ensure RegExp generates single character matches in the correct order'); + + shouldBe(new RegExp(r"[\w']+").firstMatch("'_'"), ["'_'"]); +} diff --git a/tests/corelib/regexp/compile-crash_test.dart b/tests/corelib/regexp/compile-crash_test.dart new file mode 100644 index 00000000000..3bb3f3fc6b8 --- /dev/null +++ b/tests/corelib/regexp/compile-crash_test.dart @@ -0,0 +1,38 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + description( + 'Test regexp compiling to make sure it doens\'t crash like bug 16127'); + + shouldBeTrue(new RegExp(r"\)[;\s]+") != null); + assertThrows(() => new RegExp(r"[")); + assertThrows(() => new RegExp(r"[a")); + assertThrows(() => new RegExp(r"[-")); + shouldBeTrue(new RegExp(r"(a)\1") != null); + shouldBeTrue(new RegExp(r"(a)\1{1,3}") != null); +} diff --git a/tests/corelib/regexp/compile_test.dart b/tests/corelib/regexp/compile_test.dart new file mode 100644 index 00000000000..e9932bb58a8 --- /dev/null +++ b/tests/corelib/regexp/compile_test.dart @@ -0,0 +1,42 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + description('Test RegExp.compile method.'); + + var re = new RegExp("a", caseSensitive: false); + shouldBeTrue(re.hasMatch('A')); + shouldBeFalse(re.isMultiLine); + shouldBeFalse(re.isCaseSensitive); + + re = new RegExp("a"); + shouldBeFalse(re.isMultiLine); + shouldBeTrue(re.isCaseSensitive); + shouldBeFalse(re.hasMatch('A')); + + assertThrows(() => new RegExp('+')); +} diff --git a/tests/corelib/regexp/constructor_test.dart b/tests/corelib/regexp/constructor_test.dart new file mode 100644 index 00000000000..046cf897e33 --- /dev/null +++ b/tests/corelib/regexp/constructor_test.dart @@ -0,0 +1,43 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + description("This test checks use of the regexp constructor."); + + var re = new RegExp(r"abc"); + + // We do not guarantee that the same regular expression will or will not be shared. + // shouldBeTrue(identical(re, new RegExp(r"abc"))); + // shouldBeTrue(identical(re, new RegExp(r"abc", caseSensitive: true, multiLine: false))); + + shouldBeFalse( + identical(re, new RegExp(r"abc", caseSensitive: false, multiLine: true))); + shouldBeFalse( + identical(re, new RegExp(r"abc", caseSensitive: true, multiLine: true))); + shouldBeFalse(identical( + re, new RegExp(r"abc", caseSensitive: false, multiLine: false))); +} diff --git a/tests/corelib/regexp/default_arguments_test.dart b/tests/corelib/regexp/default_arguments_test.dart new file mode 100644 index 00000000000..0baf31614ed --- /dev/null +++ b/tests/corelib/regexp/default_arguments_test.dart @@ -0,0 +1,35 @@ +// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +// Test that `null` is interpreted as `false` when passed as argument to +// `caseSensitive` and `multiLine`. + +import 'package:expect/expect.dart'; + +main() { + testCaseSensitive(); + testMultiLine(); +} + +testCaseSensitive() { + var r1 = new RegExp('foo'); + var r2 = new RegExp('foo', caseSensitive: true); + var r3 = new RegExp('foo', caseSensitive: false); + var r4 = new RegExp('foo', caseSensitive: null); + Expect.isNull(r1.firstMatch('Foo'), "r1.firstMatch('Foo')"); + Expect.isNull(r2.firstMatch('Foo'), "r2.firstMatch('Foo')"); + Expect.isNotNull(r3.firstMatch('Foo'), "r3.firstMatch('Foo')"); + Expect.isNotNull(r4.firstMatch('Foo'), "r4.firstMatch('Foo')"); +} + +testMultiLine() { + var r1 = new RegExp(r'^foo$'); + var r2 = new RegExp(r'^foo$', multiLine: true); + var r3 = new RegExp(r'^foo$', multiLine: false); + var r4 = new RegExp(r'^foo$', multiLine: null); + Expect.isNull(r1.firstMatch('\nfoo\n'), "r1.firstMatch('\\nfoo\\n')"); + Expect.isNotNull(r2.firstMatch('\nfoo\n'), "r2.firstMatch('\\nfoo\\n')"); + Expect.isNull(r3.firstMatch('\nfoo\n'), "r3.firstMatch('\\nfoo\\n')"); + Expect.isNull(r4.firstMatch('\nfoo\n'), "r4.firstMatch('\\nfoo\\n')"); +} diff --git a/tests/corelib/regexp/dotstar_test.dart b/tests/corelib/regexp/dotstar_test.dart new file mode 100644 index 00000000000..33e8107997a --- /dev/null +++ b/tests/corelib/regexp/dotstar_test.dart @@ -0,0 +1,166 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + description("This page tests handling of parentheses subexpressions."); + + var regexp1 = new RegExp(r".*blah.*"); + shouldBeNull(regexp1.firstMatch('test')); + shouldBe(regexp1.firstMatch('blah'), ['blah']); + shouldBe(regexp1.firstMatch('1blah'), ['1blah']); + shouldBe(regexp1.firstMatch('blah1'), ['blah1']); + shouldBe(regexp1.firstMatch('blah blah blah'), ['blah blah blah']); + shouldBe(regexp1.firstMatch('blah\nsecond'), ['blah']); + shouldBe(regexp1.firstMatch('first\nblah'), ['blah']); + shouldBe(regexp1.firstMatch('first\nblah\nthird'), ['blah']); + shouldBe(regexp1.firstMatch('first\nblah2\nblah3'), ['blah2']); + + var regexp2 = new RegExp(r"^.*blah.*"); + shouldBeNull(regexp2.firstMatch('test')); + shouldBe(regexp2.firstMatch('blah'), ['blah']); + shouldBe(regexp2.firstMatch('1blah'), ['1blah']); + shouldBe(regexp2.firstMatch('blah1'), ['blah1']); + shouldBe(regexp2.firstMatch('blah blah blah'), ['blah blah blah']); + shouldBe(regexp2.firstMatch('blah\nsecond'), ['blah']); + shouldBeNull(regexp2.firstMatch('first\nblah')); + shouldBeNull(regexp2.firstMatch('first\nblah\nthird')); + shouldBeNull(regexp2.firstMatch('first\nblah2\nblah3')); + + var regexp3 = new RegExp(r".*blah.*$"); + shouldBeNull(regexp3.firstMatch('test')); + shouldBe(regexp3.firstMatch('blah'), ['blah']); + shouldBe(regexp3.firstMatch('1blah'), ['1blah']); + shouldBe(regexp3.firstMatch('blah1'), ['blah1']); + shouldBe(regexp3.firstMatch('blah blah blah'), ['blah blah blah']); + shouldBeNull(regexp3.firstMatch('blah\nsecond')); + shouldBe(regexp3.firstMatch('first\nblah'), ['blah']); + shouldBeNull(regexp3.firstMatch('first\nblah\nthird')); + shouldBe(regexp3.firstMatch('first\nblah2\nblah3'), ['blah3']); + + var regexp4 = new RegExp(r"^.*blah.*$"); + shouldBeNull(regexp4.firstMatch('test')); + shouldBe(regexp4.firstMatch('blah'), ['blah']); + shouldBe(regexp4.firstMatch('1blah'), ['1blah']); + shouldBe(regexp4.firstMatch('blah1'), ['blah1']); + shouldBe(regexp4.firstMatch('blah blah blah'), ['blah blah blah']); + shouldBeNull(regexp4.firstMatch('blah\nsecond')); + shouldBeNull(regexp4.firstMatch('first\nblah')); + shouldBeNull(regexp4.firstMatch('first\nblah\nthird')); + shouldBeNull(regexp4.firstMatch('first\nblah2\nblah3')); + + var regexp5 = new RegExp(r".*?blah.*"); + shouldBeNull(regexp5.firstMatch('test')); + shouldBe(regexp5.firstMatch('blah'), ['blah']); + shouldBe(regexp5.firstMatch('1blah'), ['1blah']); + shouldBe(regexp5.firstMatch('blah1'), ['blah1']); + shouldBe(regexp5.firstMatch('blah blah blah'), ['blah blah blah']); + shouldBe(regexp5.firstMatch('blah\nsecond'), ['blah']); + shouldBe(regexp5.firstMatch('first\nblah'), ['blah']); + shouldBe(regexp5.firstMatch('first\nblah\nthird'), ['blah']); + shouldBe(regexp5.firstMatch('first\nblah2\nblah3'), ['blah2']); + + var regexp6 = new RegExp(r".*blah.*?"); + shouldBeNull(regexp6.firstMatch('test')); + shouldBe(regexp6.firstMatch('blah'), ['blah']); + shouldBe(regexp6.firstMatch('1blah'), ['1blah']); + shouldBe(regexp6.firstMatch('blah1'), ['blah']); + shouldBe(regexp6.firstMatch('blah blah blah'), ['blah blah blah']); + shouldBe(regexp6.firstMatch('blah\nsecond'), ['blah']); + shouldBe(regexp6.firstMatch('first\nblah'), ['blah']); + shouldBe(regexp6.firstMatch('first\nblah\nthird'), ['blah']); + shouldBe(regexp6.firstMatch('first\nblah2\nblah3'), ['blah']); + + var regexp7 = new RegExp(r"^.*?blah.*?$"); + shouldBeNull(regexp7.firstMatch('test')); + shouldBe(regexp7.firstMatch('blah'), ['blah']); + shouldBe(regexp7.firstMatch('1blah'), ['1blah']); + shouldBe(regexp7.firstMatch('blah1'), ['blah1']); + shouldBe(regexp7.firstMatch('blah blah blah'), ['blah blah blah']); + shouldBeNull(regexp7.firstMatch('blah\nsecond')); + shouldBeNull(regexp7.firstMatch('first\nblah')); + shouldBeNull(regexp7.firstMatch('first\nblah\nthird')); + shouldBeNull(regexp7.firstMatch('first\nblah2\nblah3')); + + var regexp8 = new RegExp(r"^(.*)blah.*$"); + shouldBeNull(regexp8.firstMatch('test')); + shouldBe(regexp8.firstMatch('blah'), ['blah', '']); + shouldBe(regexp8.firstMatch('1blah'), ['1blah', '1']); + shouldBe(regexp8.firstMatch('blah1'), ['blah1', '']); + shouldBe( + regexp8.firstMatch('blah blah blah'), ['blah blah blah', 'blah blah ']); + shouldBeNull(regexp8.firstMatch('blah\nsecond')); + shouldBeNull(regexp8.firstMatch('first\nblah')); + shouldBeNull(regexp8.firstMatch('first\nblah\nthird')); + shouldBeNull(regexp8.firstMatch('first\nblah2\nblah3')); + + var regexp9 = new RegExp(r".*blah.*", multiLine: true); + shouldBeNull(regexp9.firstMatch('test')); + shouldBe(regexp9.firstMatch('blah'), ['blah']); + shouldBe(regexp9.firstMatch('1blah'), ['1blah']); + shouldBe(regexp9.firstMatch('blah1'), ['blah1']); + shouldBe(regexp9.firstMatch('blah blah blah'), ['blah blah blah']); + shouldBe(regexp9.firstMatch('blah\nsecond'), ['blah']); + shouldBe(regexp9.firstMatch('first\nblah'), ['blah']); + shouldBe(regexp9.firstMatch('first\nblah\nthird'), ['blah']); + shouldBe(regexp9.firstMatch('first\nblah2\nblah3'), ['blah2']); + + var regexp10 = new RegExp(r"^.*blah.*", multiLine: true); + shouldBeNull(regexp10.firstMatch('test')); + shouldBe(regexp10.firstMatch('blah'), ['blah']); + shouldBe(regexp10.firstMatch('1blah'), ['1blah']); + shouldBe(regexp10.firstMatch('blah1'), ['blah1']); + shouldBe(regexp10.firstMatch('blah blah blah'), ['blah blah blah']); + shouldBe(regexp10.firstMatch('blah\nsecond'), ['blah']); + shouldBe(regexp10.firstMatch('first\nblah'), ['blah']); + shouldBe(regexp10.firstMatch('first\nblah\nthird'), ['blah']); + shouldBe(regexp10.firstMatch('first\nblah2\nblah3'), ['blah2']); + + var regexp11 = new RegExp(r".*(?:blah).*$"); + shouldBeNull(regexp11.firstMatch('test')); + shouldBe(regexp11.firstMatch('blah'), ['blah']); + shouldBe(regexp11.firstMatch('1blah'), ['1blah']); + shouldBe(regexp11.firstMatch('blah1'), ['blah1']); + shouldBe(regexp11.firstMatch('blah blah blah'), ['blah blah blah']); + shouldBeNull(regexp11.firstMatch('blah\nsecond')); + shouldBe(regexp11.firstMatch('first\nblah'), ['blah']); + shouldBeNull(regexp11.firstMatch('first\nblah\nthird')); + shouldBe(regexp11.firstMatch('first\nblah2\nblah3'), ['blah3']); + + var regexp12 = new RegExp(r".*(?:blah|buzz|bang).*$"); + shouldBeNull(regexp12.firstMatch('test')); + shouldBe(regexp12.firstMatch('blah'), ['blah']); + shouldBe(regexp12.firstMatch('1blah'), ['1blah']); + shouldBe(regexp12.firstMatch('blah1'), ['blah1']); + shouldBe(regexp12.firstMatch('blah blah blah'), ['blah blah blah']); + shouldBeNull(regexp12.firstMatch('blah\nsecond')); + shouldBe(regexp12.firstMatch('first\nblah'), ['blah']); + shouldBeNull(regexp12.firstMatch('first\nblah\nthird')); + shouldBe(regexp12.firstMatch('first\nblah2\nblah3'), ['blah3']); + + var regexp13 = new RegExp(r".*\n\d+.*"); + shouldBe(regexp13.firstMatch('abc\n123'), ['abc\n123']); +} diff --git a/tests/corelib/regexp/early-acid3-86_test.dart b/tests/corelib/regexp/early-acid3-86_test.dart new file mode 100644 index 00000000000..5b81f060af3 --- /dev/null +++ b/tests/corelib/regexp/early-acid3-86_test.dart @@ -0,0 +1,38 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + description( + 'Test that covers capturing brackets, and was adapted from a part of an early version of Acid3.'); + + // JS regexps aren't like Perl regexps, if their character + // classes start with a ] that means they're empty. So this + // is a syntax error; if we get here it's a bug. + assertThrows(() => new RegExp(r"TA[])]").firstMatch('TA]')); + shouldBeNull(new RegExp(r"[]").firstMatch('')); + shouldBe(new RegExp(r"(\3)(\1)(a)").firstMatch('cat'), ['a', '', '', 'a']); +} diff --git a/tests/corelib/regexp/ecma-regex-examples_test.dart b/tests/corelib/regexp/ecma-regex-examples_test.dart new file mode 100644 index 00000000000..6ad84b64b56 --- /dev/null +++ b/tests/corelib/regexp/ecma-regex-examples_test.dart @@ -0,0 +1,71 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + description( + "This page tests the regex examples from the ECMA-262 specification."); + + var regex01 = new RegExp(r"a|ab"); + shouldBe(regex01.firstMatch("abc"), ["a"]); + + var regex02 = new RegExp(r"((a)|(ab))((c)|(bc))"); + shouldBe( + regex02.firstMatch("abc"), ["abc", "a", "a", null, "bc", null, "bc"]); + + var regex03 = new RegExp(r"a[a-z]{2,4}"); + shouldBe(regex03.firstMatch("abcdefghi"), ["abcde"]); + + var regex04 = new RegExp(r"a[a-z]{2,4}?"); + shouldBe(regex04.firstMatch("abcdefghi"), ["abc"]); + + var regex05 = new RegExp(r"(aa|aabaac|ba|b|c)*"); + shouldBe(regex05.firstMatch("aabaac"), ["aaba", "ba"]); + + var regex06 = new RegExp(r"^(a+)\1*,\1+$"); + Expect.equals( + "aaaaaaaaaa,aaaaaaaaaaaaaaa".replaceAllMapped(regex06, (m) => m.group(1)), + "aaaaa"); + + var regex07 = new RegExp(r"(z)((a+)?(b+)?(c))*"); + shouldBe(regex07.firstMatch("zaacbbbcac"), + ["zaacbbbcac", "z", "ac", "a", null, "c"]); + + var regex08 = new RegExp(r"(a*)*"); + shouldBe(regex08.firstMatch("b"), ["", null]); + + var regex09 = new RegExp(r"(a*)b\1+"); + shouldBe(regex09.firstMatch("baaaac"), ["b", ""]); + + var regex10 = new RegExp(r"(?=(a+))"); + shouldBe(regex10.firstMatch("baaabac"), ["", "aaa"]); + + var regex11 = new RegExp(r"(?=(a+))a*b\1"); + shouldBe(regex11.firstMatch("baaabac"), ["aba", "a"]); + + var regex12 = new RegExp(r"(.*?)a(?!(a+)b\2c)\2(.*)"); + shouldBe(regex12.firstMatch("baaabaac"), ["baaabaac", "ba", null, "abaac"]); +} diff --git a/tests/corelib/regexp/extended-characters-match_test.dart b/tests/corelib/regexp/extended-characters-match_test.dart new file mode 100644 index 00000000000..c11f95e520f --- /dev/null +++ b/tests/corelib/regexp/extended-characters-match_test.dart @@ -0,0 +1,45 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + description( + "This test checks regular expressions using extended (> 255) characters and character classes."); + + shouldBeNull((new RegExp("[\u0100-\u0101]")).firstMatch("a")); + shouldBeNull((new RegExp("[\u0100]")).firstMatch("a")); + shouldBeNull((new RegExp("\u0100")).firstMatch("a")); + assertEquals((new RegExp("[\u0061]")).firstMatch("a").group(0), "a"); + assertEquals((new RegExp("[\u0100-\u0101a]")).firstMatch("a").group(0), "a"); + assertEquals((new RegExp("[\u0100a]")).firstMatch("a").group(0), "a"); + assertEquals((new RegExp("\u0061")).firstMatch("a").group(0), "a"); + assertEquals((new RegExp("[a-\u0100]")).firstMatch("a").group(0), "a"); + assertEquals( + (new RegExp("[\u0100]")).firstMatch("\u0100").group(0), "\u0100"); + assertEquals( + (new RegExp("[\u0100-\u0101]")).firstMatch("\u0100").group(0), "\u0100"); + assertEquals((new RegExp("\u0100")).firstMatch("\u0100").group(0), "\u0100"); +} diff --git a/tests/corelib/regexp/extended-characters-more_test.dart b/tests/corelib/regexp/extended-characters-more_test.dart new file mode 100644 index 00000000000..f51a016e330 --- /dev/null +++ b/tests/corelib/regexp/extended-characters-more_test.dart @@ -0,0 +1,40 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + description( + "This test checks a few cases of extended (> 127) characters in repeat regular expressions."); + + assertEquals( + "foo\u00a0\u00a0\u00a0" + .replaceFirst(new RegExp(new String.fromCharCode(0x00a0) + "*"), ""), + "foo\u00a0\u00a0\u00a0"); + assertEquals( + "foo\u00a0\u00a0\u00a0".replaceFirst(new RegExp(r"\u00a0+"), ""), "foo"); + assertEquals( + "foo\u00a0\u00a0\u00a0".replaceFirst(new RegExp(r"\u00a0*$"), ""), "foo"); +} diff --git a/tests/corelib/regexp/find-first-asserted_test.dart b/tests/corelib/regexp/find-first-asserted_test.dart new file mode 100644 index 00000000000..e985bf0a2dc --- /dev/null +++ b/tests/corelib/regexp/find-first-asserted_test.dart @@ -0,0 +1,37 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + description( + 'Tests some regular expressions that were doing the wrong thing with the "find first asserted" optimization.'); + + shouldBe( + new RegExp(r".*(.*).*").firstMatch("foobarbaz"), + ["foobarbaz", "bar"]); + shouldBe(new RegExp(r"\s*\s*").firstMatch(""), + ["", ""]); +} diff --git a/tests/corelib/regexp/global_test.dart b/tests/corelib/regexp/global_test.dart new file mode 100644 index 00000000000..1954916dd14 --- /dev/null +++ b/tests/corelib/regexp/global_test.dart @@ -0,0 +1,184 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2012 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + var str = "ABX X"; + str = str.replaceAll(new RegExp(r"(\w)?X"), "c"); + assertEquals("Ac c", str); + + // Test zero-length matches. + str = "Als Gregor Samsa eines Morgens"; + str = str.replaceAll(new RegExp(r"\b"), "/"); + assertEquals("/Als/ /Gregor/ /Samsa/ /eines/ /Morgens/", str); + + // Test zero-length matches that have non-zero-length sub-captures. + str = "It was a pleasure to burn."; + str = str.replaceAllMapped( + new RegExp(r"(?=(\w+))\b"), (Match m) => m.group(1).length.toString()); + assertEquals("2It 3was 1a 8pleasure 2to 4burn.", str); + + // Test multiple captures. + str = "Try not. Do, or do not. There is no try."; + str = str.replaceAllMapped( + new RegExp(r"(not?)|(do)|(try)", caseSensitive: false), (m) { + if (m.group(1) != null) return "-"; + if (m.group(2) != null) return "+"; + if (m.group(3) != null) return "="; + }); + assertEquals("= -. +, or + -. There is - =.", str); + + // Test multiple alternate captures. + str = "FOUR LEGS GOOD, TWO LEGS BAD!"; + str = str.replaceAllMapped(new RegExp(r"(FOUR|TWO) LEGS (GOOD|BAD)"), (m) { + if (m.group(1) == "FOUR") assertTrue(m.group(2) == "GOOD"); + if (m.group(1) == "TWO") assertTrue(m.group(2) == "BAD"); + return m.group(0).length - 10; + }); + assertEquals("4, 2!", str); + + // The same tests with UC16. + + //Test that an optional capture is cleared between two matches. + str = "AB\u1234 \u1234"; + str = str.replaceAll(new RegExp(r"(\w)?\u1234"), "c"); + assertEquals("Ac c", str); + + // Test zero-length matches. + str = "Als \u2623\u2642 eines Morgens"; + str = str.replaceAll(new RegExp(r"\b"), "/"); + + // Test zero-length matches that have non-zero-length sub-captures. + str = "It was a pleasure to \u70e7."; + str = str.replaceAllMapped( + new RegExp(r"(?=(\w+))\b"), (m) => "${m.group(1).length}"); + assertEquals("2It 3was 1a 8pleasure 2to \u70e7.", str); + + // Test multiple captures. + str = "Try not. D\u26aa, or d\u26aa not. There is no try."; + str = str.replaceAllMapped( + new RegExp(r"(not?)|(d\u26aa)|(try)", caseSensitive: false), (m) { + if (m.group(1) != null) return "-"; + if (m.group(2) != null) return "+"; + if (m.group(3) != null) return "="; + }); + assertEquals("= -. +, or + -. There is - =.", str); + + // Test multiple alternate captures. + str = "FOUR \u817f GOOD, TWO \u817f BAD!"; + str = str.replaceAllMapped(new RegExp(r"(FOUR|TWO) \u817f (GOOD|BAD)"), (m) { + if (m.group(1) == "FOUR") assertTrue(m.group(2) == "GOOD"); + if (m.group(1) == "TWO") assertTrue(m.group(2) == "BAD"); + return m.group(0).length - 7; + }); + assertEquals("4, 2!", str); + + // Test capture that is a real substring. + str = "Beasts of England, beasts of Ireland"; + str = str.replaceAll(new RegExp(r"(.*)"), '~'); + assertEquals("~~", str); + + // Test zero-length matches that have non-zero-length sub-captures that do not + // start at the match start position. + str = "up up up up"; + str = str.replaceAllMapped( + new RegExp(r"\b(?=u(p))"), (m) => "${m.group(1).length}"); + + assertEquals("1up 1up 1up 1up", str); + + // Create regexp that has a *lot* of captures. + var re_string = "(a)"; + for (var i = 0; i < 500; i++) { + re_string = "(" + re_string + ")"; + } + re_string = re_string + "1"; + // re_string = "(((...((a))...)))1" + + var regexps = new List(); + var last_match_expectations = new List(); + var first_capture_expectations = new List(); + + // Atomic regexp. + regexps.add(new RegExp(r"a1")); + last_match_expectations.add("a1"); + first_capture_expectations.add(""); + // Small regexp (no capture); + regexps.add(new RegExp(r"\w1")); + last_match_expectations.add("a1"); + first_capture_expectations.add(""); + // Small regexp (one capture). + regexps.add(new RegExp(r"(a)1")); + last_match_expectations.add("a1"); + first_capture_expectations.add("a"); + // Large regexp (a lot of captures). + regexps.add(new RegExp(re_string)); + last_match_expectations.add("a1"); + first_capture_expectations.add("a"); + + dynamic test_replace(result_expectation, subject, regexp, replacement) { + for (var i = 0; i < regexps.length; i++) { + // Conduct tests. + assertEquals( + result_expectation, subject.replaceAll(regexps[i], replacement)); + } + } + + // Test for different number of matches. + for (var m = 0; m < 33; m++) { + // Create string that matches m times. + var subject = ""; + var test_1_expectation = ""; + var test_2_expectation = ""; + var test_3_expectation = (m == 0) ? null : new List(); + for (var i = 0; i < m; i++) { + subject += "a11"; + test_1_expectation += "x1"; + test_2_expectation += "1"; + test_3_expectation.add("a1"); + } + + // Test 1a: String.replace with string. + test_replace(test_1_expectation, subject, new RegExp(r"a1"), "x"); + + // Test 2a: String.replace with empty string. + test_replace(test_2_expectation, subject, new RegExp(r"a1"), ""); + } + + // Test String hashing (compiling regular expression includes hashing). + var crosscheck = "\x80"; + for (var i = 0; i < 12; i++) crosscheck += crosscheck; + new RegExp(crosscheck); + + var subject = "ascii~only~string~here~"; + var replacement = "\x80"; + var result = subject.replaceAll(new RegExp(r"~"), replacement); + for (var i = 0; i < 5; i++) result += result; + new RegExp(result); +} diff --git a/tests/corelib/regexp/indexof_test.dart b/tests/corelib/regexp/indexof_test.dart new file mode 100644 index 00000000000..7b0489f5d7e --- /dev/null +++ b/tests/corelib/regexp/indexof_test.dart @@ -0,0 +1,105 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2008 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + dynamic CheckMatch(re, str, matches) { + assertEquals(matches.length > 0, re.hasMatch(str)); + var result = re.allMatches(str).toList(); + if (matches.length > 0) { + assertEquals(matches.length, result.length); + var lastExpected; + var lastFrom; + var lastLength; + for (var idx = 0; idx < matches.length; idx++) { + var from = matches[idx][0]; + var length = matches[idx][1]; + var expected = str.substring(from, from + length); + var name = "$str[$from..${from+length}]"; + assertEquals(expected, result[idx].group(0), name); + } + } else { + assertTrue(result.isEmpty); + } + } + + CheckMatch(new RegExp(r"abc"), "xxxabcxxxabcxxx", [ + [3, 3], + [9, 3] + ]); + CheckMatch(new RegExp(r"abc"), "abcabcabc", [ + [0, 3], + [3, 3], + [6, 3] + ]); + CheckMatch(new RegExp(r"aba"), "ababababa", [ + [0, 3], + [4, 3] + ]); + CheckMatch(new RegExp(r"foo"), "ofooofoooofofooofo", [ + [1, 3], + [5, 3], + [12, 3] + ]); + CheckMatch(new RegExp(r"foobarbaz"), "xx", []); + CheckMatch(new RegExp(r"abc"), "abababa", []); + + assertEquals("xxxdefxxxdefxxx", + "xxxabcxxxabcxxx".replaceAll(new RegExp(r"abc"), "def")); + assertEquals( + "o-o-oofo-ofo", "ofooofoooofofooofo".replaceAll(new RegExp(r"foo"), "-")); + assertEquals("deded", "deded".replaceAll(new RegExp(r"x"), "-")); + assertEquals("-a-b-c-d-e-f-", "abcdef".replaceAll(new RegExp(""), "-")); + + CheckMatch(new RegExp(r"a(.)"), "xyzzyabxyzzyacxyzzy", [ + [5, 2], + [12, 2] + ]); + + CheckMatch(new RegExp(r"a|(?:)"), "aba", [ + [0, 1], + [1, 0], + [2, 1], + [3, 0] + ]); + CheckMatch(new RegExp(r"a|(?:)"), "baba", [ + [0, 0], + [1, 1], + [2, 0], + [3, 1], + [4, 0] + ]); + CheckMatch(new RegExp(r"a|(?:)"), "bab", [ + [0, 0], + [1, 1], + [2, 0], + [3, 0] + ]); +} diff --git a/tests/corelib/regexp/invalid-range-in-class_test.dart b/tests/corelib/regexp/invalid-range-in-class_test.dart new file mode 100644 index 00000000000..4669858902a --- /dev/null +++ b/tests/corelib/regexp/invalid-range-in-class_test.dart @@ -0,0 +1,54 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + description("This page tests invalid character ranges in character classes."); + + // These test a basic range / non range. + shouldBe(new RegExp(r"[a-c]+").firstMatch("-acbd"), ["acb"]); + shouldBe(new RegExp(r"[a\-c]+").firstMatch("-acbd"), ["-ac"]); + + // A reverse-range is invalid. + assertThrows(() => new RegExp(r"[c-a]+").firstMatch("-acbd")); + + // A character-class in a range is invalid, according to ECMA-262, but we allow it. + shouldBe(new RegExp(r"[\d-x]+").firstMatch("1-3xy"), ["1-3x"]); + shouldBe(new RegExp(r"[x-\d]+").firstMatch("1-3xy"), ["1-3x"]); + shouldBe(new RegExp(r"[\\d-\d]+").firstMatch("1-3xy"), ["1-3"]); + + // Whilst we break with ECMA-262's definition of CharacterRange, we do comply with + // the grammar, and as such in the following regex a-z cannot be matched as a range. + shouldBe(new RegExp(r"[\d-a-z]+").firstMatch("az1-3y"), ["az1-3"]); + + // An escaped hyphen should not be confused for an invalid range. + shouldBe(new RegExp(r"[\d\-x]+").firstMatch("1-3xy"), ["1-3x"]); + shouldBe(new RegExp(r"[x\-\d]+").firstMatch("1-3xy"), ["1-3x"]); + shouldBe(new RegExp(r"[\d\-\d]+").firstMatch("1-3xy"), ["1-3"]); + + // A hyphen after a character-class is not invalid. + shouldBe(new RegExp(r"[\d-]+").firstMatch("1-3xy"), ["1-3"]); +} diff --git a/tests/corelib/regexp/issue_19193_test.dart b/tests/corelib/regexp/issue_19193_test.dart new file mode 100644 index 00000000000..52746cf5b67 --- /dev/null +++ b/tests/corelib/regexp/issue_19193_test.dart @@ -0,0 +1,12 @@ +// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'package:expect/expect.dart'; + +// Regression test for http://dartbug.com/19193 +main() { + RegExp re = new RegExp(r'.*(a+)+\d'); + Expect.isTrue("a0aaaaaaaaaaaaa".contains(re)); + Expect.isTrue("a0aaaaaaaaaaaaaa".contains(re)); // false when using JSCRE. +} diff --git a/tests/corelib/regexp/lastindex_test.dart b/tests/corelib/regexp/lastindex_test.dart new file mode 100644 index 00000000000..fd574299c17 --- /dev/null +++ b/tests/corelib/regexp/lastindex_test.dart @@ -0,0 +1,44 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + // 'Test for regression against "https://bugs.webkit.org/show_bug.cgi?id=5602" + // REGRESSION: RegExp("[^\\s$]+", "g") returns extra matches' + + var re = new RegExp(r"[^\s$]+"); + var accumulate = ""; + var match; + for (var match in re.allMatches(" abcdefg")) + accumulate += match.group(0) + "; "; + assertEquals(accumulate, "abcdefg; "); + + re = new RegExp(r"\d"); + accumulate = ""; + for (var match in re.allMatches("123456789")) + accumulate += match.group(0) + "; "; + assertEquals(accumulate, "1; 2; 3; 4; 5; 6; 7; 8; 9; "); +} diff --git a/tests/corelib/regexp/look-ahead_test.dart b/tests/corelib/regexp/look-ahead_test.dart new file mode 100644 index 00000000000..56bead702f9 --- /dev/null +++ b/tests/corelib/regexp/look-ahead_test.dart @@ -0,0 +1,34 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + description( + 'Test for regression against Yarr Interpreter is crashing in some cases of look-ahead regex patterns'); + + shouldBe(firstMatch("ab", new RegExp(r"a(?=b|c)")), ["a"]); + shouldBe(firstMatch("abd", new RegExp(r"a(?=c|b)|d")), ["a"]); +} diff --git a/tests/corelib/regexp/lookahead_test.dart b/tests/corelib/regexp/lookahead_test.dart new file mode 100644 index 00000000000..2248d85e0cb --- /dev/null +++ b/tests/corelib/regexp/lookahead_test.dart @@ -0,0 +1,162 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2009 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + // Tests captures in positive and negative look-ahead in regular expressions. + + dynamic testRE(re, input, expected_result) { + if (expected_result) { + assertTrue(re.hasMatch(input)); + } else { + assertFalse(re.hasMatch(input)); + } + } + + dynamic execRE(re, input, expected_result) { + shouldBe(re.firstMatch(input), expected_result); + } + + // Test of simple positive lookahead. + + var re = new RegExp(r"^(?=a)"); + testRE(re, "a", true); + testRE(re, "b", false); + execRE(re, "a", [""]); + + re = new RegExp(r"^(?=\woo)f\w"); + testRE(re, "foo", true); + testRE(re, "boo", false); + testRE(re, "fao", false); + testRE(re, "foa", false); + execRE(re, "foo", ["fo"]); + + re = new RegExp(r"(?=\w).(?=\W)"); + testRE(re, ".a! ", true); + testRE(re, ".! ", false); + testRE(re, ".ab! ", true); + execRE(re, ".ab! ", ["b"]); + + re = new RegExp(r"(?=f(?=[^f]o)).."); + testRE(re, ", foo!", true); + testRE(re, ", fo!", false); + testRE(re, ", ffo", false); + execRE(re, ", foo!", ["fo"]); + + // Positive lookahead with captures. + re = new RegExp("^[^\'\"]*(?=([\'\"])).*\\1(\\w+)\\1"); + testRE(re, " 'foo' ", true); + testRE(re, ' "foo" ', true); + testRE(re, " \" 'foo' ", false); + testRE(re, " ' \"foo\" ", false); + testRE(re, " 'foo\" ", false); + testRE(re, " \"foo' ", false); + execRE(re, " 'foo' ", [" 'foo'", "'", "foo"]); + execRE(re, ' "foo" ', [' "foo"', '"', 'foo']); + + // Captures are cleared on backtrack past the look-ahead. + re = new RegExp(r"^(?:(?=(.))a|b)\1$"); + testRE(re, "aa", true); + testRE(re, "b", true); + testRE(re, "bb", false); + testRE(re, "a", false); + execRE(re, "aa", ["aa", "a"]); + execRE(re, "b", ["b", null]); + + re = new RegExp(r"^(?=(.)(?=(.)\1\2)\2\1)\1\2"); + testRE(re, "abab", true); + testRE(re, "ababxxxxxxxx", true); + testRE(re, "aba", false); + execRE(re, "abab", ["ab", "a", "b"]); + + re = new RegExp(r"^(?:(?=(.))a|b|c)$"); + testRE(re, "a", true); + testRE(re, "b", true); + testRE(re, "c", true); + testRE(re, "d", false); + execRE(re, "a", ["a", "a"]); + execRE(re, "b", ["b", null]); + execRE(re, "c", ["c", null]); + + execRE(new RegExp(r"^(?=(b))b"), "b", ["b", "b"]); + execRE(new RegExp(r"^(?:(?=(b))|a)b"), "ab", ["ab", null]); + execRE(new RegExp(r"^(?:(?=(b)(?:(?=(c))|d))|)bd"), "bd", ["bd", "b", null]); + + // Test of Negative Look-Ahead. + + re = new RegExp(r"(?!x)."); + testRE(re, "y", true); + testRE(re, "x", false); + execRE(re, "y", ["y"]); + + re = new RegExp(r"(?!(\d))|\d"); + testRE(re, "4", true); + execRE(re, "4", ["4", null]); + execRE(re, "x", ["", null]); + + // Test mixed nested look-ahead with captures. + + re = new RegExp(r"^(?=(x)(?=(y)))"); + testRE(re, "xy", true); + testRE(re, "xz", false); + execRE(re, "xy", ["", "x", "y"]); + + re = new RegExp(r"^(?!(x)(?!(y)))"); + testRE(re, "xy", true); + testRE(re, "xz", false); + execRE(re, "xy", ["", null, null]); + + re = new RegExp(r"^(?=(x)(?!(y)))"); + testRE(re, "xz", true); + testRE(re, "xy", false); + execRE(re, "xz", ["", "x", null]); + + re = new RegExp(r"^(?!(x)(?=(y)))"); + testRE(re, "xz", true); + testRE(re, "xy", false); + execRE(re, "xz", ["", null, null]); + + re = new RegExp(r"^(?=(x)(?!(y)(?=(z))))"); + testRE(re, "xaz", true); + testRE(re, "xya", true); + testRE(re, "xyz", false); + testRE(re, "a", false); + execRE(re, "xaz", ["", "x", null, null]); + execRE(re, "xya", ["", "x", null, null]); + + re = new RegExp(r"^(?!(x)(?=(y)(?!(z))))"); + testRE(re, "a", true); + testRE(re, "xa", true); + testRE(re, "xyz", true); + testRE(re, "xya", false); + execRE(re, "a", ["", null, null, null]); + execRE(re, "xa", ["", null, null, null]); + execRE(re, "xyz", ["", null, null, null]); +} diff --git a/tests/corelib/regexp/loop-capture_test.dart b/tests/corelib/regexp/loop-capture_test.dart new file mode 100644 index 00000000000..ee39410c880 --- /dev/null +++ b/tests/corelib/regexp/loop-capture_test.dart @@ -0,0 +1,36 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2009 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + shouldBe(new RegExp(r"(?:(a)|(b)|(c))+").firstMatch("abc"), + ["abc", null, null, "c"]); + shouldBe(new RegExp(r"(?:(a)|b)*").firstMatch("ab"), ["ab", null]); +} diff --git a/tests/corelib/regexp/malformed-escapes_test.dart b/tests/corelib/regexp/malformed-escapes_test.dart new file mode 100644 index 00000000000..dbf91267e5c --- /dev/null +++ b/tests/corelib/regexp/malformed-escapes_test.dart @@ -0,0 +1,59 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + description("This page tests handling of malformed escape sequences."); + + var regexp; + + regexp = new RegExp(r"\ug", multiLine: true); + shouldBeTrue(regexp.hasMatch('ug')); + + regexp = new RegExp(r"\xg", multiLine: true); + shouldBeTrue(regexp.hasMatch('xg')); + + regexp = new RegExp(r"\c_", multiLine: true); + shouldBeTrue(regexp.hasMatch('\\\\c_')); + + regexp = new RegExp(r"[\B]", multiLine: true); + shouldBeTrue(regexp.hasMatch('B')); + + regexp = new RegExp(r"[\b]", multiLine: true); + shouldBeTrue(regexp.hasMatch('\b')); + + regexp = new RegExp(r"\8", multiLine: true); + shouldBeTrue(regexp.hasMatch('\\\8')); + + regexp = new RegExp(r"^[\c]$"); + shouldBeTrue(regexp.hasMatch('c')); + + regexp = new RegExp(r"^[\c_]$"); + shouldBeFalse(regexp.hasMatch('c')); + + regexp = new RegExp(r"^[\c]]$"); + shouldBeTrue(regexp.hasMatch('c]')); +} diff --git a/tests/corelib/regexp/many-brackets_test.dart b/tests/corelib/regexp/many-brackets_test.dart new file mode 100644 index 00000000000..5c8777ff717 --- /dev/null +++ b/tests/corelib/regexp/many-brackets_test.dart @@ -0,0 +1,44 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + description( + 'Test regular expression processing with many capturing brackets (200).'); + + var count = 200; + + var regexp = ""; + for (var i = 0; i < count; ++i) regexp += "("; + regexp += "hello"; + for (var i = 0; i < count; ++i) regexp += ")"; + + var manyHellosArray = []; + for (var i = 0; i <= count; ++i) manyHellosArray.add("hello"); + + var manyBracketsRegExp = new RegExp(regexp); + shouldBe(firstMatch('hello', manyBracketsRegExp), manyHellosArray); +} diff --git a/tests/corelib/regexp/multiline_test.dart b/tests/corelib/regexp/multiline_test.dart new file mode 100644 index 00000000000..fd4b3403718 --- /dev/null +++ b/tests/corelib/regexp/multiline_test.dart @@ -0,0 +1,114 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2008 the V8 project authors. All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are +// met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above +// copyright notice, this list of conditions and the following +// disclaimer in the documentation and/or other materials provided +// with the distribution. +// * Neither the name of Google Inc. nor the names of its +// contributors may be used to endorse or promote products derived +// from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +/** + * @fileoverview Check that various regexp constructs work as intended. + * Particularly those regexps that use ^ and $. + */ + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + assertTrue(new RegExp(r"^bar").hasMatch("bar")); + assertTrue(new RegExp(r"^bar").hasMatch("bar\nfoo")); + assertFalse(new RegExp(r"^bar").hasMatch("foo\nbar")); + assertTrue(new RegExp(r"^bar", multiLine: true).hasMatch("bar")); + assertTrue(new RegExp(r"^bar", multiLine: true).hasMatch("bar\nfoo")); + assertTrue(new RegExp(r"^bar", multiLine: true).hasMatch("foo\nbar")); + + assertTrue(new RegExp(r"bar$").hasMatch("bar")); + assertFalse(new RegExp(r"bar$").hasMatch("bar\nfoo")); + assertTrue(new RegExp(r"bar$").hasMatch("foo\nbar")); + assertTrue(new RegExp(r"bar$", multiLine: true).hasMatch("bar")); + assertTrue(new RegExp(r"bar$", multiLine: true).hasMatch("bar\nfoo")); + assertTrue(new RegExp(r"bar$", multiLine: true).hasMatch("foo\nbar")); + + assertFalse(new RegExp(r"^bxr").hasMatch("bar")); + assertFalse(new RegExp(r"^bxr").hasMatch("bar\nfoo")); + assertFalse(new RegExp(r"^bxr", multiLine: true).hasMatch("bar")); + assertFalse(new RegExp(r"^bxr", multiLine: true).hasMatch("bar\nfoo")); + assertFalse(new RegExp(r"^bxr", multiLine: true).hasMatch("foo\nbar")); + + assertFalse(new RegExp(r"bxr$").hasMatch("bar")); + assertFalse(new RegExp(r"bxr$").hasMatch("foo\nbar")); + assertFalse(new RegExp(r"bxr$", multiLine: true).hasMatch("bar")); + assertFalse(new RegExp(r"bxr$", multiLine: true).hasMatch("bar\nfoo")); + assertFalse(new RegExp(r"bxr$", multiLine: true).hasMatch("foo\nbar")); + + assertTrue(new RegExp(r"^.*$").hasMatch("")); + assertTrue(new RegExp(r"^.*$").hasMatch("foo")); + assertFalse(new RegExp(r"^.*$").hasMatch("\n")); + assertTrue(new RegExp(r"^.*$", multiLine: true).hasMatch("\n")); + + assertTrue(new RegExp(r"^[\s]*$").hasMatch(" ")); + assertTrue(new RegExp(r"^[\s]*$").hasMatch("\n")); + + assertTrue(new RegExp(r"^[^]*$").hasMatch("")); + assertTrue(new RegExp(r"^[^]*$").hasMatch("foo")); + assertTrue(new RegExp(r"^[^]*$").hasMatch("\n")); + + assertTrue(new RegExp(r"^([()\s]|.)*$").hasMatch("()\n()")); + assertTrue(new RegExp(r"^([()\n]|.)*$").hasMatch("()\n()")); + assertFalse(new RegExp(r"^([()]|.)*$").hasMatch("()\n()")); + assertTrue(new RegExp(r"^([()]|.)*$", multiLine: true).hasMatch("()\n()")); + assertTrue(new RegExp(r"^([()]|.)*$", multiLine: true).hasMatch("()\n")); + assertTrue(new RegExp(r"^[()]*$", multiLine: true).hasMatch("()\n.")); + + assertTrue(new RegExp(r"^[\].]*$").hasMatch("...]...")); + + dynamic check_case(lc, uc) { + var a = new RegExp("^" + lc + r"$"); + assertFalse(a.hasMatch(uc)); + a = new RegExp("^" + lc + r"$", caseSensitive: false); + assertTrue(a.hasMatch(uc)); + + var A = new RegExp("^" + uc + r"$"); + assertFalse(A.hasMatch(lc)); + A = new RegExp("^" + uc + r"$", caseSensitive: false); + assertTrue(A.hasMatch(lc)); + + a = new RegExp("^[" + lc + r"]$"); + assertFalse(a.hasMatch(uc)); + a = new RegExp("^[" + lc + r"]$", caseSensitive: false); + assertTrue(a.hasMatch(uc)); + + A = new RegExp("^[" + uc + r"]$"); + assertFalse(A.hasMatch(lc)); + A = new RegExp("^[" + uc + r"]$", caseSensitive: false); + assertTrue(A.hasMatch(lc)); + } + + check_case("a", "A"); + // Aring + check_case(new String.fromCharCode(229), new String.fromCharCode(197)); + // Russian G + check_case(new String.fromCharCode(0x413), new String.fromCharCode(0x433)); + + assertThrows(() => new RegExp('[z-a]')); +} diff --git a/tests/corelib/regexp/negative-special-characters_test.dart b/tests/corelib/regexp/negative-special-characters_test.dart new file mode 100644 index 00000000000..2c673b156e5 --- /dev/null +++ b/tests/corelib/regexp/negative-special-characters_test.dart @@ -0,0 +1,95 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + description("This test checks Unicode in negative RegExp character classes."); + + dynamic testPassed(str) {} + dynamic testFailed(str) => Expect.fail(str); + + dynamic test(pattern, str, expected_length) { + var result = str.replaceAll( + new RegExp(pattern, caseSensitive: false, multiLine: true), ''); + + if (result.length == expected_length) + testPassed('"' + pattern + '", ' + '"' + str + '".'); + else + testFailed( + '"' + pattern + '", ' + '"' + str + '". Was "' + result + '".'); + } + + test("\\s", " \t\f\v\r\n", 0); // ASCII whitespace. + test("\\S", "Проверка", 0); // Cyrillic letters are non-whitespace... + test("\\s", "Проверка", 8); // ...and they aren't whitespace. + test("[\\s]", "Проверка", 8); + test("[\\S]", "Проверка", 0); + test("[^\\s]", "Проверка", 0); + test("[^\\S]", "Проверка", 8); + test("[\\s\\S]*", "\\u2002Проверка\\r\\n\\u00a0", 0); + test("\\S\\S", "уф", 0); + test("\\S{2}", "уф", 0); + + test("\\w", "Проверка", + 8); // Alas, only ASCII characters count as word ones in JS. + test("\\W", "Проверка", 0); + test("[\\w]", "Проверка", 8); + test("[\\W]", "Проверка", 0); + test("[^\\w]", "Проверка", 0); + test("[^\\W]", "Проверка", 8); + test("\\W\\W", "уф", 0); + test("\\W{2}", "уф", 0); + + test("\\d", "Проверка", 8); // Digit and non-digit. + test("\\D", "Проверка", 0); + test("[\\d]", "Проверка", 8); + test("[\\D]", "Проверка", 0); + test("[^\\d]", "Проверка", 0); + test("[^\\D]", "Проверка", 8); + test("\\D\\D", "уф", 0); + test("\\D{2}", "уф", 0); + + test("[\\S\\d]", "Проверка123", 0); + test("[\\d\\S]", "Проверка123", 0); + test("[^\\S\\d]", "Проверка123", 11); + test("[^\\d\\S]", "Проверка123", 11); + + test("[ \\S]", " Проверка ", 0); + test("[\\S ]", " Проверка ", 0); + test("[ф \\S]", " Проверка ", 0); + test("[\\Sф ]", " Проверка ", 0); + + test("[^р\\S]", " Проверка ", 8); + test("[^\\Sр]", " Проверка ", 8); + test("[^р\\s]", " Проверка ", 4); + test("[^\\sр]", " Проверка ", 4); + + test("[ф \\s\\S]", "Проверка \\r\\n", 0); + test("[\\S\\sф ]", "Проверка \\r\\n", 0); + + test("[^z]", "Проверка \\r\\n", 0); + test("[^ф]", "Проверка \\r\\n", 0); +} diff --git a/tests/corelib/regexp/no-extensions_test.dart b/tests/corelib/regexp/no-extensions_test.dart new file mode 100644 index 00000000000..131d250627e --- /dev/null +++ b/tests/corelib/regexp/no-extensions_test.dart @@ -0,0 +1,94 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + description( + 'Tests that regular expressions do not have extensions that diverge from the JavaScript specification. ' + + 'Because WebKit originally used a copy of PCRE, various non-JavaScript regular expression features were historically present. ' + + 'Also tests various related edge cases.'); + + shouldBeNull(new RegExp(r"\\x{41}").firstMatch("yA1")); + assertEquals(new RegExp(r"[\x{41}]").firstMatch("yA1").group(0), "1"); + assertEquals(new RegExp(r"\x1g").firstMatch("x1g").group(0), "x1g"); + assertEquals(new RegExp(r"[\x1g]").firstMatch("x").group(0), "x"); + assertEquals(new RegExp(r"[\x1g]").firstMatch("1").group(0), "1"); + assertEquals( + new RegExp(r"\2147483648") + .firstMatch(new String.fromCharCode(140) + "7483648") + .group(0), + new String.fromCharCode(140) + "7483648"); + assertEquals(new RegExp(r"\4294967296").firstMatch("\"94967296").group(0), + "\"94967296"); + assertEquals(new RegExp(r"\8589934592").firstMatch("\8589934592").group(0), + "\8589934592"); + assertEquals( + "\nAbc\n".replaceAllMapped(new RegExp(r"(\n)[^\n]+$"), (m) => m.group(1)), + "\nAbc\n"); + shouldBeNull(new RegExp(r"x$").firstMatch("x\n")); + assertThrows(() => new RegExp(r"x++")); + shouldBeNull(new RegExp(r"[]]").firstMatch("]")); + + assertEquals(new RegExp(r"\060").firstMatch("y01").group(0), "0"); + assertEquals(new RegExp(r"[\060]").firstMatch("y01").group(0), "0"); + assertEquals(new RegExp(r"\606").firstMatch("y06").group(0), "06"); + assertEquals(new RegExp(r"[\606]").firstMatch("y06").group(0), "0"); + assertEquals(new RegExp(r"[\606]").firstMatch("y6").group(0), "6"); + assertEquals(new RegExp(r"\101").firstMatch("yA1").group(0), "A"); + assertEquals(new RegExp(r"[\101]").firstMatch("yA1").group(0), "A"); + assertEquals(new RegExp(r"\1011").firstMatch("yA1").group(0), "A1"); + assertEquals(new RegExp(r"[\1011]").firstMatch("yA1").group(0), "A"); + assertEquals(new RegExp(r"[\1011]").firstMatch("y1").group(0), "1"); + assertEquals( + new RegExp(r"\10q") + .firstMatch("y" + new String.fromCharCode(8) + "q") + .group(0), + new String.fromCharCode(8) + "q"); + assertEquals( + new RegExp(r"[\10q]") + .firstMatch("y" + new String.fromCharCode(8) + "q") + .group(0), + new String.fromCharCode(8)); + assertEquals( + new RegExp(r"\1q") + .firstMatch("y" + new String.fromCharCode(1) + "q") + .group(0), + new String.fromCharCode(1) + "q"); + assertEquals( + new RegExp(r"[\1q]") + .firstMatch("y" + new String.fromCharCode(1) + "q") + .group(0), + new String.fromCharCode(1)); + assertEquals(new RegExp(r"[\1q]").firstMatch("yq").group(0), "q"); + assertEquals(new RegExp(r"\8q").firstMatch("\8q").group(0), "\8q"); + assertEquals(new RegExp(r"[\8q]").firstMatch("y8q").group(0), "8"); + assertEquals(new RegExp(r"[\8q]").firstMatch("yq").group(0), "q"); + shouldBe(new RegExp(r"(x)\1q").firstMatch("xxq"), ["xxq", "x"]); + shouldBe(new RegExp(r"(x)[\1q]").firstMatch("xxq"), ["xq", "x"]); + shouldBe( + new RegExp(r"(x)[\1q]").firstMatch("xx" + new String.fromCharCode(1)), + ["x" + new String.fromCharCode(1), "x"]); +} diff --git a/tests/corelib/regexp/non-bmp_test.dart b/tests/corelib/regexp/non-bmp_test.dart new file mode 100644 index 00000000000..9849bba321f --- /dev/null +++ b/tests/corelib/regexp/non-bmp_test.dart @@ -0,0 +1,51 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + description('Tests that regular expressions treat non-BMP characters as two separate characters. ' + + 'From a Unicode correctness point of view this is wrong, but it is what other browsers do. ' + + 'And given that we store strings as UTF-16, it is also more efficient to implement. ' + + 'Also test some other cases related to UTF-8 and UTF-16.'); + + var surrogatePair = + new String.fromCharCode(0xD800) + new String.fromCharCode(0xDC00); + + assertEquals(new RegExp(r".").firstMatch(surrogatePair).group(0).length, 1); + assertEquals(new RegExp(r"\D").firstMatch(surrogatePair).group(0).length, 1); + assertEquals(new RegExp(r"\S").firstMatch(surrogatePair).group(0).length, 1); + assertEquals(new RegExp(r"\W").firstMatch(surrogatePair).group(0).length, 1); + assertEquals( + new RegExp(r"[^x]").firstMatch(surrogatePair).group(0).length, 1); + + assertEquals( + new RegExp(r".{1,2}") + .firstMatch("!!" + new String.fromCharCode(0xA1)) + .group(0) + .length, + 2); + shouldBeNull(new RegExp(r".").firstMatch("")); +} diff --git a/tests/corelib/regexp/non-capturing-backtracking_test.dart b/tests/corelib/regexp/non-capturing-backtracking_test.dart new file mode 100644 index 00000000000..68c2dc23884 --- /dev/null +++ b/tests/corelib/regexp/non-capturing-backtracking_test.dart @@ -0,0 +1,34 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + description( + "This page tests for proper backtracking with greedy quantifiers and non-capturing parentheses."); + + var re = new RegExp(r"(?:a*)a"); + shouldBe(re.firstMatch('a'), ['a']); +} diff --git a/tests/corelib/regexp/non-capturing-groups_test.dart b/tests/corelib/regexp/non-capturing-groups_test.dart new file mode 100644 index 00000000000..33a83835c27 --- /dev/null +++ b/tests/corelib/regexp/non-capturing-groups_test.dart @@ -0,0 +1,49 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + description( + 'Test for behavior of non-capturing groups, as described in ' + + 'a blog post by Steven Levithan and bug 14931.'); + + shouldBeTrue(new RegExp(r"(x)?\1y").hasMatch("y")); + shouldBe(new RegExp(r"(x)?\1y").firstMatch("y"), ["y", null]); + shouldBe(new RegExp(r"(x)?y").firstMatch("y"), ["y", null]); + shouldBe(firstMatch("y", new RegExp(r"(x)?\1y")), ["y", null]); + shouldBe(firstMatch("y", new RegExp(r"(x)?y")), ["y", null]); + shouldBe(firstMatch("y", new RegExp(r"(x)?\1y")), ["y", null]); + Expect.listEquals("y".split(new RegExp(r"(x)?\1y")), ["", ""]); + Expect.listEquals("y".split(new RegExp(r"(x)?y")), ["", ""]); + assertEquals("y".indexOf(new RegExp(r"(x)?\1y")), 0); + assertEquals("y".replaceAll(new RegExp(r"(x)?\1y"), "z"), "z"); + assertEquals( + "y".replaceAllMapped(new RegExp(r"(x)?y"), (m) => m.group(1)), "null"); + assertEquals( + "y".replaceAllMapped(new RegExp(r"(x)?\1y"), (m) => m.group(1)), "null"); + assertEquals( + "y".replaceAllMapped(new RegExp(r"(x)?y"), (m) => m.group(1)), "null"); +} diff --git a/tests/corelib/regexp/non-character_test.dart b/tests/corelib/regexp/non-character_test.dart new file mode 100644 index 00000000000..5afcd94a020 --- /dev/null +++ b/tests/corelib/regexp/non-character_test.dart @@ -0,0 +1,46 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + description( + 'Test for regular expressions with non-character values in them, specifically in character classes.'); + + shouldBeNull(firstMatch("F", new RegExp(r"[\uD7FF]"))); + shouldBeNull(firstMatch("0", new RegExp(r"[\uD800]"))); + shouldBeNull(firstMatch("F", new RegExp(r"[\uDFFF]"))); + shouldBeNull(firstMatch("E", new RegExp(r"[\uE000]"))); + shouldBeNull(firstMatch("y", new RegExp(r"[\uFDBF]"))); + shouldBeNull(firstMatch("y", new RegExp(r"[\uFDD0]"))); + shouldBeNull(firstMatch("y", new RegExp(r"[\uFDEF]"))); + shouldBeNull(firstMatch("y", new RegExp(r"[\uFDF0]"))); + shouldBeNull(firstMatch("y", new RegExp(r"[\uFEFF]"))); + shouldBeNull(firstMatch("y", new RegExp(r"[\uFEFF]"))); + shouldBeNull(firstMatch("y", new RegExp(r"[\uFFFE]"))); + shouldBeNull(firstMatch("y", new RegExp(r"[\uFFFF]"))); + shouldBeNull(firstMatch("y", new RegExp(r"[\u10FFFF]"))); + shouldBeNull(firstMatch("y", new RegExp(r"[\u110000]"))); +} diff --git a/tests/corelib/regexp/non-greedy-parentheses_test.dart b/tests/corelib/regexp/non-greedy-parentheses_test.dart new file mode 100644 index 00000000000..4c85a3ac734 --- /dev/null +++ b/tests/corelib/regexp/non-greedy-parentheses_test.dart @@ -0,0 +1,41 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + description( + 'Test for regression against Wrong result in case of non-iterative matching of subpatterns in non-greedy cases in YARR Interpreter'); + + shouldBe(firstMatch("a", new RegExp(r"(a)??")), ["", null]); + shouldBe(firstMatch("b", new RegExp(r"(a)??")), ["", null]); + shouldBe(firstMatch("ab", new RegExp(r"(a)??b")), ["ab", "a"]); + shouldBe(firstMatch("aaab", new RegExp(r"(a+)??b")), ["aaab", "aaa"]); + shouldBe( + firstMatch("abbc", new RegExp(r"(a)??(b+)??c")), ["abbc", "a", "bb"]); + shouldBe(firstMatch("ac", new RegExp(r"(a)??(b)??c")), ["ac", "a", null]); + shouldBe(firstMatch("abc", new RegExp(r"(a(b)??)??c")), ["abc", "ab", "b"]); + shouldBe(firstMatch("ac", new RegExp(r"(a(b)??)??c")), ["ac", "a", null]); +} diff --git a/tests/corelib/regexp/norepeat_test.dart b/tests/corelib/regexp/norepeat_test.dart new file mode 100644 index 00000000000..f0f8cc34636 --- /dev/null +++ b/tests/corelib/regexp/norepeat_test.dart @@ -0,0 +1,34 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + description('Test for https://bugs.webkit.org/show_bug.cgi?id=46077'); + + var re = new RegExp(r"^b|^cd"); + var str = "abcd"; + shouldBeFalse(re.hasMatch(str)); +} diff --git a/tests/corelib/regexp/overflow_test.dart b/tests/corelib/regexp/overflow_test.dart new file mode 100644 index 00000000000..42523d007fe --- /dev/null +++ b/tests/corelib/regexp/overflow_test.dart @@ -0,0 +1,45 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + description( + "This test checks expressions with alternative lengths of appox. 2^31."); + + var regexp1 = new RegExp(r"(?:(?=g))|(?:m).{2147483648,}"); + shouldBeNull(regexp1.firstMatch('')); + + var regexp2 = new RegExp(r"(?:(?=g)).{2147483648,}"); + shouldBeNull(regexp2.firstMatch('')); + + var s3 = + r"&{6}u4a64YfQP{C}u88c4u5772Qu8693{4294967167}u85f2u7f3fs((uf202){4})u5bc6u1947"; + var regexp3 = new RegExp(s3); + shouldBeNull(regexp3.firstMatch(s3)); + + var regexp4 = new RegExp(r"[^a$]{4294967295}"); + shouldBeNull(regexp4.firstMatch(s3)); +} diff --git a/tests/corelib/regexp/parentheses_test.dart b/tests/corelib/regexp/parentheses_test.dart new file mode 100644 index 00000000000..340416ece6f --- /dev/null +++ b/tests/corelib/regexp/parentheses_test.dart @@ -0,0 +1,358 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + description("This page tests handling of parentheses subexpressions."); + + var regexp1 = new RegExp(r"(a|A)(b|B)"); + shouldBe(regexp1.firstMatch('abc'), ['ab', 'a', 'b']); + + var regexp2 = new RegExp(r"(a((b)|c|d))e"); + shouldBe(regexp2.firstMatch('abacadabe'), ['abe', 'ab', 'b', 'b']); + + var regexp3 = new RegExp(r"(a(b|(c)|d))e"); + shouldBe(regexp3.firstMatch('abacadabe'), ['abe', 'ab', 'b', null]); + + var regexp4 = new RegExp(r"(a(b|c|(d)))e"); + shouldBe(regexp4.firstMatch('abacadabe'), ['abe', 'ab', 'b', null]); + + var regexp5 = new RegExp(r"(a((b)|(c)|(d)))e"); + shouldBe( + regexp5.firstMatch('abacadabe'), ['abe', 'ab', 'b', 'b', null, null]); + + var regexp6 = new RegExp(r"(a((b)|(c)|(d)))"); + shouldBe(regexp6.firstMatch('abcde'), ['ab', 'ab', 'b', 'b', null, null]); + + var regexp7 = new RegExp(r"(a(b)??)??c"); + shouldBe(regexp7.firstMatch('abc'), ['abc', 'ab', 'b']); + + var regexp8 = new RegExp(r"(a|(e|q))(x|y)"); + shouldBe(regexp8.firstMatch('bcaddxqy'), ['qy', 'q', 'q', 'y']); + + var regexp9 = new RegExp(r"((t|b)?|a)$"); + shouldBe( + regexp9.firstMatch('asdfjejgsdflaksdfjkeljghkjea'), ['a', 'a', null]); + + var regexp10 = new RegExp(r"(?:h|e?(?:t|b)?|a?(?:t|b)?)(?:$)"); + shouldBe(regexp10.firstMatch('asdfjejgsdflaksdfjkeljghat'), ['at']); + + var regexp11 = new RegExp(r"([Jj]ava([Ss]cript)?)\sis\s(fun\w*)"); + shouldBeNull(regexp11.firstMatch( + 'Developing with JavaScript is dangerous, do not try it without assistance')); + + var regexp12 = new RegExp(r"(?:(.+), )?(.+), (..) to (?:(.+), )?(.+), (..)"); + shouldBe(regexp12.firstMatch('Seattle, WA to Buckley, WA'), [ + 'Seattle, WA to Buckley, WA', + null, + 'Seattle', + 'WA', + null, + 'Buckley', + 'WA' + ]); + + var regexp13 = new RegExp(r"(A)?(A.*)"); + shouldBe(regexp13.firstMatch('zxcasd;fl\ ^AaaAAaaaf;lrlrzs'), + ['AaaAAaaaf;lrlrzs', null, 'AaaAAaaaf;lrlrzs']); + + var regexp14 = new RegExp(r"(a)|(b)"); + shouldBe(regexp14.firstMatch('b'), ['b', null, 'b']); + + var regexp15 = new RegExp(r"^(?!(ab)de|x)(abd)(f)"); + shouldBe(regexp15.firstMatch('abdf'), ['abdf', null, 'abd', 'f']); + + var regexp16 = new RegExp(r"(a|A)(b|B)"); + shouldBe(regexp16.firstMatch('abc'), ['ab', 'a', 'b']); + + var regexp17 = new RegExp(r"(a|d|q|)x", caseSensitive: false); + shouldBe(regexp17.firstMatch('bcaDxqy'), ['Dx', 'D']); + + var regexp18 = new RegExp(r"^.*?(:|$)"); + shouldBe(regexp18.firstMatch('Hello: World'), ['Hello:', ':']); + + var regexp19 = new RegExp(r"(ab|^.{0,2})bar"); + shouldBe(regexp19.firstMatch('barrel'), ['bar', '']); + + var regexp20 = new RegExp(r"(?:(?!foo)...|^.{0,2})bar(.*)"); + shouldBe(regexp20.firstMatch('barrel'), ['barrel', 'rel']); + shouldBe(regexp20.firstMatch('2barrel'), ['2barrel', 'rel']); + + var regexp21 = new RegExp(r"([a-g](b|B)|xyz)"); + shouldBe(regexp21.firstMatch('abc'), ['ab', 'ab', 'b']); + + var regexp22 = new RegExp(r"(?:^|;)\s*abc=([^;]*)"); + shouldBeNull(regexp22.firstMatch('abcdlskfgjdslkfg')); + + var regexp23 = new RegExp("\"[^<\"]*\"|'[^<']*'"); + shouldBe(regexp23.firstMatch('"\'\s]*)?)|(/?>)|.[^\w\s>]*)'); + shouldBe(regexp33.firstMatch('> '), ['>', null, null, '>']); + + var regexp34 = new RegExp(r"(?:^|\b)btn-\S+"); + shouldBeNull(regexp34.firstMatch('xyz123')); + shouldBe(regexp34.firstMatch('btn-abc'), ['btn-abc']); + shouldBeNull(regexp34.firstMatch('btn- abc')); + shouldBeNull(regexp34.firstMatch('XXbtn-abc')); + shouldBe(regexp34.firstMatch('XX btn-abc'), ['btn-abc']); + + var regexp35 = new RegExp(r"^((a|b)(x|xxx)|)$"); + shouldBe(regexp35.firstMatch('ax'), ['ax', 'ax', 'a', 'x']); + shouldBeNull(regexp35.firstMatch('axx')); + shouldBe(regexp35.firstMatch('axxx'), ['axxx', 'axxx', 'a', 'xxx']); + shouldBe(regexp35.firstMatch('bx'), ['bx', 'bx', 'b', 'x']); + shouldBeNull(regexp35.firstMatch('bxx')); + shouldBe(regexp35.firstMatch('bxxx'), ['bxxx', 'bxxx', 'b', 'xxx']); + + var regexp36 = new RegExp(r"^((\/|\.|\-)(\d\d|\d\d\d\d)|)$"); + shouldBe(regexp36.firstMatch('/2011'), ['/2011', '/2011', '/', '2011']); + shouldBe(regexp36.firstMatch('/11'), ['/11', '/11', '/', '11']); + shouldBeNull(regexp36.firstMatch('/123')); + + var regexp37 = new RegExp( + r"^([1][0-2]|[0]\d|\d)(\/|\.|\-)([0-2]\d|[3][0-1]|\d)((\/|\.|\-)(\d\d|\d\d\d\d)|)$"); + shouldBe(regexp37.firstMatch('7/4/1776'), + ['7/4/1776', '7', '/', '4', '/1776', '/', '1776']); + shouldBe(regexp37.firstMatch('07-04-1776'), + ['07-04-1776', '07', '-', '04', '-1776', '-', '1776']); + + var regexp38 = new RegExp(r"^(z|(x|xx)|b|)$"); + shouldBe(regexp38.firstMatch('xx'), ['xx', 'xx', 'xx']); + shouldBe(regexp38.firstMatch('b'), ['b', 'b', null]); + shouldBe(regexp38.firstMatch('z'), ['z', 'z', null]); + shouldBe(regexp38.firstMatch(''), ['', '', null]); + + var regexp39 = new RegExp(r"(8|((?=P)))?"); + shouldBe(regexp39.firstMatch(''), ['', null, null]); + shouldBe(regexp39.firstMatch('8'), ['8', '8', null]); + shouldBe(regexp39.firstMatch('zP'), ['', null, null]); + + var regexp40 = new RegExp(r"((8)|((?=P){4}))?()"); + shouldBe(regexp40.firstMatch(''), ['', null, null, null, '']); + shouldBe(regexp40.firstMatch('8'), ['8', '8', '8', null, '']); + shouldBe(regexp40.firstMatch('zPz'), ['', null, null, null, '']); + shouldBe(regexp40.firstMatch('zPPz'), ['', null, null, null, '']); + shouldBe(regexp40.firstMatch('zPPPz'), ['', null, null, null, '']); + shouldBe(regexp40.firstMatch('zPPPPz'), ['', null, null, null, '']); + + var regexp41 = new RegExp( + r"(([\w\-]+:\/\/?|www[.])[^\s()<>]+(?:([\w\d]+)|([^\[:punct:\]\s()<>\W]|\/)))"); + shouldBe( + regexp41.firstMatch( + 'Here is a link: http://www.acme.com/our_products/index.html. That is all we want!'), + [ + 'http://www.acme.com/our_products/index.html', + 'http://www.acme.com/our_products/index.html', + 'http://', + 'l', + null + ]); + + var regexp42 = new RegExp(r"((?:(4)?))?"); + shouldBe(regexp42.firstMatch(''), ['', null, null]); + shouldBe(regexp42.firstMatch('4'), ['4', '4', '4']); + shouldBe(regexp42.firstMatch('4321'), ['4', '4', '4']); + + shouldBeTrue(new RegExp(r"(?!(?=r{0}){2,})|((z)?)?", caseSensitive: false) + .hasMatch('')); + + var regexp43 = new RegExp(r"(?!(?:\1+s))"); + shouldBe(regexp43.firstMatch('SSS'), ['']); + + var regexp44 = new RegExp(r"(?!(?:\3+(s+?)))"); + shouldBe(regexp44.firstMatch('SSS'), ['', null]); + + var regexp45 = new RegExp(r"((?!(?:|)v{2,}|))"); + shouldBeNull(regexp45.firstMatch('vt')); + + var regexp46 = new RegExp(r"(w)(?:5{3}|())|pk"); + shouldBeNull(regexp46.firstMatch('5')); + shouldBe(regexp46.firstMatch('pk'), ['pk', null, null]); + shouldBe(regexp46.firstMatch('Xw555'), ['w555', 'w', null]); + shouldBe(regexp46.firstMatch('Xw55pk5'), ['w', 'w', '']); + + var regexp47 = new RegExp(r"(.*?)(?:(?:\?(.*?)?)?)(?:(?:#)?)$"); + shouldBe(regexp47.firstMatch('/www.acme.com/this/is/a/path/file.txt'), [ + '/www.acme.com/this/is/a/path/file.txt', + '/www.acme.com/this/is/a/path/file.txt', + null + ]); + + var regexp48 = new RegExp( + r"^(?:(\w+):\/*([\w\.\-\d]+)(?::(\d+)|)(?=(?:\/|$))|)(?:$|\/?(.*?)(?:\?(.*?)?|)(?:#(.*)|)$)"); + shouldBe(regexp48.firstMatch('http://www.acme.com/this/is/a/path/file.txt'), [ + 'http://www.acme.com/this/is/a/path/file.txt', + 'http', + 'www.acme.com', + null, + 'this/is/a/path/file.txt', + null, + null + ]); + + var regexp49 = new RegExp( + r"(?:([^:]*?)(?:(?:\?(.*?)?)?)(?:(?:#)?)$)|(?:^(?:(\w+):\/*([\w\.\-\d]+)(?::(\d+)|)(?=(?:\/|$))|)(?:$|\/?(.*?)(?:\?(.*?)?|)(?:#(.*)|)$))"); + shouldBe(regexp49.firstMatch('http://www.acme.com/this/is/a/path/file.txt'), [ + 'http://www.acme.com/this/is/a/path/file.txt', + null, + null, + 'http', + 'www.acme.com', + null, + 'this/is/a/path/file.txt', + null, + null + ]); + + var regexp50 = new RegExp(r"((a)b{28,}c|d)x"); + shouldBeNull(regexp50.firstMatch('((a)b{28,}c|d)x')); + shouldBe(regexp50.firstMatch('abbbbbbbbbbbbbbbbbbbbbbbbbbbbcx'), [ + 'abbbbbbbbbbbbbbbbbbbbbbbbbbbbcx', + 'abbbbbbbbbbbbbbbbbbbbbbbbbbbbc', + 'a' + ]); + shouldBe(regexp50.firstMatch('dx'), ['dx', 'd', null]); + + var s = "((.\s{-}).{28,}\P{Yi}?{,30}\|.)\x9e{-,}\P{Any}"; + var regexp51 = new RegExp(s); + shouldBeNull(regexp51.firstMatch('abc')); + shouldBe(regexp51.firstMatch(s), [')\x9e{-,}P{Any}', ')', null]); + + var regexp52 = new RegExp(r"(Rob)|(Bob)|(Robert)|(Bobby)"); + shouldBe(regexp52.firstMatch('Hi Bob'), ['Bob', null, 'Bob', null, null]); + + // Test cases discovered by fuzzing that crashed the compiler. + var regexp53 = new RegExp( + r"(?=(?:(?:(gB)|(?!cs|<))((?=(?!v6){0,})))|(?=#)+?)", + multiLine: true); + shouldBe(regexp53.firstMatch('#'), ['', null, '']); + var regexp54 = new RegExp(r"((?:(?:()|(?!))((?=(?!))))|())", multiLine: true); + shouldBe(regexp54.firstMatch('#'), ['', '', null, null, '']); + var regexp55 = new RegExp(r"(?:(?:(?:a?|(?:))((?:)))|a?)", multiLine: true); + shouldBe(regexp55.firstMatch('#'), ['', '']); + + // Test evaluation order of empty subpattern alternatives. + var regexp56 = new RegExp(r"(|a)"); + shouldBe(regexp56.firstMatch('a'), ['', '']); + var regexp57 = new RegExp(r"(a|)"); + shouldBe(regexp57.firstMatch('a'), ['a', 'a']); + + // Tests that non-greedy repeat quantified parentheses will backtrack through multiple frames of subpattern matches. + var regexp58 = new RegExp(r"a|b(?:[^b])*?c"); + shouldBe(regexp58.firstMatch('badbc'), ['a']); + var regexp59 = new RegExp(r"(X(?:.(?!X))*?Y)|(Y(?:.(?!Y))*?Z)"); + Expect.listEquals( + regexp59 + .allMatches('Y aaa X Match1 Y aaa Y Match2 Z') + .map((m) => m.group(0)) + .toList(), + ['X Match1 Y', 'Y Match2 Z']); +} diff --git a/tests/corelib/regexp/pcre-test-4_test.dart b/tests/corelib/regexp/pcre-test-4_test.dart new file mode 100644 index 00000000000..80745d173a2 --- /dev/null +++ b/tests/corelib/regexp/pcre-test-4_test.dart @@ -0,0 +1,1031 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Copyright 2013 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + description( + "A chunk of our port of PCRE's test suite, adapted to be more applicable to JavaScript."); + + var regex0 = new RegExp(r"a.b"); + var input0 = "acb"; + var results = ["acb"]; + shouldBe(regex0.firstMatch(input0), results); + var input1 = "a\x7fb"; + results = ["a\u007fb"]; + shouldBe(regex0.firstMatch(input1), results); + var input2 = "a\u0100b"; + results = ["a\u0100b"]; + shouldBe(regex0.firstMatch(input2), results); + // Failers + var input3 = "a\nb"; + results = null; + shouldBe(regex0.firstMatch(input3), results); + + var regex1 = new RegExp(r"a(.{3})b"); + input0 = "a\u4000xyb"; + results = ["a\u4000xyb", "\u4000xy"]; + shouldBe(regex1.firstMatch(input0), results); + input1 = "a\u4000\x7fyb"; + results = ["a\u4000\u007fyb", "\u4000\u007fy"]; + shouldBe(regex1.firstMatch(input1), results); + input2 = "a\u4000\u0100yb"; + results = ["a\u4000\u0100yb", "\u4000\u0100y"]; + shouldBe(regex1.firstMatch(input2), results); + // Failers + input3 = "a\u4000b"; + results = null; + shouldBe(regex1.firstMatch(input3), results); + var input4 = "ac\ncb"; + results = null; + shouldBe(regex1.firstMatch(input4), results); + + var regex2 = new RegExp(r"a(.*?)(.)"); + input0 = "a\xc0\x88b"; + results = ["a\xc0", "", "\xc0"]; + shouldBe(regex2.firstMatch(input0), results); + + var regex3 = new RegExp(r"a(.*?)(.)"); + input0 = "a\u0100b"; + results = ["a\u0100", "", "\u0100"]; + shouldBe(regex3.firstMatch(input0), results); + + var regex4 = new RegExp(r"a(.*)(.)"); + input0 = "a\xc0\x88b"; + results = ["a\xc0\x88b", "\xc0\x88", "b"]; + shouldBe(regex4.firstMatch(input0), results); + + var regex5 = new RegExp(r"a(.*)(.)"); + input0 = "a\u0100b"; + results = ["a\u0100b", "\u0100", "b"]; + shouldBe(regex5.firstMatch(input0), results); + + var regex6 = new RegExp(r"a(.)(.)"); + input0 = "a\xc0\x92bcd"; + results = ["a\xc0\x92", "\xc0", "\x92"]; + shouldBe(regex6.firstMatch(input0), results); + + var regex7 = new RegExp(r"a(.)(.)"); + input0 = "a\u0240bcd"; + results = ["a\u0240b", "\u0240", "b"]; + shouldBe(regex7.firstMatch(input0), results); + + var regex8 = new RegExp(r"a(.?)(.)"); + input0 = "a\xc0\x92bcd"; + results = ["a\xc0\x92", "\xc0", "\x92"]; + shouldBe(regex8.firstMatch(input0), results); + + var regex9 = new RegExp(r"a(.?)(.)"); + input0 = "a\u0240bcd"; + results = ["a\u0240b", "\u0240", "b"]; + shouldBe(regex9.firstMatch(input0), results); + + var regex10 = new RegExp(r"a(.??)(.)"); + input0 = "a\xc0\x92bcd"; + results = ["a\xc0", "", "\xc0"]; + shouldBe(regex10.firstMatch(input0), results); + + var regex11 = new RegExp(r"a(.??)(.)"); + input0 = "a\u0240bcd"; + results = ["a\u0240", "", "\u0240"]; + shouldBe(regex11.firstMatch(input0), results); + + var regex12 = new RegExp(r"a(.{3})b"); + input0 = "a\u1234xyb"; + results = ["a\u1234xyb", "\u1234xy"]; + shouldBe(regex12.firstMatch(input0), results); + input1 = "a\u1234\u4321yb"; + results = ["a\u1234\u4321yb", "\u1234\u4321y"]; + shouldBe(regex12.firstMatch(input1), results); + input2 = "a\u1234\u4321\u3412b"; + results = ["a\u1234\u4321\u3412b", "\u1234\u4321\u3412"]; + shouldBe(regex12.firstMatch(input2), results); + // Failers + input3 = "a\u1234b"; + results = null; + shouldBe(regex12.firstMatch(input3), results); + input4 = "ac\ncb"; + results = null; + shouldBe(regex12.firstMatch(input4), results); + + var regex13 = new RegExp(r"a(.{3,})b"); + input0 = "a\u1234xyb"; + results = ["a\u1234xyb", "\u1234xy"]; + shouldBe(regex13.firstMatch(input0), results); + input1 = "a\u1234\u4321yb"; + results = ["a\u1234\u4321yb", "\u1234\u4321y"]; + shouldBe(regex13.firstMatch(input1), results); + input2 = "a\u1234\u4321\u3412b"; + results = ["a\u1234\u4321\u3412b", "\u1234\u4321\u3412"]; + shouldBe(regex13.firstMatch(input2), results); + input3 = "axxxxbcdefghijb"; + results = ["axxxxbcdefghijb", "xxxxbcdefghij"]; + shouldBe(regex13.firstMatch(input3), results); + input4 = "a\u1234\u4321\u3412\u3421b"; + results = ["a\u1234\u4321\u3412\u3421b", "\u1234\u4321\u3412\u3421"]; + shouldBe(regex13.firstMatch(input4), results); + // Failers + var input5 = "a\u1234b"; + results = null; + shouldBe(regex13.firstMatch(input5), results); + + var regex14 = new RegExp(r"a(.{3,}?)b"); + input0 = "a\u1234xyb"; + results = ["a\u1234xyb", "\u1234xy"]; + shouldBe(regex14.firstMatch(input0), results); + input1 = "a\u1234\u4321yb"; + results = ["a\u1234\u4321yb", "\u1234\u4321y"]; + shouldBe(regex14.firstMatch(input1), results); + input2 = "a\u1234\u4321\u3412b"; + results = ["a\u1234\u4321\u3412b", "\u1234\u4321\u3412"]; + shouldBe(regex14.firstMatch(input2), results); + input3 = "axxxxbcdefghijb"; + results = ["axxxxb", "xxxx"]; + shouldBe(regex14.firstMatch(input3), results); + input4 = "a\u1234\u4321\u3412\u3421b"; + results = ["a\u1234\u4321\u3412\u3421b", "\u1234\u4321\u3412\u3421"]; + shouldBe(regex14.firstMatch(input4), results); + // Failers + input5 = "a\u1234b"; + results = null; + shouldBe(regex14.firstMatch(input5), results); + + var regex15 = new RegExp(r"a(.{3,5})b"); + input0 = "a\u1234xyb"; + results = ["a\u1234xyb", "\u1234xy"]; + shouldBe(regex15.firstMatch(input0), results); + input1 = "a\u1234\u4321yb"; + results = ["a\u1234\u4321yb", "\u1234\u4321y"]; + shouldBe(regex15.firstMatch(input1), results); + input2 = "a\u1234\u4321\u3412b"; + results = ["a\u1234\u4321\u3412b", "\u1234\u4321\u3412"]; + shouldBe(regex15.firstMatch(input2), results); + input3 = "axxxxbcdefghijb"; + results = ["axxxxb", "xxxx"]; + shouldBe(regex15.firstMatch(input3), results); + input4 = "a\u1234\u4321\u3412\u3421b"; + results = ["a\u1234\u4321\u3412\u3421b", "\u1234\u4321\u3412\u3421"]; + shouldBe(regex15.firstMatch(input4), results); + input5 = "axbxxbcdefghijb"; + results = ["axbxxb", "xbxx"]; + shouldBe(regex15.firstMatch(input5), results); + var input6 = "axxxxxbcdefghijb"; + results = ["axxxxxb", "xxxxx"]; + shouldBe(regex15.firstMatch(input6), results); + // Failers + var input7 = "a\u1234b"; + results = null; + shouldBe(regex15.firstMatch(input7), results); + var input8 = "axxxxxxbcdefghijb"; + results = null; + shouldBe(regex15.firstMatch(input8), results); + + var regex16 = new RegExp(r"a(.{3,5}?)b"); + input0 = "a\u1234xyb"; + results = ["a\u1234xyb", "\u1234xy"]; + shouldBe(regex16.firstMatch(input0), results); + input1 = "a\u1234\u4321yb"; + results = ["a\u1234\u4321yb", "\u1234\u4321y"]; + shouldBe(regex16.firstMatch(input1), results); + input2 = "a\u1234\u4321\u3412b"; + results = ["a\u1234\u4321\u3412b", "\u1234\u4321\u3412"]; + shouldBe(regex16.firstMatch(input2), results); + input3 = "axxxxbcdefghijb"; + results = ["axxxxb", "xxxx"]; + shouldBe(regex16.firstMatch(input3), results); + input4 = "a\u1234\u4321\u3412\u3421b"; + results = ["a\u1234\u4321\u3412\u3421b", "\u1234\u4321\u3412\u3421"]; + shouldBe(regex16.firstMatch(input4), results); + input5 = "axbxxbcdefghijb"; + results = ["axbxxb", "xbxx"]; + shouldBe(regex16.firstMatch(input5), results); + input6 = "axxxxxbcdefghijb"; + results = ["axxxxxb", "xxxxx"]; + shouldBe(regex16.firstMatch(input6), results); + // Failers + input7 = "a\u1234b"; + results = null; + shouldBe(regex16.firstMatch(input7), results); + input8 = "axxxxxxbcdefghijb"; + results = null; + shouldBe(regex16.firstMatch(input8), results); + + var regex17 = new RegExp(r"^[a\u00c0]"); + // Failers + input0 = "\u0100"; + results = null; + shouldBe(regex17.firstMatch(input0), results); + + var regex21 = new RegExp(r"(?:\u0100){3}b"); + input0 = "\u0100\u0100\u0100b"; + results = ["\u0100\u0100\u0100b"]; + shouldBe(regex21.firstMatch(input0), results); + // Failers + input1 = "\u0100\u0100b"; + results = null; + shouldBe(regex21.firstMatch(input1), results); + + var regex22 = new RegExp(r"\u00ab"); + input0 = "\u00ab"; + results = ["\u00ab"]; + shouldBe(regex22.firstMatch(input0), results); + input1 = "\xc2\xab"; + results = ["\u00ab"]; + shouldBe(regex22.firstMatch(input1), results); + // Failers + input2 = "\x00{ab}"; + results = null; + shouldBe(regex22.firstMatch(input2), results); + + var regex30 = new RegExp(r"^[^a]{2}"); + input0 = "\u0100bc"; + results = ["\u0100b"]; + shouldBe(regex30.firstMatch(input0), results); + + var regex31 = new RegExp(r"^[^a]{2,}"); + input0 = "\u0100bcAa"; + results = ["\u0100bcA"]; + shouldBe(regex31.firstMatch(input0), results); + + var regex32 = new RegExp(r"^[^a]{2,}?"); + input0 = "\u0100bca"; + results = ["\u0100b"]; + shouldBe(regex32.firstMatch(input0), results); + + var regex33 = new RegExp(r"^[^a]{2}", caseSensitive: false); + input0 = "\u0100bc"; + results = ["\u0100b"]; + shouldBe(regex33.firstMatch(input0), results); + + var regex34 = new RegExp(r"^[^a]{2,}", caseSensitive: false); + input0 = "\u0100bcAa"; + results = ["\u0100bc"]; + shouldBe(regex34.firstMatch(input0), results); + + var regex35 = new RegExp(r"^[^a]{2,}?", caseSensitive: false); + input0 = "\u0100bca"; + results = ["\u0100b"]; + shouldBe(regex35.firstMatch(input0), results); + + var regex36 = new RegExp(r"\u0100{0,0}"); + input0 = "abcd"; + results = [""]; + shouldBe(regex36.firstMatch(input0), results); + + var regex37 = new RegExp(r"\u0100?"); + input0 = "abcd"; + results = [""]; + shouldBe(regex37.firstMatch(input0), results); + input1 = "\u0100\u0100"; + results = ["\u0100"]; + shouldBe(regex37.firstMatch(input1), results); + + var regex38 = new RegExp(r"\u0100{0,3}"); + input0 = "\u0100\u0100"; + results = ["\u0100\u0100"]; + shouldBe(regex38.firstMatch(input0), results); + input1 = "\u0100\u0100\u0100\u0100"; + results = ["\u0100\u0100\u0100"]; + shouldBe(regex38.firstMatch(input1), results); + + var regex39 = new RegExp(r"\u0100*"); + input0 = "abce"; + results = [""]; + shouldBe(regex39.firstMatch(input0), results); + input1 = "\u0100\u0100\u0100\u0100"; + results = ["\u0100\u0100\u0100\u0100"]; + shouldBe(regex39.firstMatch(input1), results); + + var regex40 = new RegExp(r"\u0100{1,1}"); + input0 = "abcd\u0100\u0100\u0100\u0100"; + results = ["\u0100"]; + shouldBe(regex40.firstMatch(input0), results); + + var regex41 = new RegExp(r"\u0100{1,3}"); + input0 = "abcd\u0100\u0100\u0100\u0100"; + results = ["\u0100\u0100\u0100"]; + shouldBe(regex41.firstMatch(input0), results); + + var regex42 = new RegExp(r"\u0100+"); + input0 = "abcd\u0100\u0100\u0100\u0100"; + results = ["\u0100\u0100\u0100\u0100"]; + shouldBe(regex42.firstMatch(input0), results); + + var regex43 = new RegExp(r"\u0100{3}"); + input0 = "abcd\u0100\u0100\u0100XX"; + results = ["\u0100\u0100\u0100"]; + shouldBe(regex43.firstMatch(input0), results); + + var regex44 = new RegExp(r"\u0100{3,5}"); + input0 = "abcd\u0100\u0100\u0100\u0100\u0100\u0100\u0100XX"; + results = ["\u0100\u0100\u0100\u0100\u0100"]; + shouldBe(regex44.firstMatch(input0), results); + + var regex45 = new RegExp(r"\u0100{3,}"); + input0 = "abcd\u0100\u0100\u0100\u0100\u0100\u0100\u0100XX"; + results = ["\u0100\u0100\u0100\u0100\u0100\u0100\u0100"]; + shouldBe(regex45.firstMatch(input0), results); + + var regex47 = new RegExp(r"\D*"); + input0 = + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; + results = [ + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + ]; + shouldBe(regex47.firstMatch(input0), results); + + var regex48 = new RegExp(r"\D*"); + input0 = + "\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100"; + results = [ + "\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100\u0100" + ]; + shouldBe(regex48.firstMatch(input0), results); + + var regex49 = new RegExp(r"\D"); + input0 = "1X2"; + results = ["X"]; + shouldBe(regex49.firstMatch(input0), results); + input1 = "1\u01002"; + results = ["\u0100"]; + shouldBe(regex49.firstMatch(input1), results); + + var regex50 = new RegExp(r">\S"); + input0 = "> >X Y"; + results = [">X"]; + shouldBe(regex50.firstMatch(input0), results); + input1 = "> >\u0100 Y"; + results = [">\u0100"]; + shouldBe(regex50.firstMatch(input1), results); + + var regex51 = new RegExp(r"\d"); + input0 = "\u01003"; + results = ["3"]; + shouldBe(regex51.firstMatch(input0), results); + + var regex52 = new RegExp(r"\s"); + input0 = "\u0100 X"; + results = [" "]; + shouldBe(regex52.firstMatch(input0), results); + + var regex53 = new RegExp(r"\D+"); + input0 = "12abcd34"; + results = ["abcd"]; + shouldBe(regex53.firstMatch(input0), results); + // Failers + input1 = "1234"; + results = null; + shouldBe(regex53.firstMatch(input1), results); + + var regex54 = new RegExp(r"\D{2,3}"); + input0 = "12abcd34"; + results = ["abc"]; + shouldBe(regex54.firstMatch(input0), results); + input1 = "12ab34"; + results = ["ab"]; + shouldBe(regex54.firstMatch(input1), results); + // Failers + input2 = "1234"; + results = null; + shouldBe(regex54.firstMatch(input2), results); + input3 = "12a34"; + results = null; + shouldBe(regex54.firstMatch(input3), results); + + var regex55 = new RegExp(r"\D{2,3}?"); + input0 = "12abcd34"; + results = ["ab"]; + shouldBe(regex55.firstMatch(input0), results); + input1 = "12ab34"; + results = ["ab"]; + shouldBe(regex55.firstMatch(input1), results); + // Failers + input2 = "1234"; + results = null; + shouldBe(regex55.firstMatch(input2), results); + input3 = "12a34"; + results = null; + shouldBe(regex55.firstMatch(input3), results); + + var regex56 = new RegExp(r"\d+"); + input0 = "12abcd34"; + results = ["12"]; + shouldBe(regex56.firstMatch(input0), results); + + var regex57 = new RegExp(r"\d{2,3}"); + input0 = "12abcd34"; + results = ["12"]; + shouldBe(regex57.firstMatch(input0), results); + input1 = "1234abcd"; + results = ["123"]; + shouldBe(regex57.firstMatch(input1), results); + // Failers + input2 = "1.4"; + results = null; + shouldBe(regex57.firstMatch(input2), results); + + var regex58 = new RegExp(r"\d{2,3}?"); + input0 = "12abcd34"; + results = ["12"]; + shouldBe(regex58.firstMatch(input0), results); + input1 = "1234abcd"; + results = ["12"]; + shouldBe(regex58.firstMatch(input1), results); + // Failers + input2 = "1.4"; + results = null; + shouldBe(regex58.firstMatch(input2), results); + + var regex59 = new RegExp(r"\S+"); + input0 = "12abcd34"; + results = ["12abcd34"]; + shouldBe(regex59.firstMatch(input0), results); + // Failers + input1 = " "; + results = null; + shouldBe(regex59.firstMatch(input1), results); + + var regex60 = new RegExp(r"\S{2,3}"); + input0 = "12abcd34"; + results = ["12a"]; + shouldBe(regex60.firstMatch(input0), results); + input1 = "1234abcd"; + results = ["123"]; + shouldBe(regex60.firstMatch(input1), results); + // Failers + input2 = " "; + results = null; + shouldBe(regex60.firstMatch(input2), results); + + var regex61 = new RegExp(r"\S{2,3}?"); + input0 = "12abcd34"; + results = ["12"]; + shouldBe(regex61.firstMatch(input0), results); + input1 = "1234abcd"; + results = ["12"]; + shouldBe(regex61.firstMatch(input1), results); + // Failers + input2 = " "; + results = null; + shouldBe(regex61.firstMatch(input2), results); + + var regex62 = new RegExp(r">\s+<"); + input0 = "12> <34"; + results = ["> <"]; + shouldBe(regex62.firstMatch(input0), results); + + var regex63 = new RegExp(r">\s{2,3}<"); + input0 = "ab> <"]; + shouldBe(regex63.firstMatch(input0), results); + input1 = "ab> <"]; + shouldBe(regex63.firstMatch(input1), results); + // Failers + input2 = "ab> \s{2,3}?<"); + input0 = "ab> <"]; + shouldBe(regex64.firstMatch(input0), results); + input1 = "ab> <"]; + shouldBe(regex64.firstMatch(input1), results); + // Failers + input2 = "ab> m.group(0)).toList(), results); + + var regexGlobal1 = new RegExp(r"\S\S"); + input0 = "A\u00a3BC"; + results = ["A\u00a3", "BC"]; + Expect.listEquals(allStringMatches(input0, regexGlobal1), results); + + var regexGlobal2 = new RegExp(r"\S{2}"); + input0 = "A\u00a3BC"; + results = ["A\u00a3", "BC"]; + Expect.listEquals(allStringMatches(input0, regexGlobal2), results); + + var regexGlobal3 = new RegExp(r"\W\W"); + input0 = "+\u00a3=="; + results = ["+\u00a3", "=="]; + Expect.listEquals(allStringMatches(input0, regexGlobal3), results); + + var regexGlobal4 = new RegExp(r"\W{2}"); + input0 = "+\u00a3=="; + results = ["+\u00a3", "=="]; + Expect.listEquals(allStringMatches(input0, regexGlobal4), results); + + var regexGlobal5 = new RegExp(r"\S"); + input0 = "\u0442\u0435\u0441\u0442"; + results = ["\u0442", "\u0435", "\u0441", "\u0442"]; + Expect.listEquals(allStringMatches(input0, regexGlobal5), results); + + var regexGlobal6 = new RegExp(r"[\S]"); + input0 = "\u0442\u0435\u0441\u0442"; + results = ["\u0442", "\u0435", "\u0441", "\u0442"]; + Expect.listEquals(allStringMatches(input0, regexGlobal6), results); + + var regexGlobal7 = new RegExp(r"\D"); + input0 = "\u0442\u0435\u0441\u0442"; + results = ["\u0442", "\u0435", "\u0441", "\u0442"]; + Expect.listEquals(allStringMatches(input0, regexGlobal7), results); + + var regexGlobal8 = new RegExp(r"[\D]"); + input0 = "\u0442\u0435\u0441\u0442"; + results = ["\u0442", "\u0435", "\u0441", "\u0442"]; + Expect.listEquals(allStringMatches(input0, regexGlobal8), results); + + var regexGlobal9 = new RegExp(r"\W"); + input0 = "\u2442\u2435\u2441\u2442"; + results = ["\u2442", "\u2435", "\u2441", "\u2442"]; + Expect.listEquals(allStringMatches(input0, regexGlobal9), results); + + var regexGlobal10 = new RegExp(r"[\W]"); + input0 = "\u2442\u2435\u2441\u2442"; + results = ["\u2442", "\u2435", "\u2441", "\u2442"]; + Expect.listEquals(allStringMatches(input0, regexGlobal10), results); + + var regexGlobal11 = new RegExp(r"[\u041f\S]"); + input0 = "\u0442\u0435\u0441\u0442"; + results = ["\u0442", "\u0435", "\u0441", "\u0442"]; + Expect.listEquals(allStringMatches(input0, regexGlobal11), results); + + var regexGlobal12 = new RegExp(r".[^\S]."); + input0 = "abc def\u0442\u0443xyz\npqr"; + results = ["c d", "z\u000ap"]; + Expect.listEquals(allStringMatches(input0, regexGlobal12), results); + + var regexGlobal13 = new RegExp(r".[^\S\n]."); + input0 = "abc def\u0442\u0443xyz\npqr"; + results = ["c d"]; + Expect.listEquals(allStringMatches(input0, regexGlobal13), results); + + var regexGlobal14 = new RegExp(r"[\W]"); + input0 = "+\u2442"; + results = ["+", "\u2442"]; + Expect.listEquals(allStringMatches(input0, regexGlobal14), results); + + var regexGlobal15 = new RegExp(r"[^a-zA-Z]"); + input0 = "+\u2442"; + results = ["+", "\u2442"]; + Expect.listEquals(allStringMatches(input0, regexGlobal15), results); + + var regexGlobal16 = new RegExp(r"[^a-zA-Z]"); + input0 = "A\u0442"; + results = ["\u0442"]; + Expect.listEquals(allStringMatches(input0, regexGlobal16), results); + + var regexGlobal17 = new RegExp(r"[\S]"); + input0 = "A\u0442"; + results = ["A", "\u0442"]; + Expect.listEquals(allStringMatches(input0, regexGlobal17), results); + + var regexGlobal19 = new RegExp(r"[\D]"); + input0 = "A\u0442"; + results = ["A", "\u0442"]; + Expect.listEquals(allStringMatches(input0, regexGlobal19), results); + + var regexGlobal21 = new RegExp(r"[^a-z]"); + input0 = "A\u0422"; + results = ["A", "\u0422"]; + Expect.listEquals(allStringMatches(input0, regexGlobal21), results); + + var regexGlobal24 = new RegExp(r"[\S]"); + input0 = "A\u0442"; + results = ["A", "\u0442"]; + Expect.listEquals(allStringMatches(input0, regexGlobal24), results); + + var regexGlobal25 = new RegExp(r"[^A-Z]"); + input0 = "a\u0442"; + results = ["a", "\u0442"]; + Expect.listEquals(allStringMatches(input0, regexGlobal25), results); + + var regexGlobal26 = new RegExp(r"[\W]"); + input0 = "+\u2442"; + results = ["+", "\u2442"]; + Expect.listEquals(allStringMatches(input0, regexGlobal26), results); + + var regexGlobal27 = new RegExp(r"[\D]"); + input0 = "M\u0442"; + results = ["M", "\u0442"]; + Expect.listEquals(allStringMatches(input0, regexGlobal27), results); + + var regexGlobal28 = new RegExp(r"[^a]+", caseSensitive: false); + input0 = "bcd"; + results = ["bcd"]; + Expect.listEquals(allStringMatches(input0, regexGlobal28), results); + input1 = "\u0100aY\u0256Z"; + results = ["\u0100", "Y\u0256Z"]; + Expect.listEquals(allStringMatches(input1, regexGlobal28), results); + + var regexGlobal29 = new RegExp(r"(a|)"); + input0 = "catac"; + results = ["", "a", "", "a", "", ""]; + Expect.listEquals(allStringMatches(input0, regexGlobal29), results); + input1 = "a\u0256a"; + results = ["a", "", "a", ""]; + Expect.listEquals(allStringMatches(input1, regexGlobal29), results); +} diff --git a/tests/corelib/regexp/pcre_test.dart b/tests/corelib/regexp/pcre_test.dart new file mode 100644 index 00000000000..dbcce204840 --- /dev/null +++ b/tests/corelib/regexp/pcre_test.dart @@ -0,0 +1,7225 @@ +// Copyright (c) 2014, the Dart project authors. All rights reserved. +// Autogenerated from the PCRE test suite Mon Feb 2 15:14:04 CET 2009 + +// Note that some regexps in the PCRE test suite use features not present +// in JavaScript. These don't work in JS, but they fail to work in a +// predictable way, and the expected results reflect this. + +// PCRE comes with the following license + +// PCRE LICENCE +// ------------ +// +// PCRE is a library of functions to support regular expressions whose syntax +// and semantics are as close as possible to those of the Perl 5 language. +// +// Release 7 of PCRE is distributed under the terms of the "BSD" licence, as +// specified below. The documentation for PCRE, supplied in the "doc" +// directory, is distributed under the same terms as the software itself. +// +// The basic library functions are written in C and are freestanding. Also +// included in the distribution is a set of C++ wrapper functions. +// +// +// THE BASIC LIBRARY FUNCTIONS +// --------------------------- +// +// Written by: Philip Hazel +// Email local part: ph10 +// Email domain: cam.ac.uk +// +// University of Cambridge Computing Service, +// Cambridge, England. +// +// Copyright (c) 1997-2007 University of Cambridge +// All rights reserved. +// +// +// THE C++ WRAPPER FUNCTIONS +// ------------------------- +// +// Contributed by: Google Inc. +// +// Copyright (c) 2007, Google Inc. +// All rights reserved. +// +// +// THE "BSD" LICENCE +// ----------------- +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// * Neither the name of the University of Cambridge nor the name of Google +// Inc. nor the names of their contributors may be used to endorse or +// promote products derived from this software without specific prior +// written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. +// +// End + +import 'v8_regexp_utils.dart'; +import 'package:expect/expect.dart'; + +void main() { + var res = []; + res.add(new RegExp(r"(a)b|", caseSensitive: false)); + res.add(new RegExp(r"abc", caseSensitive: false)); + res.add(new RegExp(r"^abc", caseSensitive: false)); + res.add(new RegExp(r"a+bc", caseSensitive: false)); + res.add(new RegExp(r"a*bc", caseSensitive: false)); + res.add(new RegExp(r"a{3}bc", caseSensitive: false)); + res.add(new RegExp(r"(abc|a+z)", caseSensitive: false)); + res.add(new RegExp(r"^abc$", caseSensitive: false)); + res.add(new RegExp(r"ab\idef")); + res.add(new RegExp(r".*b", caseSensitive: false)); + res.add(new RegExp(r".*?b", caseSensitive: false)); + res.add(new RegExp(r"cat|dog|elephant", caseSensitive: false)); + res.add(new RegExp(r"cat|dog|elephant", caseSensitive: false)); + res.add(new RegExp(r"cat|dog|elephant", caseSensitive: false)); + res.add(new RegExp(r"a|[bcd]", caseSensitive: false)); + res.add(new RegExp(r"(a|[^\dZ])", caseSensitive: false)); + res.add(new RegExp(r"(a|b)*[\s]", caseSensitive: false)); + res.add(new RegExp(r"(ab\2)")); + res.add(new RegExp(r"(a)(b)(c)\2", caseSensitive: false)); + res.add(new RegExp(r"(a)bc|(a)(b)\2", caseSensitive: false)); + res.add(new RegExp(r"abc$", caseSensitive: false)); + res.add(new RegExp(r"(a)(b)(c)(d)(e)\6")); + res.add(new RegExp(r"the quick brown fox", caseSensitive: false)); + res.add(new RegExp(r"^abc|def", caseSensitive: false)); + res.add(new RegExp(r".*((abc)$|(def))", caseSensitive: false)); + res.add(new RegExp(r"abc", caseSensitive: false)); + res.add(new RegExp(r"^abc|def", caseSensitive: false)); + res.add(new RegExp(r".*((abc)$|(def))", caseSensitive: false)); + res.add(new RegExp(r"the quick brown fox", caseSensitive: false)); + res.add(new RegExp(r"the quick brown fox", caseSensitive: false)); + res.add(new RegExp(r"abc.def", caseSensitive: false)); + res.add(new RegExp(r"abc$", caseSensitive: false)); + res.add(new RegExp(r"(abc)\2", caseSensitive: false)); + res.add(new RegExp(r"(abc\1)", caseSensitive: false)); + res.add(new RegExp(r"a[]b")); + res.add(new RegExp(r"[^aeiou ]{3,}", caseSensitive: false)); + res.add(new RegExp(r"<.*>", caseSensitive: false)); + res.add(new RegExp(r"<.*?>", caseSensitive: false)); + res.add(new RegExp(r"[abcd]", caseSensitive: false)); + res.add(new RegExp(r"(^a|^b)", multiLine: true, caseSensitive: false)); + res.add(new RegExp(r"a$", caseSensitive: false)); + res.add(new RegExp(r"a$", multiLine: true, caseSensitive: false)); + res.add(new RegExp(r"\Aabc", multiLine: true, caseSensitive: false)); + res.add(new RegExp(r"^abc", multiLine: true, caseSensitive: false)); + res.add(new RegExp(r"(?!alphabet)[ab]", caseSensitive: false)); + res.add(new RegExp( + r"The next three are in testinput2 because they have variable length branches")); + res.add(new RegExp(r"This one is here because Perl 5.005_02 doesn't fail it", + caseSensitive: false)); + res.add(new RegExp( + r"This one is here because I think Perl 5.005_02 gets the setting of $1 wrong", + caseSensitive: false)); + res.add(new RegExp(r"^(a\1?){4}$", caseSensitive: false)); + res.add(new RegExp(r"These are syntax tests from Perl 5.005", + caseSensitive: false)); + res.add(new RegExp(r"a[]b")); + res.add(new RegExp(r"\1")); + res.add(new RegExp(r"\2")); + res.add(new RegExp(r"(a)|\2")); + res.add(new RegExp(r"a[]b", caseSensitive: false)); + res.add(new RegExp(r"abc")); + res.add(new RegExp(r"abc")); + res.add(new RegExp(r"abc", caseSensitive: false)); + res.add(new RegExp(r"(a)bc(d)", caseSensitive: false)); + res.add(new RegExp(r"(.{20})", caseSensitive: false)); + res.add(new RegExp(r"(.{15})", caseSensitive: false)); + res.add(new RegExp(r"(.{16})", caseSensitive: false)); + res.add(new RegExp(r"^(a|(bc))de(f)", caseSensitive: false)); + res.add(new RegExp(r"^abc\00def", caseSensitive: false)); + res.add(new RegExp( + r"word ((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+\n)((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+ )((?:[a-zA-Z0-9]+\n)?)?)?)?)?)?)?)?)?otherword", + caseSensitive: false)); + res.add(new RegExp(r".*X", caseSensitive: false)); + res.add(new RegExp(r".*X", caseSensitive: false)); + res.add(new RegExp(r"(.*X|^B)", caseSensitive: false)); + res.add(new RegExp(r"(.*X|^B)", caseSensitive: false)); + res.add(new RegExp(r"\Biss\B", caseSensitive: false)); + res.add(new RegExp(r"\Biss\B", caseSensitive: false)); + res.add(new RegExp(r"iss", caseSensitive: false)); + res.add(new RegExp(r"\Biss\B", caseSensitive: false)); + res.add(new RegExp(r"\Biss\B", caseSensitive: false)); + res.add(new RegExp(r"^iss", caseSensitive: false)); + res.add(new RegExp(r".*iss", caseSensitive: false)); + res.add(new RegExp(r".i.", caseSensitive: false)); + res.add(new RegExp(r"^.is", caseSensitive: false)); + res.add(new RegExp(r"^ab\n", caseSensitive: false)); + res.add(new RegExp(r"^ab\n", multiLine: true, caseSensitive: false)); + res.add(new RegExp(r"abc", caseSensitive: false)); + res.add(new RegExp(r"abc|bac", caseSensitive: false)); + res.add(new RegExp(r"(abc|bac)", caseSensitive: false)); + res.add(new RegExp(r"(abc|(c|dc))", caseSensitive: false)); + res.add(new RegExp(r"(abc|(d|de)c)", caseSensitive: false)); + res.add(new RegExp(r"a*", caseSensitive: false)); + res.add(new RegExp(r"a+", caseSensitive: false)); + res.add(new RegExp(r"(baa|a+)", caseSensitive: false)); + res.add(new RegExp(r"a{0,3}", caseSensitive: false)); + res.add(new RegExp(r"baa{3,}", caseSensitive: false)); + res.add(new RegExp(r'"([^\\"]+|\.)*"', caseSensitive: false)); + res.add(new RegExp(r"(abc|ab[cd])", caseSensitive: false)); + res.add(new RegExp(r"(a|.)", caseSensitive: false)); + res.add(new RegExp(r"a|ba|\w", caseSensitive: false)); + res.add(new RegExp(r"abc(?=pqr)", caseSensitive: false)); + res.add(new RegExp(r"abc(?!pqr)", caseSensitive: false)); + res.add(new RegExp(r"ab.", caseSensitive: false)); + res.add(new RegExp(r"ab[xyz]", caseSensitive: false)); + res.add(new RegExp(r"abc*", caseSensitive: false)); + res.add(new RegExp(r"ab.c*", caseSensitive: false)); + res.add(new RegExp(r"a.c*", caseSensitive: false)); + res.add(new RegExp(r".c*", caseSensitive: false)); + res.add(new RegExp(r"ac*", caseSensitive: false)); + res.add(new RegExp(r"(a.c*|b.c*)", caseSensitive: false)); + res.add(new RegExp(r"a.c*|aba", caseSensitive: false)); + res.add(new RegExp(r".+a", caseSensitive: false)); + res.add(new RegExp(r"(?=abcda)a.*", caseSensitive: false)); + res.add(new RegExp(r"(?=a)a.*", caseSensitive: false)); + res.add(new RegExp(r"a(b)*", caseSensitive: false)); + res.add(new RegExp(r"a\d*", caseSensitive: false)); + res.add(new RegExp(r"ab\d*", caseSensitive: false)); + res.add(new RegExp(r"a(\d)*", caseSensitive: false)); + res.add(new RegExp(r"abcde{0,0}", caseSensitive: false)); + res.add(new RegExp(r"ab\d+", caseSensitive: false)); + res.add(new RegExp(r"ab\d{0}e", caseSensitive: false)); + res.add(new RegExp(r"a?b?", caseSensitive: false)); + res.add(new RegExp(r"|-", caseSensitive: false)); + res.add(new RegExp(r"a*(b+)(z)(z)", caseSensitive: false)); + res.add(new RegExp(r"^.?abcd", caseSensitive: false)); + res.add(new RegExp(r"^[[:alnum:]]")); + res.add(new RegExp(r"^[[:^alnum:]]")); + res.add(new RegExp(r"^[[:alpha:]]")); + res.add(new RegExp(r"^[[:^alpha:]]")); + res.add(new RegExp(r"[_[:alpha:]]", caseSensitive: false)); + res.add(new RegExp(r"^[[:ascii:]]")); + res.add(new RegExp(r"^[[:^ascii:]]")); + res.add(new RegExp(r"^[[:blank:]]")); + res.add(new RegExp(r"^[[:^blank:]]")); + res.add(new RegExp(r"[\n\x0b\x0c\x0d[:blank:]]", caseSensitive: false)); + res.add(new RegExp(r"^[[:cntrl:]]")); + res.add(new RegExp(r"^[[:digit:]]")); + res.add(new RegExp(r"^[[:graph:]]")); + res.add(new RegExp(r"^[[:lower:]]")); + res.add(new RegExp(r"^[[:print:]]")); + res.add(new RegExp(r"^[[:punct:]]")); + res.add(new RegExp(r"^[[:space:]]")); + res.add(new RegExp(r"^[[:upper:]]")); + res.add(new RegExp(r"^[[:xdigit:]]")); + res.add(new RegExp(r"^[[:word:]]")); + res.add(new RegExp(r"^[[:^cntrl:]]")); + res.add(new RegExp(r"^[12[:^digit:]]")); + res.add(new RegExp(r"^[[:^blank:]]")); + res.add(new RegExp(r"[01[:alpha:]%]")); + res.add(new RegExp(r"[[.ch.]]", caseSensitive: false)); + res.add(new RegExp(r"[[=ch=]]", caseSensitive: false)); + res.add(new RegExp(r"[[:rhubarb:]]", caseSensitive: false)); + res.add(new RegExp(r"[[:upper:]]", caseSensitive: false)); + res.add(new RegExp(r"[[:lower:]]", caseSensitive: false)); + res.add(new RegExp( + r"This one's here because of the large output vector needed", + caseSensitive: false)); + res.add(new RegExp( + r"(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\d+(?:\s|$))(\w+)\s+(\270)", + caseSensitive: false)); + res.add(new RegExp( + r"This one's here because Perl does this differently and PCRE can't at present", + caseSensitive: false)); + res.add(new RegExp(r"(main(O)?)+", caseSensitive: false)); + res.add(new RegExp( + r"These are all cases where Perl does it differently (nested captures)", + caseSensitive: false)); + res.add(new RegExp(r"^(a(b)?)+$", caseSensitive: false)); + res.add(new RegExp(r"^(aa(bb)?)+$", caseSensitive: false)); + res.add(new RegExp(r"^(aa|aa(bb))+$", caseSensitive: false)); + res.add(new RegExp(r"^(aa(bb)??)+$", caseSensitive: false)); + res.add(new RegExp(r"^(?:aa(bb)?)+$", caseSensitive: false)); + res.add(new RegExp(r"^(aa(b(b))?)+$", caseSensitive: false)); + res.add(new RegExp(r"^(?:aa(b(b))?)+$", caseSensitive: false)); + res.add(new RegExp(r"^(?:aa(b(?:b))?)+$", caseSensitive: false)); + res.add(new RegExp(r"^(?:aa(bb(?:b))?)+$", caseSensitive: false)); + res.add(new RegExp(r"^(?:aa(b(?:bb))?)+$", caseSensitive: false)); + res.add(new RegExp(r"^(?:aa(?:b(b))?)+$", caseSensitive: false)); + res.add(new RegExp(r"^(?:aa(?:b(bb))?)+$", caseSensitive: false)); + res.add(new RegExp(r"^(aa(b(bb))?)+$", caseSensitive: false)); + res.add(new RegExp(r"^(aa(bb(bb))?)+$", caseSensitive: false)); + res.add(new RegExp(r"a", caseSensitive: false)); + res.add(new RegExp(r"[\s]")); + res.add(new RegExp(r"[\S]")); + res.add(new RegExp( + r"123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890")); + res.add(new RegExp( + r"\Q123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890")); + res.add(new RegExp(r"\Q\E")); + res.add(new RegExp(r"\Q\Ex")); + res.add(new RegExp(r" \Q\E")); + res.add(new RegExp(r"a\Q\E")); + res.add(new RegExp(r"a\Q\Eb")); + res.add(new RegExp(r"\Q\Eabc")); + res.add(new RegExp(r"[.x.]", caseSensitive: false)); + res.add(new RegExp(r"[=x=]", caseSensitive: false)); + res.add(new RegExp(r"[:x:]", caseSensitive: false)); + res.add(new RegExp(r"\l", caseSensitive: false)); + res.add(new RegExp(r"\L", caseSensitive: false)); + res.add(new RegExp(r"\N{name}", caseSensitive: false)); + res.add(new RegExp(r"\u", caseSensitive: false)); + res.add(new RegExp(r"\U", caseSensitive: false)); + res.add(new RegExp(r"[[:space:]", caseSensitive: false)); + res.add(new RegExp(r"[\s]", caseSensitive: false)); + res.add(new RegExp(r"[[:space:]]", caseSensitive: false)); + res.add(new RegExp(r"[[:space:]abcde]", caseSensitive: false)); + res.add(new RegExp(r"(.*)\d+\1", caseSensitive: false)); + res.add(new RegExp(r"(.*)\d+", caseSensitive: false)); + res.add(new RegExp(r"(.*)\d+\1", caseSensitive: false)); + res.add(new RegExp(r"(.*)\d+", caseSensitive: false)); + res.add(new RegExp(r"(.*(xyz))\d+\2", caseSensitive: false)); + res.add(new RegExp(r"((.*))\d+\1", caseSensitive: false)); + res.add(new RegExp(r"a[b]", caseSensitive: false)); + res.add(new RegExp(r"(?=a).*", caseSensitive: false)); + res.add(new RegExp(r"(?=abc).xyz", caseSensitive: false)); + res.add(new RegExp(r"(?=a)(?=b)", caseSensitive: false)); + res.add(new RegExp(r"(?=.)a", caseSensitive: false)); + res.add(new RegExp(r"((?=abcda)a)", caseSensitive: false)); + res.add(new RegExp(r"((?=abcda)ab)", caseSensitive: false)); + res.add(new RegExp(r"()a", caseSensitive: false)); + res.add(new RegExp(r"(a)+", caseSensitive: false)); + res.add(new RegExp(r"(a){2,3}", caseSensitive: false)); + res.add(new RegExp(r"(a)*", caseSensitive: false)); + res.add(new RegExp(r"[a]", caseSensitive: false)); + res.add(new RegExp(r"[ab]", caseSensitive: false)); + res.add(new RegExp(r"[ab]", caseSensitive: false)); + res.add(new RegExp(r"[^a]", caseSensitive: false)); + res.add(new RegExp(r"\d456", caseSensitive: false)); + res.add(new RegExp(r"\d456", caseSensitive: false)); + res.add(new RegExp(r"a^b", caseSensitive: false)); + res.add(new RegExp(r"^a", multiLine: true, caseSensitive: false)); + res.add(new RegExp(r"c|abc", caseSensitive: false)); + res.add(new RegExp(r"(.*)a", caseSensitive: false)); + res.add(new RegExp(r"(.*)a\1", caseSensitive: false)); + res.add(new RegExp(r"(.*)a(b)\2", caseSensitive: false)); + res.add(new RegExp(r"((.*)a|(.*)b)z", caseSensitive: false)); + res.add(new RegExp(r"((.*)a|(.*)b)z\1", caseSensitive: false)); + res.add(new RegExp(r"((.*)a|(.*)b)z\2", caseSensitive: false)); + res.add(new RegExp(r"((.*)a|(.*)b)z\3", caseSensitive: false)); + res.add(new RegExp(r"((.*)a|^(.*)b)z\3", caseSensitive: false)); + res.add(new RegExp( + r"(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)a", + caseSensitive: false)); + res.add(new RegExp( + r"(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)a\31", + caseSensitive: false)); + res.add(new RegExp( + r"(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)|(.*)a\32", + caseSensitive: false)); + res.add(new RegExp(r"(a)(bc)", caseSensitive: false)); + res.add(new RegExp(r"(a+)*zz", caseSensitive: false)); + res.add(new RegExp(r"((w\/|-|with)*(free|immediate)*.*?shipping\s*[!.-]*)", + caseSensitive: false)); + res.add(new RegExp(r"((w\/|-|with)*(free|immediate)*.*?shipping\s*[!.-]*)", + caseSensitive: false)); + res.add(new RegExp(r"a*.*b", caseSensitive: false)); + res.add(new RegExp(r"(a|b)*.?c", caseSensitive: false)); + res.add(new RegExp(r"abcde", caseSensitive: false)); + res.add(new RegExp(r"a*b", caseSensitive: false)); + res.add(new RegExp(r"a+b", caseSensitive: false)); + res.add(new RegExp(r"(abc|def)x", caseSensitive: false)); + res.add(new RegExp(r"(ab|cd){3,4}", caseSensitive: false)); + res.add(new RegExp(r"([ab]{,4}c|xy)", caseSensitive: false)); + res.add(new RegExp(r"([ab]{1,4}c|xy){4,5}?123", caseSensitive: false)); + res.add(new RegExp(r"\b.*", caseSensitive: false)); + res.add(new RegExp(r"\b.*", caseSensitive: false)); + res.add(new RegExp(r"(?!.bcd).*", caseSensitive: false)); + res.add(new RegExp(r"abcde", caseSensitive: false)); + res.add(new RegExp(r"0{0,2}ABC", caseSensitive: false)); + res.add(new RegExp(r"\d{3,}ABC", caseSensitive: false)); + res.add(new RegExp(r"\d*ABC", caseSensitive: false)); + res.add(new RegExp(r"[abc]+DE", caseSensitive: false)); + res.add(new RegExp(r"[abc]?123", caseSensitive: false)); + res.add(new RegExp(r"^(?:\d){3,5}X", caseSensitive: false)); + res.add(new RegExp(r"^a", caseSensitive: false)); + res.add(new RegExp(r"line\nbreak", caseSensitive: false)); + res.add(new RegExp(r"line\nbreak", caseSensitive: false)); + res.add(new RegExp(r"line\nbreak", multiLine: true, caseSensitive: false)); + res.add(new RegExp(r"ab.cd", caseSensitive: false)); + res.add(new RegExp(r"ab.cd", caseSensitive: false)); + res.add(new RegExp(r"a(b)c", caseSensitive: false)); + res.add(new RegExp( + r"Inthisnexttest,Jisnotsetattheouterlevel;consequentlyitisn'tsetinthepattern'soptions;consequentlypcre_get_named_substring()producesarandomvalue.", + caseSensitive: false)); + res.add(new RegExp(r"\777", caseSensitive: false)); + res.add(new RegExp(r"\s*,\s*", caseSensitive: false)); + res.add(new RegExp(r"^abc", multiLine: true, caseSensitive: false)); + res.add(new RegExp(r"abc$", multiLine: true, caseSensitive: false)); + res.add(new RegExp(r"^abc", multiLine: true, caseSensitive: false)); + res.add(new RegExp(r"^abc", multiLine: true, caseSensitive: false)); + res.add(new RegExp(r"^abc", multiLine: true, caseSensitive: false)); + res.add(new RegExp(r"^abc", multiLine: true, caseSensitive: false)); + res.add(new RegExp(r"abc", caseSensitive: false)); + res.add(new RegExp(r".*", caseSensitive: false)); + res.add(new RegExp(r"\w+(.)(.)?def", caseSensitive: false)); + res.add(new RegExp( + r"()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()(.(.))", + caseSensitive: false)); + res.add(new RegExp(r"()[ab]xyz", caseSensitive: false)); + res.add(new RegExp(r"(|)[ab]xyz", caseSensitive: false)); + res.add(new RegExp(r"(|c)[ab]xyz", caseSensitive: false)); + res.add(new RegExp(r"(|c?)[ab]xyz", caseSensitive: false)); + res.add(new RegExp(r"(d?|c?)[ab]xyz", caseSensitive: false)); + res.add(new RegExp(r"(d?|c)[ab]xyz", caseSensitive: false)); + res.add(new RegExp(r"^a*b\d")); + res.add(new RegExp(r"^a*?b\d")); + res.add(new RegExp(r"^a+A\d")); + res.add(new RegExp(r"^a*A\d", caseSensitive: false)); + res.add(new RegExp(r"(a*|b*)[cd]", caseSensitive: false)); + res.add(new RegExp(r"(a+|b*)[cd]", caseSensitive: false)); + res.add(new RegExp(r"(a*|b+)[cd]", caseSensitive: false)); + res.add(new RegExp(r"(a+|b+)[cd]", caseSensitive: false)); + res.add(new RegExp( + r"(((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((a)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))", + caseSensitive: false)); + res.add(new RegExp(r"a*\d")); + res.add(new RegExp(r"a*\D")); + res.add(new RegExp(r"0*\d")); + res.add(new RegExp(r"0*\D")); + res.add(new RegExp(r"a*\s")); + res.add(new RegExp(r"a*\S")); + res.add(new RegExp(r" *\s")); + res.add(new RegExp(r" *\S")); + res.add(new RegExp(r"a*\w")); + res.add(new RegExp(r"a*\W")); + res.add(new RegExp(r"=*\w")); + res.add(new RegExp(r"=*\W")); + res.add(new RegExp(r"\d*a")); + res.add(new RegExp(r"\d*2")); + res.add(new RegExp(r"\d*\d")); + res.add(new RegExp(r"\d*\D")); + res.add(new RegExp(r"\d*\s")); + res.add(new RegExp(r"\d*\S")); + res.add(new RegExp(r"\d*\w")); + res.add(new RegExp(r"\d*\W")); + res.add(new RegExp(r"\D*a")); + res.add(new RegExp(r"\D*2")); + res.add(new RegExp(r"\D*\d")); + res.add(new RegExp(r"\D*\D")); + res.add(new RegExp(r"\D*\s")); + res.add(new RegExp(r"\D*\S")); + res.add(new RegExp(r"\D*\w")); + res.add(new RegExp(r"\D*\W")); + res.add(new RegExp(r"\s*a")); + res.add(new RegExp(r"\s*2")); + res.add(new RegExp(r"\s*\d")); + res.add(new RegExp(r"\s*\D")); + res.add(new RegExp(r"\s*\s")); + res.add(new RegExp(r"\s*\S")); + res.add(new RegExp(r"\s*\w")); + res.add(new RegExp(r"\s*\W")); + res.add(new RegExp(r"\S*a")); + res.add(new RegExp(r"\S*2")); + res.add(new RegExp(r"\S*\d")); + res.add(new RegExp(r"\S*\D")); + res.add(new RegExp(r"\S*\s")); + res.add(new RegExp(r"\S*\S")); + res.add(new RegExp(r"\S*\w")); + res.add(new RegExp(r"\S*\W")); + res.add(new RegExp(r"\w*a")); + res.add(new RegExp(r"\w*2")); + res.add(new RegExp(r"\w*\d")); + res.add(new RegExp(r"\w*\D")); + res.add(new RegExp(r"\w*\s")); + res.add(new RegExp(r"\w*\S")); + res.add(new RegExp(r"\w*\w")); + res.add(new RegExp(r"\w*\W")); + res.add(new RegExp(r"\W*a")); + res.add(new RegExp(r"\W*2")); + res.add(new RegExp(r"\W*\d")); + res.add(new RegExp(r"\W*\D")); + res.add(new RegExp(r"\W*\s")); + res.add(new RegExp(r"\W*\S")); + res.add(new RegExp(r"\W*\w")); + res.add(new RegExp(r"\W*\W")); + res.add(new RegExp(r"[^a]+a")); + res.add(new RegExp(r"[^a]+a", caseSensitive: false)); + res.add(new RegExp(r"[^a]+A", caseSensitive: false)); + res.add(new RegExp(r"[^a]+b")); + res.add(new RegExp(r"[^a]+\d")); + res.add(new RegExp(r"a*[^a]")); + res.add(new RegExp(r"^(?:(?:\1|X)(a|b))+")); + res.add(new RegExp(r"^[\E\Qa\E-\Qz\E]+")); + res.add(new RegExp(r"^[a\Q]bc\E]")); + res.add(new RegExp(r"(?=(\w+))\1:", caseSensitive: false)); + res.add(new RegExp(r"(a|)*\d")); + res.add(new RegExp(r"^a.b")); + res.add(new RegExp(r"^abc.", multiLine: true)); + res.add(new RegExp(r"abc.$", multiLine: true)); + res.add(new RegExp(r"a")); + res.add(new RegExp(r"a")); + res.add(new RegExp(r"^a\Rb", caseSensitive: false)); + res.add(new RegExp(r"^a\R*b", caseSensitive: false)); + res.add(new RegExp(r"^a\R+b", caseSensitive: false)); + res.add(new RegExp(r"^a\R{1,3}b", caseSensitive: false)); + res.add(new RegExp(r"^a[\R]b", caseSensitive: false)); + res.add(new RegExp(r"^(a(b))\1\g1\g{1}\g-1\g{-1}\g{-02}Z")); + res.add(new RegExp(r"^(a)\g-2")); + res.add(new RegExp(r"^(a)\g")); + res.add(new RegExp(r"^(a)\g{0}")); + res.add(new RegExp(r"^(a)\g{3")); + res.add(new RegExp(r"^(a)\g{4a}")); + res.add(new RegExp(r"^a.b")); + res.add(new RegExp(r".+foo")); + res.add(new RegExp(r".+foo")); + res.add(new RegExp(r".+foo")); + res.add(new RegExp(r".+foo")); + res.add(new RegExp(r"^$", multiLine: true)); + res.add(new RegExp(r"abc.$", multiLine: true)); + res.add(new RegExp(r"^X", multiLine: true)); + res.add(new RegExp(r"(foo)\Kbar")); + res.add(new RegExp(r"(foo)(\Kbar|baz)")); + res.add(new RegExp(r"(foo\Kbar)baz")); + res.add(new RegExp(r"\g{A")); + res.add(new RegExp(r"\H\h\V\v")); + res.add(new RegExp(r"\H*\h+\V?\v{3,4}")); + res.add(new RegExp(r"\H{3,4}")); + res.add(new RegExp(r".\h{3,4}.")); + res.add(new RegExp(r"\h*X\h?\H+Y\H?Z")); + res.add(new RegExp(r"\v*X\v?Y\v+Z\V*\x0a\V+\x0b\V{2,3}\x0c")); + res.add(new RegExp(r"[\h]")); + res.add(new RegExp(r"[\h]+")); + res.add(new RegExp(r"[\v]")); + res.add(new RegExp(r"[\H]")); + res.add(new RegExp(r"[^\h]")); + res.add(new RegExp(r"[\V]")); + res.add(new RegExp(r"[\x0a\V]")); + res.add(new RegExp(r"\H+\hY")); + res.add(new RegExp(r"\H+ Y")); + res.add(new RegExp(r"\h+A")); + res.add(new RegExp(r"\v*B")); + res.add(new RegExp(r"\V+\x0a")); + res.add(new RegExp(r"A+\h")); + res.add(new RegExp(r" *\H")); + res.add(new RegExp(r"A*\v")); + res.add(new RegExp(r"\x0b*\V")); + res.add(new RegExp(r"\d+\h")); + res.add(new RegExp(r"\d*\v")); + res.add(new RegExp(r"S+\h\S+\v")); + res.add(new RegExp(r"\w{3,}\h\w+\v")); + res.add(new RegExp(r"\h+\d\h+\w\h+\S\h+\H")); + res.add(new RegExp(r"\v+\d\v+\w\v+\S\v+\V")); + res.add(new RegExp(r"\H+\h\H+\d")); + res.add(new RegExp(r"\V+\v\V+\w")); + res.add(new RegExp(r"[\E]AAA")); + res.add(new RegExp(r"[\Q\E]AAA")); + res.add(new RegExp(r"[^\E]AAA")); + res.add(new RegExp(r"[^\Q\E]AAA")); + res.add(new RegExp(r"[\E^]AAA")); + res.add(new RegExp(r"[\Q\E^]AAA")); + res.add(new RegExp(r"\g6666666666")); + res.add(new RegExp(r"[\g6666666666]")); + res.add(new RegExp(r".+A")); + res.add(new RegExp(r"\nA")); + res.add(new RegExp(r"[\r\n]A")); + res.add(new RegExp(r"(\r|\n)A")); + res.add(new RegExp(r"a\Rb", caseSensitive: false)); + res.add(new RegExp(r"a\Rb", caseSensitive: false)); + res.add(new RegExp(r"a\R?b", caseSensitive: false)); + res.add(new RegExp(r"a\R?b", caseSensitive: false)); + res.add(new RegExp(r"a\R{2,4}b", caseSensitive: false)); + res.add(new RegExp(r"a\R{2,4}b", caseSensitive: false)); + res.add(new RegExp(r"\k''")); + res.add(new RegExp(r"\k<>")); + res.add(new RegExp(r"\k{}")); + res.add(new RegExp(r"[[:foo:]]")); + res.add(new RegExp(r"[[:1234:]]")); + res.add(new RegExp(r"[[:f\oo:]]")); + res.add(new RegExp(r"[[: :]]")); + res.add(new RegExp(r"[[:...:]]")); + res.add(new RegExp(r"[[:l\ower:]]")); + res.add(new RegExp(r"[[:abc\:]]")); + res.add(new RegExp(r"[abc[:x\]pqr:]]")); + res.add(new RegExp(r"[[:a\dz:]]")); + res.add(new RegExp(r"^(a|b\g<1>c)")); + res.add(new RegExp(r"^(a|b\g'1'c)")); + res.add(new RegExp(r"^(a|b\g'-1'c)")); + res.add(new RegExp(r"(^(a|b\g<-1>c))")); + res.add(new RegExp(r"(^(a|b\g<-1'c))")); + res.add(new RegExp(r"(^(a|b\g{-1}))")); + res.add(new RegExp(r"(\3)(\1)(a)")); + res.add(new RegExp(r"(\3)(\1)(a)")); + res.add(new RegExp(r"TA]")); + res.add(new RegExp(r"TA]")); + res.add(new RegExp(r"a[]b")); + res.add(new RegExp(r"a[^]b")); + res.add(new RegExp(r"a[]b")); + res.add(new RegExp(r"a[]+b")); + res.add(new RegExp(r"a[^]b")); + res.add(new RegExp(r"a[^]+b")); + res.add(new RegExp(r"a(?!)+b")); + res.add(new RegExp(r"(abc|pqr|123){0}[xyz]", caseSensitive: false)); + res.add(new RegExp(r" End of testinput2 ")); + res.add(new RegExp(r"a.b")); + res.add(new RegExp(r"a(.{3})b")); + res.add(new RegExp(r"a(.*?)(.)")); + res.add(new RegExp(r"a(.*?)(.)")); + res.add(new RegExp(r"a(.*)(.)")); + res.add(new RegExp(r"a(.*)(.)")); + res.add(new RegExp(r"a(.)(.)")); + res.add(new RegExp(r"a(.)(.)")); + res.add(new RegExp(r"a(.?)(.)")); + res.add(new RegExp(r"a(.?)(.)")); + res.add(new RegExp(r"a(.??)(.)")); + res.add(new RegExp(r"a(.??)(.)")); + res.add(new RegExp(r"a(.{3})b")); + res.add(new RegExp(r"a(.{3,})b")); + res.add(new RegExp(r"a(.{3,}?)b")); + res.add(new RegExp(r"a(.{3,5})b")); + res.add(new RegExp(r"a(.{3,5}?)b")); + res.add(new RegExp(r"X(\C{3})")); + res.add(new RegExp(r"X(\C{4})")); + res.add(new RegExp(r"X\C*")); + res.add(new RegExp(r"X\C*?")); + res.add(new RegExp(r"X\C{3,5}")); + res.add(new RegExp(r"X\C{3,5}?")); + res.add(new RegExp(r"[^a]+")); + res.add(new RegExp(r"^[^a]{2}")); + res.add(new RegExp(r"^[^a]{2,}")); + res.add(new RegExp(r"^[^a]{2,}?")); + res.add(new RegExp(r"[^a]+", caseSensitive: false)); + res.add(new RegExp(r"^[^a]{2}", caseSensitive: false)); + res.add(new RegExp(r"^[^a]{2,}", caseSensitive: false)); + res.add(new RegExp(r"^[^a]{2,}?", caseSensitive: false)); + res.add(new RegExp(r"\D*")); + res.add(new RegExp(r"\D*")); + res.add(new RegExp(r"\D")); + res.add(new RegExp(r">\S")); + res.add(new RegExp(r"\d")); + res.add(new RegExp(r"\s")); + res.add(new RegExp(r"\D+")); + res.add(new RegExp(r"\D{2,3}")); + res.add(new RegExp(r"\D{2,3}?")); + res.add(new RegExp(r"\d+")); + res.add(new RegExp(r"\d{2,3}")); + res.add(new RegExp(r"\d{2,3}?")); + res.add(new RegExp(r"\S+")); + res.add(new RegExp(r"\S{2,3}")); + res.add(new RegExp(r"\S{2,3}?")); + res.add(new RegExp(r">\s+<")); + res.add(new RegExp(r">\s{2,3}<")); + res.add(new RegExp(r">\s{2,3}?<")); + res.add(new RegExp(r"\w+")); + res.add(new RegExp(r"\w{2,3}")); + res.add(new RegExp(r"\w{2,3}?")); + res.add(new RegExp(r"\W+")); + res.add(new RegExp(r"\W{2,3}")); + res.add(new RegExp(r"\W{2,3}?")); + res.add(new RegExp(r"a\Cb")); + res.add(new RegExp(r"a\Cb")); + res.add(new RegExp(r"[\xFF]")); + res.add(new RegExp(r"[\xff]")); + res.add(new RegExp(r"[^\xFF]")); + res.add(new RegExp(r"[^\xff]")); + res.add(new RegExp(r"^[ac]*b")); + res.add(new RegExp(r"^[^x]*b", caseSensitive: false)); + res.add(new RegExp(r"^[^x]*b")); + res.add(new RegExp(r"^\d*b")); + res.add(new RegExp(r"(|a)")); + res.add(new RegExp(r"\S\S")); + res.add(new RegExp(r"\S{2}")); + res.add(new RegExp(r"\W\W")); + res.add(new RegExp(r"\W{2}")); + res.add(new RegExp(r"\S")); + res.add(new RegExp(r"[\S]")); + res.add(new RegExp(r"\D")); + res.add(new RegExp(r"[\D]")); + res.add(new RegExp(r"\W")); + res.add(new RegExp(r"[\W]")); + res.add(new RegExp(r"[\S\s]*")); + res.add(new RegExp(r".[^\S].")); + res.add(new RegExp(r".[^\S\n].")); + res.add(new RegExp(r"[[:^alnum:]]")); + res.add(new RegExp(r"[[:^alpha:]]")); + res.add(new RegExp(r"[[:^ascii:]]")); + res.add(new RegExp(r"[[:^blank:]]")); + res.add(new RegExp(r"[[:^cntrl:]]")); + res.add(new RegExp(r"[[:^digit:]]")); + res.add(new RegExp(r"[[:^graph:]]")); + res.add(new RegExp(r"[[:^lower:]]")); + res.add(new RegExp(r"[[:^print:]]")); + res.add(new RegExp(r"[[:^punct:]]")); + res.add(new RegExp(r"[[:^space:]]")); + res.add(new RegExp(r"[[:^upper:]]")); + res.add(new RegExp(r"[[:^word:]]")); + res.add(new RegExp(r"[[:^xdigit:]]")); + res.add(new RegExp(r"^[^d]*?$")); + res.add(new RegExp(r"^[^d]*?$")); + res.add(new RegExp(r"^[^d]*?$", caseSensitive: false)); + res.add(new RegExp(r"^[^d]*?$", caseSensitive: false)); + res.add(new RegExp(r" End of testinput4 ")); + res.add(new RegExp(r"\x80")); + res.add(new RegExp(r"\xff")); + res.add(new RegExp(r".{3,5}X")); + res.add(new RegExp(r".{3,5}?")); + res.add(new RegExp(r"X(\C)(.*)")); + res.add(new RegExp(r"^[ab]")); + res.add(new RegExp(r"^[^ab]")); + res.add(new RegExp(r"[^ab\xC0-\xF0]")); + res.add(new RegExp(r"[\xFF]")); + res.add(new RegExp(r"[\xff]")); + res.add(new RegExp(r"[^\xFF]")); + res.add(new RegExp(r"[^\xff]")); + res.add(new RegExp(r"anything")); + res.add(new RegExp(r"\W")); + res.add(new RegExp(r"\w")); + res.add(new RegExp(r"\777", caseSensitive: false)); + res.add(new RegExp(r"\777", caseSensitive: false)); + res.add(new RegExp(r"^abc.", multiLine: true)); + res.add(new RegExp(r"abc.$", multiLine: true)); + res.add(new RegExp(r"^a\Rb", caseSensitive: false)); + res.add(new RegExp(r"^a\R*b", caseSensitive: false)); + res.add(new RegExp(r"^a\R+b", caseSensitive: false)); + res.add(new RegExp(r"^a\R{1,3}b", caseSensitive: false)); + res.add(new RegExp(r"\H\h\V\v")); + res.add(new RegExp(r"\H*\h+\V?\v{3,4}")); + res.add(new RegExp(r"\H\h\V\v")); + res.add(new RegExp(r"\H*\h+\V?\v{3,4}")); + res.add(new RegExp(r"[\h]")); + res.add(new RegExp(r"[\h]{3,}")); + res.add(new RegExp(r"[\v]")); + res.add(new RegExp(r"[\H]")); + res.add(new RegExp(r"[\V]")); + res.add(new RegExp(r".*$")); + res.add(new RegExp(r"X")); + res.add(new RegExp(r"a\Rb", caseSensitive: false)); + res.add(new RegExp(r"a\Rb", caseSensitive: false)); + res.add(new RegExp(r"a\R?b", caseSensitive: false)); + res.add(new RegExp(r"a\R?b", caseSensitive: false)); + res.add(new RegExp(r".*a.*=.b.*")); + res.add(new RegExp(r"a[^]b")); + res.add(new RegExp(r"a[^]+b")); + res.add(new RegExp(r"X")); + res.add(new RegExp(r" End of testinput5 ")); + res.add(new RegExp(r"^\pC\pL\pM\pN\pP\pS\pZ<")); + res.add(new RegExp(r"^\PC")); + res.add(new RegExp(r"^\PL")); + res.add(new RegExp(r"^\PM")); + res.add(new RegExp(r"^\PN")); + res.add(new RegExp(r"^\PP")); + res.add(new RegExp(r"^\PS")); + res.add(new RegExp(r"^\PZ")); + res.add(new RegExp(r"^\p{Cc}")); + res.add(new RegExp(r"^\p{Cf}")); + res.add(new RegExp(r"^\p{Cn}")); + res.add(new RegExp(r"^\p{Co}")); + res.add(new RegExp(r"^\p{Cs}")); + res.add(new RegExp(r"^\p{Ll}")); + res.add(new RegExp(r"^\p{Lm}")); + res.add(new RegExp(r"^\p{Lo}")); + res.add(new RegExp(r"^\p{Lt}")); + res.add(new RegExp(r"^\p{Lu}")); + res.add(new RegExp(r"^\p{Mc}")); + res.add(new RegExp(r"^\p{Me}")); + res.add(new RegExp(r"^\p{Mn}")); + res.add(new RegExp(r"^\p{Nl}")); + res.add(new RegExp(r"^\p{No}")); + res.add(new RegExp(r"^\p{Pc}")); + res.add(new RegExp(r"^\p{Pd}")); + res.add(new RegExp(r"^\p{Pe}")); + res.add(new RegExp(r"^\p{Pf}")); + res.add(new RegExp(r"^\p{Pi}")); + res.add(new RegExp(r"^\p{Po}")); + res.add(new RegExp(r"^\p{Ps}")); + res.add(new RegExp(r"^\p{Sk}")); + res.add(new RegExp(r"^\p{So}")); + res.add(new RegExp(r"^\p{Zl}")); + res.add(new RegExp(r"^\p{Zp}")); + res.add(new RegExp(r"^\p{Zs}")); + res.add(new RegExp(r"\p{Nd}{2,}(..)")); + res.add(new RegExp(r"\p{Nd}{2,}?(..)")); + res.add(new RegExp(r"\p{Nd}*(..)")); + res.add(new RegExp(r"\p{Nd}*?(..)")); + res.add(new RegExp(r"\p{Nd}{2}(..)")); + res.add(new RegExp(r"\p{Nd}{2,3}(..)")); + res.add(new RegExp(r"\p{Nd}{2,3}?(..)")); + res.add(new RegExp(r"\p{Nd}?(..)")); + res.add(new RegExp(r"\p{Nd}??(..)")); + res.add(new RegExp(r"\p{Lu}", caseSensitive: false)); + res.add(new RegExp(r"\p{^Lu}", caseSensitive: false)); + res.add(new RegExp(r"\P{Lu}", caseSensitive: false)); + res.add(new RegExp(r"[\p{L}]")); + res.add(new RegExp(r"[\p{^L}]")); + res.add(new RegExp(r"[\P{L}]")); + res.add(new RegExp(r"[\P{^L}]")); + res.add(new RegExp(r"[\p{Nd}]")); + res.add(new RegExp(r"[\P{Nd}]+")); + res.add(new RegExp(r"\D+")); + res.add(new RegExp(r"[\D]+")); + res.add(new RegExp(r"[\P{Nd}]+")); + res.add(new RegExp(r"[\D\P{Nd}]+")); + res.add(new RegExp(r"\pL")); + res.add(new RegExp(r"\pL", caseSensitive: false)); + res.add(new RegExp(r"\p{Lu}")); + res.add(new RegExp(r"\p{Lu}", caseSensitive: false)); + res.add(new RegExp(r"\p{Ll}")); + res.add(new RegExp(r"\p{Ll}", caseSensitive: false)); + res.add(new RegExp(r"^\X")); + res.add(new RegExp(r"^[\X]")); + res.add(new RegExp(r"^(\X*)C")); + res.add(new RegExp(r"^(\X*?)C")); + res.add(new RegExp(r"^(\X*)(.)")); + res.add(new RegExp(r"^(\X*?)(.)")); + res.add(new RegExp(r"^\X(.)")); + res.add(new RegExp(r"^\X{2,3}(.)")); + res.add(new RegExp(r"^\X{2,3}?(.)")); + res.add(new RegExp(r"^[\p{Arabic}]")); + res.add(new RegExp(r"^[\P{Yi}]")); + res.add(new RegExp(r"^\p{Any}X")); + res.add(new RegExp(r"^\P{Any}X")); + res.add(new RegExp(r"^\p{Any}?X")); + res.add(new RegExp(r"^\P{Any}?X")); + res.add(new RegExp(r"^\p{Any}*X")); + res.add(new RegExp(r"^\P{Any}*X")); + res.add(new RegExp(r"^[\p{Any}]X")); + res.add(new RegExp(r"^[\P{Any}]X")); + res.add(new RegExp(r"^[\p{Any}]?X")); + res.add(new RegExp(r"^[\P{Any}]?X")); + res.add(new RegExp(r"^[\p{Any}]+X")); + res.add(new RegExp(r"^[\P{Any}]+X")); + res.add(new RegExp(r"^[\p{Any}]*X")); + res.add(new RegExp(r"^[\P{Any}]*X")); + res.add(new RegExp(r"^\p{Any}{3,5}?")); + res.add(new RegExp(r"^\p{Any}{3,5}")); + res.add(new RegExp(r"^\P{Any}{3,5}?")); + res.add(new RegExp(r"^\p{L&}X")); + res.add(new RegExp(r"^[\p{L&}]X")); + res.add(new RegExp(r"^[\p{L&}]+X")); + res.add(new RegExp(r"^[\p{L&}]+?X")); + res.add(new RegExp(r"^\P{L&}X")); + res.add(new RegExp(r"^[\P{L&}]X")); + res.add(new RegExp(r"^(\p{Z}[^\p{C}\p{Z}]+)*$")); + res.add(new RegExp(r"([\pL]=(abc))*X")); + res.add(new RegExp( + r"^\p{Balinese}\p{Cuneiform}\p{Nko}\p{Phags_Pa}\p{Phoenician}")); + res.add(new RegExp( + r"The next two are special cases where the lengths of the different cases of the \nsame character differ. The first went wrong with heap frame storage; the 2nd\nwas broken in all cases.")); + res.add(new RegExp(r"Check property support in non-UTF-8 mode")); + res.add(new RegExp(r"\p{L}{4}")); + res.add(new RegExp(r"\X{1,3}\d")); + res.add(new RegExp(r"\X?\d")); + res.add(new RegExp(r"\P{L}?\d")); + res.add(new RegExp(r"[\PPP\x8a]{1,}\x80")); + res.add(new RegExp(r"(?:[\PPa*]*){8,}")); + res.add(new RegExp(r"[\P{Any}]")); + res.add(new RegExp(r"[\P{Any}\E]")); + res.add(new RegExp(r"(\P{Yi}{2}\277)?")); + res.add(new RegExp(r"[\P{Yi}A]")); + res.add(new RegExp(r"[\P{Yi}\P{Yi}\P{Yi}A]")); + res.add(new RegExp(r"[^\P{Yi}A]")); + res.add(new RegExp(r"[^\P{Yi}\P{Yi}\P{Yi}A]")); + res.add(new RegExp(r"(\P{Yi}*\277)*")); + res.add(new RegExp(r"(\P{Yi}*?\277)*")); + res.add(new RegExp(r"(\P{Yi}?\277)*")); + res.add(new RegExp(r"(\P{Yi}??\277)*")); + res.add(new RegExp(r"(\P{Yi}{0,3}\277)*")); + res.add(new RegExp(r"(\P{Yi}{0,3}?\277)*")); + res.add(new RegExp(r"^[\p{Arabic}]")); + res.add(new RegExp(r"^\p{Cyrillic}")); + res.add(new RegExp(r"^\p{Common}")); + res.add(new RegExp(r"^\p{Inherited}")); + res.add(new RegExp(r"^\p{Shavian}")); + res.add(new RegExp(r"^\p{Deseret}")); + res.add(new RegExp(r"^\p{Osmanya}")); + res.add(new RegExp(r"\p{Zl}")); + res.add(new RegExp( + r"\p{Carian}\p{Cham}\p{Kayah_Li}\p{Lepcha}\p{Lycian}\p{Lydian}\p{Ol_Chiki}\p{Rejang}\p{Saurashtra}\p{Sundanese}\p{Vai}")); + res.add(new RegExp(r"(A)\1", caseSensitive: false)); + res.add(new RegExp(r" End of testinput6 ")); + res.add(new RegExp(r"abc")); + res.add(new RegExp(r"ab*c")); + res.add(new RegExp(r"ab+c")); + res.add(new RegExp(r"a*")); + res.add(new RegExp(r"(a|abcd|african)")); + res.add(new RegExp(r"^abc")); + res.add(new RegExp(r"^abc", multiLine: true)); + res.add(new RegExp(r"\Aabc")); + res.add(new RegExp(r"\Aabc", multiLine: true)); + res.add(new RegExp(r"\Gabc")); + res.add(new RegExp(r"x\dy\Dz")); + res.add(new RegExp(r"x\sy\Sz")); + res.add(new RegExp(r"x\wy\Wz")); + res.add(new RegExp(r"x.y")); + res.add(new RegExp(r"x.y")); + res.add(new RegExp(r"a\d\z")); + res.add(new RegExp(r"a\d\z", multiLine: true)); + res.add(new RegExp(r"a\d\Z")); + res.add(new RegExp(r"a\d\Z", multiLine: true)); + res.add(new RegExp(r"a\d$")); + res.add(new RegExp(r"a\d$", multiLine: true)); + res.add(new RegExp(r"abc", caseSensitive: false)); + res.add(new RegExp(r"[^a]")); + res.add(new RegExp(r"ab?\w")); + res.add(new RegExp(r"x{0,3}yz")); + res.add(new RegExp(r"x{3}yz")); + res.add(new RegExp(r"x{2,3}yz")); + res.add(new RegExp(r"[^a]+")); + res.add(new RegExp(r"[^a]*")); + res.add(new RegExp(r"[^a]{3,5}")); + res.add(new RegExp(r"\d*")); + res.add(new RegExp(r"\D*")); + res.add(new RegExp(r"\d+")); + res.add(new RegExp(r"\D+")); + res.add(new RegExp(r"\d?A")); + res.add(new RegExp(r"\D?A")); + res.add(new RegExp(r"a+")); + res.add(new RegExp(r"^.*xyz")); + res.add(new RegExp(r"^.+xyz")); + res.add(new RegExp(r"^.?xyz")); + res.add(new RegExp(r"^\d{2,3}X")); + res.add(new RegExp(r"^[abcd]\d")); + res.add(new RegExp(r"^[abcd]*\d")); + res.add(new RegExp(r"^[abcd]+\d")); + res.add(new RegExp(r"^a+X")); + res.add(new RegExp(r"^[abcd]?\d")); + res.add(new RegExp(r"^[abcd]{2,3}\d")); + res.add(new RegExp(r"^(abc)*\d")); + res.add(new RegExp(r"^(abc)+\d")); + res.add(new RegExp(r"^(abc)?\d")); + res.add(new RegExp(r"^(abc){2,3}\d")); + res.add(new RegExp(r"^(a*\w|ab)=(a*\w|ab)")); + res.add(new RegExp(r"^(?=abc)\w{5}:$")); + res.add(new RegExp(r"^(?!abc)\d\d$")); + res.add(new RegExp(r"(ab|cd){3,4}")); + res.add(new RegExp(r"^abc")); + res.add(new RegExp(r"^(a*|xyz)")); + res.add(new RegExp(r"xyz$")); + res.add(new RegExp(r"xyz$", multiLine: true)); + res.add(new RegExp(r"\Gabc")); + res.add(new RegExp(r"^abcdef")); + res.add(new RegExp(r"^a{2,4}\d+z")); + res.add(new RegExp(r"^abcdef")); + res.add(new RegExp(r"(ab*(cd|ef))+X")); + res.add(new RegExp(r"the quick brown fox")); + res.add(new RegExp(r"The quick brown fox", caseSensitive: false)); + res.add(new RegExp(r"abcd\t\n\r\f\a\e\071\x3b\$\\\?caxyz")); + res.add(new RegExp(r"a*abc?xyz+pqr{3}ab{2,}xy{4,5}pq{0,6}AB{0,}zz")); + res.add(new RegExp(r"^(abc){1,2}zz")); + res.add(new RegExp(r"^(b+?|a){1,2}?c")); + res.add(new RegExp(r"^(b+|a){1,2}c")); + res.add(new RegExp(r"^(b*|ba){1,2}?bc")); + res.add(new RegExp(r"^(ba|b*){1,2}?bc")); + res.add(new RegExp(r"^[ab\]cde]")); + res.add(new RegExp(r"^[]cde]")); + res.add(new RegExp(r"^[^ab\]cde]")); + res.add(new RegExp(r"^[^]cde]")); + res.add(new RegExp(r"^[0-9]+$")); + res.add(new RegExp(r"^.*nter")); + res.add(new RegExp(r"^xxx[0-9]+$")); + res.add(new RegExp(r"^.+[0-9][0-9][0-9]$")); + res.add(new RegExp(r"^.+?[0-9][0-9][0-9]$")); + res.add(new RegExp(r"^([^!]+)!(.+)=apquxz\.ixr\.zzz\.ac\.uk$")); + res.add(new RegExp(r":")); + res.add(new RegExp(r"([\da-f:]+)$", caseSensitive: false)); + res.add(new RegExp(r"^.*\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$")); + res.add(new RegExp(r"^(\d+)\s+IN\s+SOA\s+(\S+)\s+(\S+)\s*\(\s*$")); + res.add( + new RegExp(r"^[a-zA-Z\d][a-zA-Z\d\-]*(\.[a-zA-Z\d][a-zA-z\d\-]*)*\.$")); + res.add(new RegExp( + r"^\*\.[a-z]([a-z\-\d]*[a-z\d]+)?(\.[a-z]([a-z\-\d]*[a-z\d]+)?)*$")); + res.add(new RegExp(r"^(?=ab(de))(abd)(e)")); + res.add(new RegExp(r"^(?!(ab)de|x)(abd)(f)")); + res.add(new RegExp(r"^(?=(ab(cd)))(ab)")); + res.add(new RegExp(r"^[\da-f](\.[\da-f])*$", caseSensitive: false)); + res.add(new RegExp(r'^\".*\"\s*(;.*)?$')); + res.add(new RegExp(r"^$")); + res.add(new RegExp(r"^ab\sc$")); + res.add(new RegExp(r"^a\ b[c]d$")); + res.add(new RegExp(r"^(a(b(c)))(d(e(f)))(h(i(j)))(k(l(m)))$")); + res.add(new RegExp(r"^(?:a(b(c)))(?:d(e(f)))(?:h(i(j)))(?:k(l(m)))$")); + res.add(new RegExp(r"^[\w][\W][\s][\S][\d][\D][\b][\n][\c]][\022]")); + res.add(new RegExp(r"^a*\w")); + res.add(new RegExp(r"^a*?\w")); + res.add(new RegExp(r"^a+\w")); + res.add(new RegExp(r"^a+?\w")); + res.add(new RegExp(r"^\d{8}\w{2,}")); + res.add(new RegExp(r"^[aeiou\d]{4,5}$")); + res.add(new RegExp(r"^[aeiou\d]{4,5}?")); + res.add(new RegExp( + r"^From +([^ ]+) +[a-zA-Z][a-zA-Z][a-zA-Z] +[a-zA-Z][a-zA-Z][a-zA-Z] +[0-9]?[0-9] +[0-9][0-9]:[0-9][0-9]")); + res.add(new RegExp(r"^From\s+\S+\s+([a-zA-Z]{3}\s+){2}\d{1,2}\s+\d\d:\d\d")); + res.add(new RegExp(r"^12.34")); + res.add(new RegExp(r"\w+(?=\t)")); + res.add(new RegExp(r"foo(?!bar)(.*)")); + res.add(new RegExp(r"(?:(?!foo)...|^.{0,2})bar(.*)")); + res.add(new RegExp(r"^(\D*)(?=\d)(?!123)")); + res.add(new RegExp(r"^1234")); + res.add(new RegExp(r"^1234")); + res.add(new RegExp(r"abcd")); + res.add(new RegExp(r"^abcd")); + res.add(new RegExp(r"(?!^)abc")); + res.add(new RegExp(r"(?=^)abc")); + res.add(new RegExp(r"^[ab]{1,3}(ab*|b)")); + res.add(new RegExp(r"^[ab]{1,3}?(ab*|b)")); + res.add(new RegExp(r"^[ab]{1,3}?(ab*?|b)")); + res.add(new RegExp(r"^[ab]{1,3}(ab*?|b)")); + res.add(new RegExp( + r'(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*(?:(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"(?:[^\\\x80-\xff\n\015"]|\\[^\x80-\xff])*")(?:(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*\.(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"(?:[^\\\x80-\xff\n\015"]|\\[^\x80-\xff])*"))*(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*@(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])(?:(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*\.(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\]))*|(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"(?:[^\\\x80-\xff\n\015"]|\\[^\x80-\xff])*")(?:[^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\)|"(?:[^\\\x80-\xff\n\015"]|\\[^\x80-\xff])*")*<(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*(?:@(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])(?:(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*\.(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\]))*(?:(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*,(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*@(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])(?:(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*\.(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\]))*)*:(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*)?(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"(?:[^\\\x80-\xff\n\015"]|\\[^\x80-\xff])*")(?:(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*\.(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"(?:[^\\\x80-\xff\n\015"]|\\[^\x80-\xff])*"))*(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*@(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])(?:(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*\.(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\]))*(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*>)(?:[\040\t]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff]|\((?:[^\\\x80-\xff\n\015()]|\\[^\x80-\xff])*\))*\))*')); + res.add(new RegExp( + r'[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"[^\\\x80-\xff\n\015"]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015"]*)*")[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"[^\\\x80-\xff\n\015"]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015"]*)*")[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)*@[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)*|(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"[^\\\x80-\xff\n\015"]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015"]*)*")[^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037]*(?:(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)|"[^\\\x80-\xff\n\015"]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015"]*)*")[^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037]*)*<[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:@[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)*(?:,[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*@[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)*)*:[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)?(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"[^\\\x80-\xff\n\015"]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015"]*)*")[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"[^\\\x80-\xff\n\015"]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015"]*)*")[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)*@[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)*>)')); + res.add(new RegExp(r"abc\x0def\x00pqr\x000xyz\x0000AB")); + res.add(new RegExp(r"^[\000-\037]")); + res.add(new RegExp(r"\0*")); + res.add(new RegExp(r"A\x0{2,3}Z")); + res.add(new RegExp(r"^\s")); + res.add(new RegExp(r"^abc")); + res.add(new RegExp(r"ab{1,3}bc")); + res.add(new RegExp(r"([^.]*)\.([^:]*):[T ]+(.*)")); + res.add(new RegExp(r"([^.]*)\.([^:]*):[T ]+(.*)", caseSensitive: false)); + res.add(new RegExp(r"([^.]*)\.([^:]*):[t ]+(.*)", caseSensitive: false)); + res.add(new RegExp(r"^[W-c]+$")); + res.add(new RegExp(r"^[W-c]+$", caseSensitive: false)); + res.add(new RegExp(r"^[\x3f-\x5F]+$", caseSensitive: false)); + res.add(new RegExp(r"^abc$", multiLine: true)); + res.add(new RegExp(r"^abc$")); + res.add(new RegExp(r"\Aabc\Z", multiLine: true)); + res.add(new RegExp(r"\A(.)*\Z")); + res.add(new RegExp(r"\A(.)*\Z", multiLine: true)); + res.add(new RegExp(r"(?:b)|(?::+)")); + res.add(new RegExp(r"[-az]+")); + res.add(new RegExp(r"[az-]+")); + res.add(new RegExp(r"[a\-z]+")); + res.add(new RegExp(r"[a-z]+")); + res.add(new RegExp(r"[\d-]+")); + res.add(new RegExp(r"[\d-z]+")); + res.add(new RegExp(r"\x5c")); + res.add(new RegExp(r"\x20Z")); + res.add(new RegExp(r"ab{3cd")); + res.add(new RegExp(r"ab{3,cd")); + res.add(new RegExp(r"ab{3,4a}cd")); + res.add(new RegExp(r"{4,5a}bc")); + res.add(new RegExp(r"^a.b")); + res.add(new RegExp(r"abc$")); + res.add(new RegExp(r"(abc)\123")); + res.add(new RegExp(r"(abc)\223")); + res.add(new RegExp(r"(abc)\323")); + res.add(new RegExp(r"(abc)\100")); + res.add(new RegExp(r"abc\81")); + res.add(new RegExp(r"abc\91")); + res.add(new RegExp(r"(a)(b)(c)(d)(e)(f)(g)(h)(i)(j)(k)\12\123")); + res.add(new RegExp(r"ab\idef")); + res.add(new RegExp(r"a{0}bc")); + res.add(new RegExp(r"(a|(bc)){0,0}?xyz")); + res.add(new RegExp(r"abc[\10]de")); + res.add(new RegExp(r"abc[\1]de")); + res.add(new RegExp(r"(abc)[\1]de")); + res.add(new RegExp(r"^([^a])([^\b])([^c]*)([^d]{3,4})")); + res.add(new RegExp(r"[^a]")); + res.add(new RegExp(r"[^a]", caseSensitive: false)); + res.add(new RegExp(r"[^a]+")); + res.add(new RegExp(r"[^a]+", caseSensitive: false)); + res.add(new RegExp(r"[^a]+")); + res.add(new RegExp(r"[^k]$")); + res.add(new RegExp(r"[^k]{2,3}$")); + res.add(new RegExp(r"^\d{8,}\@.+[^k]$")); + res.add(new RegExp(r"[^a]")); + res.add(new RegExp(r"[^a]", caseSensitive: false)); + res.add(new RegExp(r"[^az]")); + res.add(new RegExp(r"[^az]", caseSensitive: false)); + res.add(new RegExp( + r"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037\040\041\042\043\044\045\046\047\050\051\052\053\054\055\056\057\060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077\100\101\102\103\104\105\106\107\110\111\112\113\114\115\116\117\120\121\122\123\124\125\126\127\130\131\132\133\134\135\136\137\140\141\142\143\144\145\146\147\150\151\152\153\154\155\156\157\160\161\162\163\164\165\166\167\170\171\172\173\174\175\176\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377")); + res.add(new RegExp(r"P[^*]TAIRE[^*]{1,6}?LL")); + res.add(new RegExp(r"P[^*]TAIRE[^*]{1,}?LL")); + res.add(new RegExp(r"(\.\d\d[1-9]?)\d+")); + res.add(new RegExp(r"(\.\d\d((?=0)|\d(?=\d)))")); + res.add(new RegExp(r"\b(foo)\s+(\w+)", caseSensitive: false)); + res.add(new RegExp(r"foo(.*)bar")); + res.add(new RegExp(r"foo(.*?)bar")); + res.add(new RegExp(r"(.*)(\d*)")); + res.add(new RegExp(r"(.*)(\d+)")); + res.add(new RegExp(r"(.*?)(\d*)")); + res.add(new RegExp(r"(.*?)(\d+)")); + res.add(new RegExp(r"(.*)(\d+)$")); + res.add(new RegExp(r"(.*?)(\d+)$")); + res.add(new RegExp(r"(.*)\b(\d+)$")); + res.add(new RegExp(r"(.*\D)(\d+)$")); + res.add(new RegExp(r"^\D*(?!123)")); + res.add(new RegExp(r"^(\D*)(?=\d)(?!123)")); + res.add(new RegExp(r"^[W-]46]")); + res.add(new RegExp(r"^[W-\]46]")); + res.add(new RegExp(r"\d\d\/\d\d\/\d\d\d\d")); + res.add(new RegExp(r"word (?:[a-zA-Z0-9]+ ){0,10}otherword")); + res.add(new RegExp(r"word (?:[a-zA-Z0-9]+ ){0,300}otherword")); + res.add(new RegExp(r"^(a){0,0}")); + res.add(new RegExp(r"^(a){0,1}")); + res.add(new RegExp(r"^(a){0,2}")); + res.add(new RegExp(r"^(a){0,3}")); + res.add(new RegExp(r"^(a){0,}")); + res.add(new RegExp(r"^(a){1,1}")); + res.add(new RegExp(r"^(a){1,2}")); + res.add(new RegExp(r"^(a){1,3}")); + res.add(new RegExp(r"^(a){1,}")); + res.add(new RegExp(r".*\.gif")); + res.add(new RegExp(r".{0,}\.gif")); + res.add(new RegExp(r".*\.gif", multiLine: true)); + res.add(new RegExp(r".*\.gif")); + res.add(new RegExp(r".*\.gif", multiLine: true)); + res.add(new RegExp(r".*$")); + res.add(new RegExp(r".*$", multiLine: true)); + res.add(new RegExp(r".*$")); + res.add(new RegExp(r".*$", multiLine: true)); + res.add(new RegExp(r".*$")); + res.add(new RegExp(r".*$", multiLine: true)); + res.add(new RegExp(r".*$")); + res.add(new RegExp(r".*$", multiLine: true)); + res.add(new RegExp(r"(.*X|^B)")); + res.add(new RegExp(r"(.*X|^B)", multiLine: true)); + res.add(new RegExp(r"(.*X|^B)")); + res.add(new RegExp(r"(.*X|^B)", multiLine: true)); + res.add(new RegExp(r"^.*B")); + res.add(new RegExp( + r"^[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]")); + res.add(new RegExp(r"^\d\d\d\d\d\d\d\d\d\d\d\d")); + res.add(new RegExp(r"^[\d][\d][\d][\d][\d][\d][\d][\d][\d][\d][\d][\d]")); + res.add(new RegExp(r"^[abc]{12}")); + res.add(new RegExp(r"^[a-c]{12}")); + res.add(new RegExp(r"^(a|b|c){12}")); + res.add(new RegExp(r"^[abcdefghijklmnopqrstuvwxy0123456789]")); + res.add(new RegExp(r"abcde{0,0}")); + res.add(new RegExp(r"ab[cd]{0,0}e")); + res.add(new RegExp(r"ab(c){0,0}d")); + res.add(new RegExp(r"a(b*)")); + res.add(new RegExp(r"ab\d{0}e")); + res.add(new RegExp(r'"([^\\"]+|\\.)*"')); + res.add(new RegExp(r".*?")); + res.add(new RegExp(r"\b")); + res.add(new RegExp(r"\b")); + res.add(new RegExp( + r"]{0,})>]{0,})>([\d]{0,}\.)(.*)((
([\w\W\s\d][^<>]{0,})|[\s]{0,}))<\/a><\/TD>]{0,})>([\w\W\s\d][^<>]{0,})<\/TD>]{0,})>([\w\W\s\d][^<>]{0,})<\/TD><\/TR>", + caseSensitive: false)); + res.add(new RegExp(r"a[^a]b")); + res.add(new RegExp(r"a.b")); + res.add(new RegExp(r"a[^a]b")); + res.add(new RegExp(r"a.b")); + res.add(new RegExp(r"^(b+?|a){1,2}?c")); + res.add(new RegExp(r"^(b+|a){1,2}?c")); + res.add(new RegExp(r"(?!\A)x", multiLine: true)); + res.add(new RegExp(r"\x0{ab}")); + res.add(new RegExp(r"(A|B)*?CD")); + res.add(new RegExp(r"(A|B)*CD")); + res.add(new RegExp(r"\Aabc\z", multiLine: true)); + res.add(new RegExp(r"(\d+)(\w)")); + res.add(new RegExp(r"(a+|b+|c+)*c")); + res.add(new RegExp(r"(abc|)+")); + res.add(new RegExp(r"([a]*)*")); + res.add(new RegExp(r"([ab]*)*")); + res.add(new RegExp(r"([^a]*)*")); + res.add(new RegExp(r"([^ab]*)*")); + res.add(new RegExp(r"([a]*?)*")); + res.add(new RegExp(r"([ab]*?)*")); + res.add(new RegExp(r"([^a]*?)*")); + res.add(new RegExp(r"([^ab]*?)*")); + res.add(new RegExp( + r"The following tests are taken from the Perl 5.005 test suite; some of them")); + res.add(new RegExp( + r"are compatible with 5.004, but I'd rather not have to sort them out.")); + res.add(new RegExp(r"abc")); + res.add(new RegExp(r"ab*c")); + res.add(new RegExp(r"ab*bc")); + res.add(new RegExp(r".{1}")); + res.add(new RegExp(r".{3,4}")); + res.add(new RegExp(r"ab{0,}bc")); + res.add(new RegExp(r"ab+bc")); + res.add(new RegExp(r"ab{1,}bc")); + res.add(new RegExp(r"ab+bc")); + res.add(new RegExp(r"ab{1,}bc")); + res.add(new RegExp(r"ab{1,3}bc")); + res.add(new RegExp(r"ab{3,4}bc")); + res.add(new RegExp(r"ab{4,5}bc")); + res.add(new RegExp(r"ab?bc")); + res.add(new RegExp(r"ab{0,1}bc")); + res.add(new RegExp(r"ab?bc")); + res.add(new RegExp(r"ab?c")); + res.add(new RegExp(r"ab{0,1}c")); + res.add(new RegExp(r"^abc$")); + res.add(new RegExp(r"^abc")); + res.add(new RegExp(r"^abc$")); + res.add(new RegExp(r"abc$")); + res.add(new RegExp(r"^")); + res.add(new RegExp(r"$")); + res.add(new RegExp(r"a.c")); + res.add(new RegExp(r"a.*c")); + res.add(new RegExp(r"a[bc]d")); + res.add(new RegExp(r"a[b-d]e")); + res.add(new RegExp(r"a[b-d]")); + res.add(new RegExp(r"a[-b]")); + res.add(new RegExp(r"a[b-]")); + res.add(new RegExp(r"a]")); + res.add(new RegExp(r"a[]]b")); + res.add(new RegExp(r"a[^bc]d")); + res.add(new RegExp(r"a[^-b]c")); + res.add(new RegExp(r"a[^]b]c")); + res.add(new RegExp(r"\ba\b")); + res.add(new RegExp(r"\by\b")); + res.add(new RegExp(r"\Ba\B")); + res.add(new RegExp(r"\By\b")); + res.add(new RegExp(r"\by\B")); + res.add(new RegExp(r"\By\B")); + res.add(new RegExp(r"\w")); + res.add(new RegExp(r"\W")); + res.add(new RegExp(r"a\sb")); + res.add(new RegExp(r"a\Sb")); + res.add(new RegExp(r"\d")); + res.add(new RegExp(r"\D")); + res.add(new RegExp(r"[\w]")); + res.add(new RegExp(r"[\W]")); + res.add(new RegExp(r"a[\s]b")); + res.add(new RegExp(r"a[\S]b")); + res.add(new RegExp(r"[\d]")); + res.add(new RegExp(r"[\D]")); + res.add(new RegExp(r"ab|cd")); + res.add(new RegExp(r"()ef")); + res.add(new RegExp(r"$b")); + res.add(new RegExp(r"a\(b")); + res.add(new RegExp(r"a\\b")); + res.add(new RegExp(r"((a))")); + res.add(new RegExp(r"(a)b(c)")); + res.add(new RegExp(r"a+b+c")); + res.add(new RegExp(r"a{1,}b{1,}c")); + res.add(new RegExp(r"a.+?c")); + res.add(new RegExp(r"(a+|b)*")); + res.add(new RegExp(r"(a+|b){0,}")); + res.add(new RegExp(r"(a+|b)+")); + res.add(new RegExp(r"(a+|b){1,}")); + res.add(new RegExp(r"(a+|b)?")); + res.add(new RegExp(r"(a+|b){0,1}")); + res.add(new RegExp(r"[^ab]*")); + res.add(new RegExp(r"abc")); + res.add(new RegExp(r"a*")); + res.add(new RegExp(r"([abc])*d")); + res.add(new RegExp(r"([abc])*bcd")); + res.add(new RegExp(r"a|b|c|d|e")); + res.add(new RegExp(r"(a|b|c|d|e)f")); + res.add(new RegExp(r"abcd*efg")); + res.add(new RegExp(r"ab*")); + res.add(new RegExp(r"(ab|cd)e")); + res.add(new RegExp(r"[abhgefdc]ij")); + res.add(new RegExp(r"^(ab|cd)e")); + res.add(new RegExp(r"(abc|)ef")); + res.add(new RegExp(r"(a|b)c*d")); + res.add(new RegExp(r"(ab|ab*)bc")); + res.add(new RegExp(r"a([bc]*)c*")); + res.add(new RegExp(r"a([bc]*)(c*d)")); + res.add(new RegExp(r"a([bc]+)(c*d)")); + res.add(new RegExp(r"a([bc]*)(c+d)")); + res.add(new RegExp(r"a[bcd]*dcdcde")); + res.add(new RegExp(r"a[bcd]+dcdcde")); + res.add(new RegExp(r"(ab|a)b*c")); + res.add(new RegExp(r"((a)(b)c)(d)")); + res.add(new RegExp(r"[a-zA-Z_][a-zA-Z0-9_]*")); + res.add(new RegExp(r"^a(bc+|b[eh])g|.h$")); + res.add(new RegExp(r"(bc+d$|ef*g.|h?i(j|k))")); + res.add(new RegExp(r"((((((((((a))))))))))")); + res.add(new RegExp(r"(((((((((a)))))))))")); + res.add(new RegExp(r"multiple words of text")); + res.add(new RegExp(r"multiple words")); + res.add(new RegExp(r"(.*)c(.*)")); + res.add(new RegExp(r"\((.*), (.*)\)")); + res.add(new RegExp(r"[k]")); + res.add(new RegExp(r"abcd")); + res.add(new RegExp(r"a(bc)d")); + res.add(new RegExp(r"a[-]?c")); + res.add(new RegExp(r"abc", caseSensitive: false)); + res.add(new RegExp(r"ab*c", caseSensitive: false)); + res.add(new RegExp(r"ab*bc", caseSensitive: false)); + res.add(new RegExp(r"ab*?bc", caseSensitive: false)); + res.add(new RegExp(r"ab{0,}?bc", caseSensitive: false)); + res.add(new RegExp(r"ab+?bc", caseSensitive: false)); + res.add(new RegExp(r"ab+bc", caseSensitive: false)); + res.add(new RegExp(r"ab{1,}bc", caseSensitive: false)); + res.add(new RegExp(r"ab+bc", caseSensitive: false)); + res.add(new RegExp(r"ab{1,}?bc", caseSensitive: false)); + res.add(new RegExp(r"ab{1,3}?bc", caseSensitive: false)); + res.add(new RegExp(r"ab{3,4}?bc", caseSensitive: false)); + res.add(new RegExp(r"ab{4,5}?bc", caseSensitive: false)); + res.add(new RegExp(r"ab??bc", caseSensitive: false)); + res.add(new RegExp(r"ab{0,1}?bc", caseSensitive: false)); + res.add(new RegExp(r"ab??bc", caseSensitive: false)); + res.add(new RegExp(r"ab??c", caseSensitive: false)); + res.add(new RegExp(r"ab{0,1}?c", caseSensitive: false)); + res.add(new RegExp(r"^abc$", caseSensitive: false)); + res.add(new RegExp(r"^abc", caseSensitive: false)); + res.add(new RegExp(r"^abc$", caseSensitive: false)); + res.add(new RegExp(r"abc$", caseSensitive: false)); + res.add(new RegExp(r"^", caseSensitive: false)); + res.add(new RegExp(r"$", caseSensitive: false)); + res.add(new RegExp(r"a.c", caseSensitive: false)); + res.add(new RegExp(r"a.*?c", caseSensitive: false)); + res.add(new RegExp(r"a.*c", caseSensitive: false)); + res.add(new RegExp(r"a[bc]d", caseSensitive: false)); + res.add(new RegExp(r"a[b-d]e", caseSensitive: false)); + res.add(new RegExp(r"a[b-d]", caseSensitive: false)); + res.add(new RegExp(r"a[-b]", caseSensitive: false)); + res.add(new RegExp(r"a[b-]", caseSensitive: false)); + res.add(new RegExp(r"a]", caseSensitive: false)); + res.add(new RegExp(r"a[]]b", caseSensitive: false)); + res.add(new RegExp(r"a[^bc]d", caseSensitive: false)); + res.add(new RegExp(r"a[^-b]c", caseSensitive: false)); + res.add(new RegExp(r"a[^]b]c", caseSensitive: false)); + res.add(new RegExp(r"ab|cd", caseSensitive: false)); + res.add(new RegExp(r"()ef", caseSensitive: false)); + res.add(new RegExp(r"$b", caseSensitive: false)); + res.add(new RegExp(r"a\(b", caseSensitive: false)); + res.add(new RegExp(r"a\\b", caseSensitive: false)); + res.add(new RegExp(r"((a))", caseSensitive: false)); + res.add(new RegExp(r"(a)b(c)", caseSensitive: false)); + res.add(new RegExp(r"a+b+c", caseSensitive: false)); + res.add(new RegExp(r"a{1,}b{1,}c", caseSensitive: false)); + res.add(new RegExp(r"a.+?c", caseSensitive: false)); + res.add(new RegExp(r"a.*?c", caseSensitive: false)); + res.add(new RegExp(r"a.{0,5}?c", caseSensitive: false)); + res.add(new RegExp(r"(a+|b)*", caseSensitive: false)); + res.add(new RegExp(r"(a+|b){0,}", caseSensitive: false)); + res.add(new RegExp(r"(a+|b)+", caseSensitive: false)); + res.add(new RegExp(r"(a+|b){1,}", caseSensitive: false)); + res.add(new RegExp(r"(a+|b)?", caseSensitive: false)); + res.add(new RegExp(r"(a+|b){0,1}", caseSensitive: false)); + res.add(new RegExp(r"(a+|b){0,1}?", caseSensitive: false)); + res.add(new RegExp(r"[^ab]*", caseSensitive: false)); + res.add(new RegExp(r"abc", caseSensitive: false)); + res.add(new RegExp(r"a*", caseSensitive: false)); + res.add(new RegExp(r"([abc])*d", caseSensitive: false)); + res.add(new RegExp(r"([abc])*bcd", caseSensitive: false)); + res.add(new RegExp(r"a|b|c|d|e", caseSensitive: false)); + res.add(new RegExp(r"(a|b|c|d|e)f", caseSensitive: false)); + res.add(new RegExp(r"abcd*efg", caseSensitive: false)); + res.add(new RegExp(r"ab*", caseSensitive: false)); + res.add(new RegExp(r"(ab|cd)e", caseSensitive: false)); + res.add(new RegExp(r"[abhgefdc]ij", caseSensitive: false)); + res.add(new RegExp(r"^(ab|cd)e", caseSensitive: false)); + res.add(new RegExp(r"(abc|)ef", caseSensitive: false)); + res.add(new RegExp(r"(a|b)c*d", caseSensitive: false)); + res.add(new RegExp(r"(ab|ab*)bc", caseSensitive: false)); + res.add(new RegExp(r"a([bc]*)c*", caseSensitive: false)); + res.add(new RegExp(r"a([bc]*)(c*d)", caseSensitive: false)); + res.add(new RegExp(r"a([bc]+)(c*d)", caseSensitive: false)); + res.add(new RegExp(r"a([bc]*)(c+d)", caseSensitive: false)); + res.add(new RegExp(r"a[bcd]*dcdcde", caseSensitive: false)); + res.add(new RegExp(r"a[bcd]+dcdcde", caseSensitive: false)); + res.add(new RegExp(r"(ab|a)b*c", caseSensitive: false)); + res.add(new RegExp(r"((a)(b)c)(d)", caseSensitive: false)); + res.add(new RegExp(r"[a-zA-Z_][a-zA-Z0-9_]*", caseSensitive: false)); + res.add(new RegExp(r"^a(bc+|b[eh])g|.h$", caseSensitive: false)); + res.add(new RegExp(r"(bc+d$|ef*g.|h?i(j|k))", caseSensitive: false)); + res.add(new RegExp(r"((((((((((a))))))))))", caseSensitive: false)); + res.add(new RegExp(r"(((((((((a)))))))))", caseSensitive: false)); + res.add(new RegExp(r"(?:(?:(?:(?:(?:(?:(?:(?:(?:(a))))))))))", + caseSensitive: false)); + res.add(new RegExp(r"(?:(?:(?:(?:(?:(?:(?:(?:(?:(a|b|c))))))))))", + caseSensitive: false)); + res.add(new RegExp(r"multiple words of text", caseSensitive: false)); + res.add(new RegExp(r"multiple words", caseSensitive: false)); + res.add(new RegExp(r"(.*)c(.*)", caseSensitive: false)); + res.add(new RegExp(r"\((.*), (.*)\)", caseSensitive: false)); + res.add(new RegExp(r"[k]", caseSensitive: false)); + res.add(new RegExp(r"abcd", caseSensitive: false)); + res.add(new RegExp(r"a(bc)d", caseSensitive: false)); + res.add(new RegExp(r"a[-]?c", caseSensitive: false)); + res.add(new RegExp(r"a(?!b).")); + res.add(new RegExp(r"a(?=d).")); + res.add(new RegExp(r"a(?=c|d).")); + res.add(new RegExp(r"a(?:b|c|d)(.)")); + res.add(new RegExp(r"a(?:b|c|d)*(.)")); + res.add(new RegExp(r"a(?:b|c|d)+?(.)")); + res.add(new RegExp(r"a(?:b|c|d)+(.)")); + res.add(new RegExp(r"a(?:b|c|d){2}(.)")); + res.add(new RegExp(r"a(?:b|c|d){4,5}(.)")); + res.add(new RegExp(r"a(?:b|c|d){4,5}?(.)")); + res.add(new RegExp(r"((foo)|(bar))*")); + res.add(new RegExp(r"a(?:b|c|d){6,7}(.)")); + res.add(new RegExp(r"a(?:b|c|d){6,7}?(.)")); + res.add(new RegExp(r"a(?:b|c|d){5,6}(.)")); + res.add(new RegExp(r"a(?:b|c|d){5,6}?(.)")); + res.add(new RegExp(r"a(?:b|c|d){5,7}(.)")); + res.add(new RegExp(r"a(?:b|c|d){5,7}?(.)")); + res.add(new RegExp(r"a(?:b|(c|e){1,2}?|d)+?(.)")); + res.add(new RegExp(r"^(.+)?B")); + res.add(new RegExp(r"^([^a-z])|(\^)$")); + res.add(new RegExp(r"^[<>]&")); + res.add(new RegExp(r"(?:(f)(o)(o)|(b)(a)(r))*")); + res.add(new RegExp(r"(?:..)*a")); + res.add(new RegExp(r"(?:..)*?a")); + res.add(new RegExp(r"^(){3,5}")); + res.add(new RegExp(r"^(a+)*ax")); + res.add(new RegExp(r"^((a|b)+)*ax")); + res.add(new RegExp(r"^((a|bc)+)*ax")); + res.add(new RegExp(r"(a|x)*ab")); + res.add(new RegExp(r"(a)*ab")); + res.add(new RegExp(r"(?:c|d)(?:)(?:a(?:)(?:b)(?:b(?:))(?:b(?:)(?:b)))")); + res.add(new RegExp( + r"(?:c|d)(?:)(?:aaaaaaaa(?:)(?:bbbbbbbb)(?:bbbbbbbb(?:))(?:bbbbbbbb(?:)(?:bbbbbbbb)))")); + res.add(new RegExp(r"foo\w*\d{4}baz")); + res.add(new RegExp(r"x(~~)*(?:(?:F)?)?")); + res.add(new RegExp(r"^a{3}c")); + res.add(new RegExp(r"^a{3}c")); + res.add(new RegExp(r"^(?:a?b?)*$")); + res.add(new RegExp(r"^b")); + res.add(new RegExp(r"()^b")); + res.add(new RegExp(r"(\w+:)+")); + res.add(new RegExp(r"([\w:]+::)?(\w+)$")); + res.add(new RegExp(r"^[^bcd]*(c+)")); + res.add(new RegExp(r"(a*)b+")); + res.add(new RegExp(r"([\w:]+::)?(\w+)$")); + res.add(new RegExp(r"^[^bcd]*(c+)")); + res.add(new RegExp(r"(>a+)ab")); + res.add(new RegExp(r"([[:]+)")); + res.add(new RegExp(r"([[=]+)")); + res.add(new RegExp(r"([[.]+)")); + res.add(new RegExp(r"a\Z")); + res.add(new RegExp(r"b\Z")); + res.add(new RegExp(r"b\z")); + res.add(new RegExp(r"b\Z")); + res.add(new RegExp(r"b\z")); + res.add(new RegExp(r"((Z)+|A)*")); + res.add(new RegExp(r"(Z()|A)*")); + res.add(new RegExp(r"(Z(())|A)*")); + res.add(new RegExp(r"a*")); + res.add(new RegExp(r"^[\d-a]")); + res.add(new RegExp(r"[[:space:]]+")); + res.add(new RegExp(r"[[:blank:]]+")); + res.add(new RegExp(r"[\s]+")); + res.add(new RegExp(r"\s+")); + res.add(new RegExp(r"a b")); + res.add(new RegExp(r"(?!\A)x", multiLine: true)); + res.add(new RegExp(r"(?!^)x", multiLine: true)); + res.add(new RegExp(r"abc\Qabc\Eabc")); + res.add(new RegExp(r"abc\Qabc\Eabc")); + res.add(new RegExp(r"abc\Qliteral\E")); + res.add(new RegExp(r"abc\Qliteral")); + res.add(new RegExp(r"abc\Qliteral\E")); + res.add(new RegExp(r"abc\Qliteral\E")); + res.add(new RegExp(r"\Qabc\$xyz\E")); + res.add(new RegExp(r"\Qabc\E\$\Qxyz\E")); + res.add(new RegExp(r"\Gabc")); + res.add(new RegExp(r"\Gabc.")); + res.add(new RegExp(r"abc.")); + res.add(new RegExp(r"[z\Qa-d]\E]")); + res.add(new RegExp(r"[\z\C]")); + res.add(new RegExp(r"\M")); + res.add(new RegExp(r"(a+)*b")); + res.add(new RegExp(r"line\nbreak")); + res.add(new RegExp(r"line\nbreak")); + res.add(new RegExp(r"line\nbreak", multiLine: true)); + res.add(new RegExp(r"1234")); + res.add(new RegExp(r"1234")); + res.add(new RegExp(r"^", multiLine: true)); + res.add(new RegExp(r"Content-Type\x3A[^\r\n]{6,}")); + res.add(new RegExp(r"Content-Type\x3A[^\r\n]{6,}z")); + res.add(new RegExp(r"Content-Type\x3A[^a]{6,}")); + res.add(new RegExp(r"Content-Type\x3A[^a]{6,}z")); + res.add(new RegExp(r"^abc", multiLine: true)); + res.add(new RegExp(r"abc$", multiLine: true)); + res.add(new RegExp(r"^abc", multiLine: true)); + res.add(new RegExp(r"^abc", multiLine: true)); + res.add(new RegExp(r"^abc", multiLine: true)); + res.add(new RegExp(r".*")); + res.add(new RegExp(r"\w+(.)(.)?def")); + res.add(new RegExp(r"^\w+=.*(\\\n.*)*")); + res.add(new RegExp(r"^(a()*)*")); + res.add(new RegExp(r"^(?:a(?:(?:))*)*")); + res.add(new RegExp(r"^(a()+)+")); + res.add(new RegExp(r"^(?:a(?:(?:))+)+")); + res.add(new RegExp(r"(a|)*\d")); + res.add(new RegExp(r"(?:a|)*\d")); + res.add(new RegExp(r"^a.b")); + res.add(new RegExp(r"^abc.", multiLine: true)); + res.add(new RegExp(r"abc.$", multiLine: true)); + res.add(new RegExp(r"^a\Rb", caseSensitive: false)); + res.add(new RegExp(r"^a\R*b", caseSensitive: false)); + res.add(new RegExp(r"^a\R+b", caseSensitive: false)); + res.add(new RegExp(r"^a\R{1,3}b", caseSensitive: false)); + res.add(new RegExp(r"^a[\R]b", caseSensitive: false)); + res.add(new RegExp(r".+foo")); + res.add(new RegExp(r".+foo")); + res.add(new RegExp(r".+foo")); + res.add(new RegExp(r".+foo")); + res.add(new RegExp(r"^$", multiLine: true)); + res.add(new RegExp(r"^X", multiLine: true)); + res.add(new RegExp(r"\H\h\V\v")); + res.add(new RegExp(r"\H*\h+\V?\v{3,4}")); + res.add(new RegExp(r"\H{3,4}")); + res.add(new RegExp(r".\h{3,4}.")); + res.add(new RegExp(r"\h*X\h?\H+Y\H?Z")); + res.add(new RegExp(r"\v*X\v?Y\v+Z\V*\x0a\V+\x0b\V{2,3}\x0c")); + res.add(new RegExp(r".+A")); + res.add(new RegExp(r"\nA")); + res.add(new RegExp(r"[\r\n]A")); + res.add(new RegExp(r"(\r|\n)A")); + res.add(new RegExp(r"a\Rb", caseSensitive: false)); + res.add(new RegExp(r"a\Rb", caseSensitive: false)); + res.add(new RegExp(r"a\R?b", caseSensitive: false)); + res.add(new RegExp(r"a\R?b", caseSensitive: false)); + res.add(new RegExp(r"a\R{2,4}b", caseSensitive: false)); + res.add(new RegExp(r"a\R{2,4}b", caseSensitive: false)); + res.add(new RegExp(r"a(?!)|\wbc")); + res.add(new RegExp(r"a[]b")); + res.add(new RegExp(r"a[]+b")); + res.add(new RegExp(r"a[^]b")); + res.add(new RegExp(r"a[^]+b")); + res.add(new RegExp(r" End of testinput7 ")); + res.add(new RegExp(r"\bX")); + res.add(new RegExp(r"\BX")); + res.add(new RegExp(r"X\b")); + res.add(new RegExp(r"X\B")); + res.add(new RegExp(r"[^a]")); + res.add(new RegExp(r"abc")); + res.add(new RegExp(r"a.b")); + res.add(new RegExp(r"a(.{3})b")); + res.add(new RegExp(r"a(.*?)(.)")); + res.add(new RegExp(r"a(.*?)(.)")); + res.add(new RegExp(r"a(.*)(.)")); + res.add(new RegExp(r"a(.*)(.)")); + res.add(new RegExp(r"a(.)(.)")); + res.add(new RegExp(r"a(.)(.)")); + res.add(new RegExp(r"a(.?)(.)")); + res.add(new RegExp(r"a(.?)(.)")); + res.add(new RegExp(r"a(.??)(.)")); + res.add(new RegExp(r"a(.??)(.)")); + res.add(new RegExp(r"a(.{3})b")); + res.add(new RegExp(r"a(.{3,})b")); + res.add(new RegExp(r"a(.{3,}?)b")); + res.add(new RegExp(r"a(.{3,5})b")); + res.add(new RegExp(r"a(.{3,5}?)b")); + res.add(new RegExp(r"[^a]+")); + res.add(new RegExp(r"^[^a]{2}")); + res.add(new RegExp(r"^[^a]{2,}")); + res.add(new RegExp(r"^[^a]{2,}?")); + res.add(new RegExp(r"[^a]+", caseSensitive: false)); + res.add(new RegExp(r"^[^a]{2}", caseSensitive: false)); + res.add(new RegExp(r"^[^a]{2,}", caseSensitive: false)); + res.add(new RegExp(r"^[^a]{2,}?", caseSensitive: false)); + res.add(new RegExp(r"\D*")); + res.add(new RegExp(r"\D*")); + res.add(new RegExp(r"\D")); + res.add(new RegExp(r">\S")); + res.add(new RegExp(r"\d")); + res.add(new RegExp(r"\s")); + res.add(new RegExp(r"\D+")); + res.add(new RegExp(r"\D{2,3}")); + res.add(new RegExp(r"\D{2,3}?")); + res.add(new RegExp(r"\d+")); + res.add(new RegExp(r"\d{2,3}")); + res.add(new RegExp(r"\d{2,3}?")); + res.add(new RegExp(r"\S+")); + res.add(new RegExp(r"\S{2,3}")); + res.add(new RegExp(r"\S{2,3}?")); + res.add(new RegExp(r">\s+<")); + res.add(new RegExp(r">\s{2,3}<")); + res.add(new RegExp(r">\s{2,3}?<")); + res.add(new RegExp(r"\w+")); + res.add(new RegExp(r"\w{2,3}")); + res.add(new RegExp(r"\w{2,3}?")); + res.add(new RegExp(r"\W+")); + res.add(new RegExp(r"\W{2,3}")); + res.add(new RegExp(r"\W{2,3}?")); + res.add(new RegExp(r"[\xFF]")); + res.add(new RegExp(r"[\xff]")); + res.add(new RegExp(r"[^\xFF]")); + res.add(new RegExp(r"[^\xff]")); + res.add(new RegExp(r"^[ac]*b")); + res.add(new RegExp(r"^[^x]*b", caseSensitive: false)); + res.add(new RegExp(r"^[^x]*b")); + res.add(new RegExp(r"^\d*b")); + res.add(new RegExp(r"(|a)")); + res.add(new RegExp(r"^abc.", multiLine: true)); + res.add(new RegExp(r"abc.$", multiLine: true)); + res.add(new RegExp(r"^a\Rb", caseSensitive: false)); + res.add(new RegExp(r"^a\R*b", caseSensitive: false)); + res.add(new RegExp(r"^a\R+b", caseSensitive: false)); + res.add(new RegExp(r"^a\R{1,3}b", caseSensitive: false)); + res.add(new RegExp(r"\h+\V?\v{3,4}")); + res.add(new RegExp(r"\V?\v{3,4}")); + res.add(new RegExp(r"\h+\V?\v{3,4}")); + res.add(new RegExp(r"\V?\v{3,4}")); + res.add(new RegExp(r"\H\h\V\v")); + res.add(new RegExp(r"\H*\h+\V?\v{3,4}")); + res.add(new RegExp(r"\H\h\V\v")); + res.add(new RegExp(r"\H*\h+\V?\v{3,4}")); + res.add(new RegExp(r"a\Rb", caseSensitive: false)); + res.add(new RegExp(r"a\Rb", caseSensitive: false)); + res.add(new RegExp(r"a\R?b", caseSensitive: false)); + res.add(new RegExp(r"a\R?b", caseSensitive: false)); + res.add(new RegExp(r"X")); + res.add(new RegExp(r" End of testinput 8 ")); + res.add(new RegExp(r"\pL\P{Nd}")); + res.add(new RegExp(r"\X.")); + res.add(new RegExp(r"\X\X")); + res.add(new RegExp(r"^\pL+")); + res.add(new RegExp(r"^\PL+")); + res.add(new RegExp(r"^\X+")); + res.add(new RegExp(r"\X?abc")); + res.add(new RegExp(r"^\X?abc")); + res.add(new RegExp(r"\X*abc")); + res.add(new RegExp(r"^\X*abc")); + res.add(new RegExp(r"^\pL?=.")); + res.add(new RegExp(r"^\pL*=.")); + res.add(new RegExp(r"^\X{2,3}X")); + res.add(new RegExp(r"^\pC\pL\pM\pN\pP\pS\pZ<")); + res.add(new RegExp(r"^\PC")); + res.add(new RegExp(r"^\PL")); + res.add(new RegExp(r"^\PM")); + res.add(new RegExp(r"^\PN")); + res.add(new RegExp(r"^\PP")); + res.add(new RegExp(r"^\PS")); + res.add(new RegExp(r"^\PZ")); + res.add(new RegExp(r"^\p{Cc}")); + res.add(new RegExp(r"^\p{Cf}")); + res.add(new RegExp(r"^\p{Cn}")); + res.add(new RegExp(r"^\p{Co}")); + res.add(new RegExp(r"^\p{Cs}")); + res.add(new RegExp(r"^\p{Ll}")); + res.add(new RegExp(r"^\p{Lm}")); + res.add(new RegExp(r"^\p{Lo}")); + res.add(new RegExp(r"^\p{Lt}")); + res.add(new RegExp(r"^\p{Lu}")); + res.add(new RegExp(r"^\p{Mc}")); + res.add(new RegExp(r"^\p{Me}")); + res.add(new RegExp(r"^\p{Mn}")); + res.add(new RegExp(r"^\p{Nl}")); + res.add(new RegExp(r"^\p{No}")); + res.add(new RegExp(r"^\p{Pc}")); + res.add(new RegExp(r"^\p{Pd}")); + res.add(new RegExp(r"^\p{Pe}")); + res.add(new RegExp(r"^\p{Pf}")); + res.add(new RegExp(r"^\p{Pi}")); + res.add(new RegExp(r"^\p{Po}")); + res.add(new RegExp(r"^\p{Ps}")); + res.add(new RegExp(r"^\p{Sk}")); + res.add(new RegExp(r"^\p{So}")); + res.add(new RegExp(r"^\p{Zl}")); + res.add(new RegExp(r"^\p{Zp}")); + res.add(new RegExp(r"^\p{Zs}")); + res.add(new RegExp(r"\p{Nd}{2,}(..)")); + res.add(new RegExp(r"\p{Nd}{2,}?(..)")); + res.add(new RegExp(r"\p{Nd}*(..)")); + res.add(new RegExp(r"\p{Nd}*?(..)")); + res.add(new RegExp(r"\p{Nd}{2}(..)")); + res.add(new RegExp(r"\p{Nd}{2,3}(..)")); + res.add(new RegExp(r"\p{Nd}{2,3}?(..)")); + res.add(new RegExp(r"\p{Nd}?(..)")); + res.add(new RegExp(r"\p{Nd}??(..)")); + res.add(new RegExp(r"\p{Lu}", caseSensitive: false)); + res.add(new RegExp(r"\p{^Lu}", caseSensitive: false)); + res.add(new RegExp(r"\P{Lu}", caseSensitive: false)); + res.add(new RegExp(r"[\p{Nd}]")); + res.add(new RegExp(r"[\P{Nd}]+")); + res.add(new RegExp(r"\D+")); + res.add(new RegExp(r"[\D]+")); + res.add(new RegExp(r"[\P{Nd}]+")); + res.add(new RegExp(r"[\D\P{Nd}]+")); + res.add(new RegExp(r"\pL")); + res.add(new RegExp(r"\pL", caseSensitive: false)); + res.add(new RegExp(r"\p{Lu}")); + res.add(new RegExp(r"\p{Lu}", caseSensitive: false)); + res.add(new RegExp(r"\p{Ll}")); + res.add(new RegExp(r"\p{Ll}", caseSensitive: false)); + res.add(new RegExp(r"^\X")); + res.add(new RegExp(r"^[\X]")); + res.add(new RegExp(r"^(\X*)C")); + res.add(new RegExp(r"^(\X*?)C")); + res.add(new RegExp(r"^(\X*)(.)")); + res.add(new RegExp(r"^(\X*?)(.)")); + res.add(new RegExp(r"^\X(.)")); + res.add(new RegExp(r"^\X{2,3}(.)")); + res.add(new RegExp(r"^\X{2,3}?(.)")); + res.add(new RegExp(r"^\pN{2,3}X")); + res.add(new RegExp(r"^[\p{Arabic}]")); + res.add(new RegExp(r"^[\P{Yi}]")); + res.add(new RegExp(r"^\p{Any}X")); + res.add(new RegExp(r"^\P{Any}X")); + res.add(new RegExp(r"^\p{Any}?X")); + res.add(new RegExp(r"^\P{Any}?X")); + res.add(new RegExp(r"^\p{Any}*X")); + res.add(new RegExp(r"^\P{Any}*X")); + res.add(new RegExp(r"^[\p{Any}]X")); + res.add(new RegExp(r"^[\P{Any}]X")); + res.add(new RegExp(r"^[\p{Any}]?X")); + res.add(new RegExp(r"^[\P{Any}]?X")); + res.add(new RegExp(r"^[\p{Any}]+X")); + res.add(new RegExp(r"^[\P{Any}]+X")); + res.add(new RegExp(r"^[\p{Any}]*X")); + res.add(new RegExp(r"^[\P{Any}]*X")); + res.add(new RegExp(r"^\p{Any}{3,5}?")); + res.add(new RegExp(r"^\p{Any}{3,5}")); + res.add(new RegExp(r"^\P{Any}{3,5}?")); + res.add(new RegExp(r"^\p{L&}X")); + res.add(new RegExp(r"^[\p{L&}]X")); + res.add(new RegExp(r"^[\p{L&}]+X")); + res.add(new RegExp(r"^[\p{L&}]+?X")); + res.add(new RegExp(r"^\P{L&}X")); + res.add(new RegExp(r"^[\P{L&}]X")); + res.add(new RegExp(r"Check property support in non-UTF-8 mode")); + res.add(new RegExp(r"\p{L}{4}")); + res.add(new RegExp( + r"\p{Carian}\p{Cham}\p{Kayah_Li}\p{Lepcha}\p{Lycian}\p{Lydian}\p{Ol_Chiki}\p{Rejang}\p{Saurashtra}\p{Sundanese}\p{Vai}")); + res.add(new RegExp(r" End ")); + res.add(new RegExp(r"^[[:alnum:]]", multiLine: true)); + res.add(new RegExp(r"a", multiLine: true, caseSensitive: false)); + res.add(new RegExp(r"abcde", multiLine: true)); + res.add(new RegExp(r"\x80", multiLine: true)); + res.add(new RegExp(r"\xff", multiLine: true)); + res.add(new RegExp(r"[\p{L}]", multiLine: true)); + res.add(new RegExp(r"[\p{^L}]", multiLine: true)); + res.add(new RegExp(r"[\P{L}]", multiLine: true)); + res.add(new RegExp(r"[\P{^L}]", multiLine: true)); + res.add(new RegExp(r"[\p{Nd}]", multiLine: true)); + res.add(new RegExp(r"[a]", multiLine: true)); + res.add(new RegExp(r"[a]", multiLine: true)); + res.add(new RegExp(r"[\xaa]", multiLine: true)); + res.add(new RegExp(r"[\xaa]", multiLine: true)); + res.add(new RegExp(r"[^a]", multiLine: true)); + res.add(new RegExp(r"[^a]", multiLine: true)); + res.add(new RegExp(r"[^\xaa]", multiLine: true)); + res.add(new RegExp(r"[^\xaa]", multiLine: true)); + res.add(new RegExp(r" End of testinput10 ")); + assertToStringEquals("abc", res[1].firstMatch("abc"), 0); + assertToStringEquals("abc", res[1].firstMatch("defabc"), 1); + assertToStringEquals("abc", res[1].firstMatch("Aabc"), 2); + assertNull(res[1].firstMatch("*** Failers"), 3); + assertToStringEquals("abc", res[1].firstMatch("Adefabc"), 4); + assertToStringEquals("ABC", res[1].firstMatch("ABC"), 5); + assertToStringEquals("abc", res[2].firstMatch("abc"), 6); + assertNull(res[2].firstMatch("Aabc"), 7); + assertNull(res[2].firstMatch("*** Failers"), 8); + assertNull(res[2].firstMatch("defabc"), 9); + assertNull(res[2].firstMatch("Adefabc"), 10); + assertToStringEquals("abc", res[7].firstMatch("abc"), 11); + assertNull(res[7].firstMatch("*** Failers"), 12); + assertNull(res[7].firstMatch("def\nabc"), 13); + assertThrows(() => new RegExp(r"x{5,4}")); + assertThrows(() => new RegExp(r"[abcd")); + assertThrows(() => new RegExp(r"[z-a]")); + assertThrows(() => new RegExp(r"^*")); + assertThrows(() => new RegExp(r"(abc")); + assertThrows(() => new RegExp(r"(?# abc")); + assertToStringEquals( + "cat", res[11].firstMatch("this sentence eventually mentions a cat"), 20); + assertToStringEquals( + "elephant", + res[11].firstMatch( + "this sentences rambles on and on for a while and then reaches elephant"), + 21); + assertToStringEquals( + "cat", res[12].firstMatch("this sentence eventually mentions a cat"), 22); + assertToStringEquals( + "elephant", + res[12].firstMatch( + "this sentences rambles on and on for a while and then reaches elephant"), + 23); + assertToStringEquals("CAT", + res[13].firstMatch("this sentence eventually mentions a CAT cat"), 24); + assertToStringEquals( + "elephant", + res[13].firstMatch( + "this sentences rambles on and on for a while to elephant ElePhant"), + 25); + assertThrows(() => new RegExp(r"{4,5}abc")); + assertToStringEquals("abcb,a,b,c", res[18].firstMatch("abcb"), 27); + assertToStringEquals("abcb,a,b,c", res[18].firstMatch("O0abcb"), 28); + assertToStringEquals("abcb,a,b,c", res[18].firstMatch("O3abcb"), 29); + assertToStringEquals("abcb,a,b,c", res[18].firstMatch("O6abcb"), 30); + assertToStringEquals("abcb,a,b,c", res[18].firstMatch("O9abcb"), 31); + assertToStringEquals("abcb,a,b,c", res[18].firstMatch("O12abcb"), 32); + assertToStringEquals("abc,a,,", res[19].firstMatch("abc"), 33); + assertToStringEquals("abc,a,,", res[19].firstMatch("O0abc"), 34); + assertToStringEquals("abc,a,,", res[19].firstMatch("O3abc"), 35); + assertToStringEquals("abc,a,,", res[19].firstMatch("O6abc"), 36); + assertToStringEquals("aba,,a,b", res[19].firstMatch("aba"), 37); + assertToStringEquals("aba,,a,b", res[19].firstMatch("O0aba"), 38); + assertToStringEquals("aba,,a,b", res[19].firstMatch("O3aba"), 39); + assertToStringEquals("aba,,a,b", res[19].firstMatch("O6aba"), 40); + assertToStringEquals("aba,,a,b", res[19].firstMatch("O9aba"), 41); + assertToStringEquals("aba,,a,b", res[19].firstMatch("O12aba"), 42); + assertToStringEquals("abc", res[20].firstMatch("abc"), 43); + assertNull(res[20].firstMatch("*** Failers"), 44); + assertNull(res[20].firstMatch("abc\n"), 45); + assertNull(res[20].firstMatch("abc\ndef"), 46); + assertToStringEquals( + "the quick brown fox", res[22].firstMatch("the quick brown fox"), 47); + assertToStringEquals("the quick brown fox", + res[22].firstMatch("this is a line with the quick brown fox"), 48); + assertToStringEquals("abc", res[23].firstMatch("abcdef"), 49); + assertToStringEquals("abc", res[23].firstMatch("abcdefB"), 50); + assertToStringEquals("defabc,abc,abc,", res[24].firstMatch("defabc"), 51); + assertToStringEquals("Zdefabc,abc,abc,", res[24].firstMatch("Zdefabc"), 52); + assertToStringEquals("abc", res[25].firstMatch("abc"), 53); + assertNull(res[25].firstMatch("*** Failers"), 54); + assertToStringEquals("abc", res[26].firstMatch("abcdef"), 55); + assertToStringEquals("abc", res[26].firstMatch("abcdefB"), 56); + assertToStringEquals("defabc,abc,abc,", res[27].firstMatch("defabc"), 57); + assertToStringEquals("Zdefabc,abc,abc,", res[27].firstMatch("Zdefabc"), 58); + assertToStringEquals( + "the quick brown fox", res[28].firstMatch("the quick brown fox"), 59); + assertNull(res[28].firstMatch("*** Failers"), 60); + assertToStringEquals( + "The Quick Brown Fox", res[28].firstMatch("The Quick Brown Fox"), 61); + assertToStringEquals( + "the quick brown fox", res[29].firstMatch("the quick brown fox"), 62); + assertToStringEquals( + "The Quick Brown Fox", res[29].firstMatch("The Quick Brown Fox"), 63); + assertNull(res[30].firstMatch("*** Failers"), 64); + assertNull(res[30].firstMatch("abc\ndef"), 65); + assertToStringEquals("abc", res[31].firstMatch("abc"), 66); + assertNull(res[31].firstMatch("abc\n"), 67); + assertToStringEquals("abc,abc", res[33].firstMatch("abc"), 68); + assertThrows(() => new RegExp(r")")); + assertToStringEquals("-pr", res[35].firstMatch("co-processors, and for"), 70); + assertToStringEquals( + "ghi", res[36].firstMatch("abcghinop"), 71); + assertToStringEquals("", res[37].firstMatch("abcghinop"), 72); + assertToStringEquals("", res[37].firstMatch("abcghinop"), 73); + assertNull(res[37].firstMatch("abc========def"), 74); + assertNull(res[37].firstMatch("foo"), 75); + assertNull(res[37].firstMatch("catfoo"), 76); + assertNull(res[37].firstMatch("*** Failers"), 77); + assertNull(res[37].firstMatch("the barfoo"), 78); + assertNull(res[37].firstMatch("and cattlefoo"), 79); + assertToStringEquals("a", res[40].firstMatch("a"), 80); + assertNull(res[40].firstMatch("a\n"), 81); + assertNull(res[40].firstMatch("*** Failers"), 82); + assertToStringEquals("a", res[40].firstMatch("Za"), 83); + assertNull(res[40].firstMatch("Za\n"), 84); + assertToStringEquals("a", res[41].firstMatch("a"), 85); + assertToStringEquals("a", res[41].firstMatch("a\n"), 86); + assertToStringEquals("a", res[41].firstMatch("Za\n"), 87); + assertNull(res[41].firstMatch("*** Failers"), 88); + assertToStringEquals("a", res[41].firstMatch("Za"), 89); + assertToStringEquals("b", res[44].firstMatch("foo\nbarbar"), 90); + assertToStringEquals("a", res[44].firstMatch("***Failers"), 91); + assertToStringEquals("b", res[44].firstMatch("rhubarb"), 92); + assertToStringEquals("b", res[44].firstMatch("barbell"), 93); + assertToStringEquals("a", res[44].firstMatch("abc\nbarton"), 94); + assertToStringEquals("b", res[44].firstMatch("foo\nbarbar"), 95); + assertToStringEquals("a", res[44].firstMatch("***Failers"), 96); + assertToStringEquals("b", res[44].firstMatch("rhubarb"), 97); + assertToStringEquals("b", res[44].firstMatch("barbell"), 98); + assertToStringEquals("a", res[44].firstMatch("abc\nbarton"), 99); + assertToStringEquals("a", res[44].firstMatch("abc"), 100); + assertToStringEquals("a", res[44].firstMatch("def\nabc"), 101); + assertToStringEquals("a", res[44].firstMatch("*** Failers"), 102); + assertToStringEquals("a", res[44].firstMatch("defabc"), 103); + assertNull(res[45].firstMatch("the bullock-cart"), 104); + assertNull(res[45].firstMatch("a donkey-cart race"), 105); + assertNull(res[45].firstMatch("*** Failers"), 106); + assertNull(res[45].firstMatch("cart"), 107); + assertNull(res[45].firstMatch("horse-and-cart"), 108); + assertNull(res[45].firstMatch("alphabetabcd"), 109); + assertNull(res[45].firstMatch("endingxyz"), 110); + assertNull(res[45].firstMatch("abxyZZ"), 111); + assertNull(res[45].firstMatch("abXyZZ"), 112); + assertNull(res[45].firstMatch("ZZZ"), 113); + assertNull(res[45].firstMatch("zZZ"), 114); + assertNull(res[45].firstMatch("bZZ"), 115); + assertNull(res[45].firstMatch("BZZ"), 116); + assertNull(res[45].firstMatch("*** Failers"), 117); + assertNull(res[45].firstMatch("ZZ"), 118); + assertNull(res[45].firstMatch("abXYZZ"), 119); + assertNull(res[45].firstMatch("zzz"), 120); + assertNull(res[45].firstMatch("bzz"), 121); + assertNull(res[45].firstMatch("bar"), 122); + assertNull(res[45].firstMatch("foobbar"), 123); + assertNull(res[45].firstMatch("*** Failers"), 124); + assertNull(res[45].firstMatch("fooabar"), 125); + assertNull(res[46].firstMatch("*** Failers"), 126); + assertNull(res[46].firstMatch("a"), 127); + assertNull(res[48].firstMatch("aaaaaa"), 128); + assertThrows(() => new RegExp(r"a[b-a]"), 129); + assertThrows(() => new RegExp(r"a["), 130); + assertThrows(() => new RegExp(r"*a"), 131); + assertThrows(() => new RegExp(r"abc)"), 132); + assertThrows(() => new RegExp(r"(abc"), 133); + assertThrows(() => new RegExp(r"a**"), 134); + assertThrows(() => new RegExp(r")("), 135); + assertThrows(() => new RegExp(r"a[b-a]"), 136); + assertThrows(() => new RegExp(r"a["), 137); + assertThrows(() => new RegExp(r"*a"), 138); + assertThrows(() => new RegExp(r"abc)"), 139); + assertThrows(() => new RegExp(r"(abc"), 140); + assertThrows(() => new RegExp(r"a**"), 141); + assertThrows(() => new RegExp(r")("), 142); + assertThrows(() => new RegExp(r":(?:"), 143); + assertThrows(() => new RegExp(r"a(?{)b"), 144); + assertThrows(() => new RegExp(r"a(?{{})b"), 145); + assertThrows(() => new RegExp(r"a(?{}})b"), 146); + assertThrows(() => new RegExp(r'a(?{\"{\"})b'), 147); + assertThrows(() => new RegExp(r'a(?{\"{\"}})b'), 148); + assertThrows(() => new RegExp(r"[a[:xyz:"), 149); + assertThrows(() => new RegExp(r"a{37,17}"), 150); + assertToStringEquals("abcd,a,d", res[58].firstMatch("abcd"), 151); + assertToStringEquals("abcd,a,d", res[58].firstMatch("abcdC2"), 152); + assertToStringEquals("abcd,a,d", res[58].firstMatch("abcdC5"), 153); + assertToStringEquals("abcdefghijklmnopqrst,abcdefghijklmnopqrst", + res[59].firstMatch("abcdefghijklmnopqrstuvwxyz"), 154); + assertToStringEquals("abcdefghijklmnopqrst,abcdefghijklmnopqrst", + res[59].firstMatch("abcdefghijklmnopqrstuvwxyzC1"), 155); + assertToStringEquals("abcdefghijklmnopqrst,abcdefghijklmnopqrst", + res[59].firstMatch("abcdefghijklmnopqrstuvwxyzG1"), 156); + assertToStringEquals("abcdefghijklmno,abcdefghijklmno", + res[60].firstMatch("abcdefghijklmnopqrstuvwxyz"), 157); + assertToStringEquals("abcdefghijklmno,abcdefghijklmno", + res[60].firstMatch("abcdefghijklmnopqrstuvwxyzC1G1"), 158); + assertToStringEquals("abcdefghijklmnop,abcdefghijklmnop", + res[61].firstMatch("abcdefghijklmnopqrstuvwxyz"), 159); + assertToStringEquals("abcdefghijklmnop,abcdefghijklmnop", + res[61].firstMatch("abcdefghijklmnopqrstuvwxyzC1G1L"), 160); + assertToStringEquals("adef,a,,f", res[62].firstMatch("adefG1G2G3G4L"), 161); + assertToStringEquals( + "bcdef,bc,bc,f", res[62].firstMatch("bcdefG1G2G3G4L"), 162); + assertToStringEquals("adef,a,,f", res[62].firstMatch("adefghijkC0"), 163); + assertToStringEquals("abc\x00def", res[63].firstMatch("abc\x00defLC0"), 164); + assertToStringEquals("iss", res[69].firstMatch("Mississippi"), 165); + assertToStringEquals("iss", res[70].firstMatch("Mississippi"), 166); + assertToStringEquals("iss", res[71].firstMatch("Mississippi"), 167); + assertToStringEquals("iss", res[72].firstMatch("Mississippi"), 168); + assertToStringEquals("iss", res[73].firstMatch("Mississippi"), 169); + assertNull(res[73].firstMatch("*** Failers"), 170); + assertToStringEquals("iss", res[73].firstMatch("MississippiA"), 171); + assertToStringEquals("iss", res[73].firstMatch("Mississippi"), 172); + assertToStringEquals("iss", res[74].firstMatch("ississippi"), 174); + assertToStringEquals("abciss", res[75].firstMatch("abciss\nxyzisspqr"), 175); + assertToStringEquals("Mis", res[76].firstMatch("Mississippi"), 176); + assertToStringEquals("Mis", res[77].firstMatch("Mississippi"), 180); + assertToStringEquals("ab\n", res[78].firstMatch("ab\nab\ncd"), 181); + assertToStringEquals("ab\n", res[79].firstMatch("ab\nab\ncd"), 182); + assertToStringEquals("a", res[115].firstMatch("a"), 183); + assertToStringEquals("b", res[115].firstMatch("b"), 184); + assertToStringEquals("ab", res[115].firstMatch("ab"), 185); + assertToStringEquals("", res[115].firstMatch("\\"), 186); + assertToStringEquals("", res[115].firstMatch("*** Failers"), 187); + assertToStringEquals("", res[115].firstMatch("N"), 188); + assertToStringEquals("", res[116].firstMatch("abcd"), 189); + assertToStringEquals("", res[116].firstMatch("-abc"), 190); + assertToStringEquals("", res[116].firstMatch("Nab-c"), 191); + assertToStringEquals("", res[116].firstMatch("*** Failers"), 192); + assertToStringEquals("", res[116].firstMatch("Nabc"), 193); + assertToStringEquals( + "aaaabbbbzz,bbbb,z,z", res[117].firstMatch("aaaabbbbzzzz"), 194); + assertToStringEquals( + "aaaabbbbzz,bbbb,z,z", res[117].firstMatch("aaaabbbbzzzzO0"), 195); + assertToStringEquals( + "aaaabbbbzz,bbbb,z,z", res[117].firstMatch("aaaabbbbzzzzO1"), 196); + assertToStringEquals( + "aaaabbbbzz,bbbb,z,z", res[117].firstMatch("aaaabbbbzzzzO2"), 197); + assertToStringEquals( + "aaaabbbbzz,bbbb,z,z", res[117].firstMatch("aaaabbbbzzzzO3"), 198); + assertToStringEquals( + "aaaabbbbzz,bbbb,z,z", res[117].firstMatch("aaaabbbbzzzzO4"), 199); + assertToStringEquals( + "aaaabbbbzz,bbbb,z,z", res[117].firstMatch("aaaabbbbzzzzO5"), 200); + assertToStringEquals("(abcd", res[118].firstMatch("(abcd)"), 201); + assertToStringEquals("(abcd", res[118].firstMatch("(abcd)xyz"), 202); + assertNull(res[118].firstMatch("xyz(abcd)"), 203); + assertNull(res[118].firstMatch("(ab(xy)cd)pqr"), 204); + assertNull(res[118].firstMatch("(ab(xycd)pqr"), 205); + assertNull(res[118].firstMatch("() abc ()"), 206); + assertNull(res[118].firstMatch("12(abcde(fsh)xyz(foo(bar))lmno)89"), 207); + assertNull(res[118].firstMatch("*** Failers"), 208); + assertToStringEquals("abcd", res[118].firstMatch("abcd"), 209); + assertToStringEquals("abcd", res[118].firstMatch("abcd)"), 210); + assertToStringEquals("(abcd", res[118].firstMatch("(abcd"), 211); + assertNull(res[118].firstMatch("(ab(xy)cd)pqr"), 212); + assertNull(res[118].firstMatch("1(abcd)(x(y)z)pqr"), 213); + assertToStringEquals("(abcd", res[118].firstMatch("(abcd)"), 214); + assertNull(res[118].firstMatch("(ab(xy)cd)"), 215); + assertNull(res[118].firstMatch("(a(b(c)d)e)"), 216); + assertNull(res[118].firstMatch("((ab))"), 217); + assertNull(res[118].firstMatch("*** Failers"), 218); + assertNull(res[118].firstMatch("()"), 219); + assertNull(res[118].firstMatch("()"), 220); + assertNull(res[118].firstMatch("12(abcde(fsh)xyz(foo(bar))lmno)89"), 221); + assertNull(res[118].firstMatch("(ab(xy)cd)"), 222); + assertNull(res[118].firstMatch("(ab(xy)cd)"), 223); + assertNull(res[118].firstMatch("(ab(xy)cd)"), 224); + assertNull(res[118].firstMatch("(123ab(xy)cd)"), 225); + assertNull(res[118].firstMatch("(ab(xy)cd)"), 226); + assertNull(res[118].firstMatch("(123ab(xy)cd)"), 227); + assertNull(res[118].firstMatch("(ab(xy)cd)"), 228); + assertToStringEquals( + "(abcd", res[118].firstMatch("(abcd(xyz