Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: opal/opal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 662bec6be231
Choose a base ref
...
head repository: opal/opal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: e6704c405e5e
Choose a head ref
  • 2 commits
  • 2 files changed
  • 2 contributors

Commits on Apr 1, 2015

  1. Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    c523287 View commit details

Commits on Apr 2, 2015

  1. Merge pull request #786 from vais/string

    Preparation for the last major offensive on String bugs
    elia committed Apr 2, 2015

    Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    e6704c4 View commit details
Showing with 228 additions and 12 deletions.
  1. +215 −0 spec/filters/bugs/string.rb
  2. +13 −12 spec/rubyspecs
215 changes: 215 additions & 0 deletions spec/filters/bugs/string.rb
Original file line number Diff line number Diff line change
@@ -59,4 +59,219 @@
fails "String#initialize with an argument returns self"
fails "String#initialize with no arguments does not raise an exception when frozen"
fails "String#initialize is a private method"

fails "String#match matches a literal Regexp that uses ASCII-only UTF-8 escape sequences"
fails "String#match raises a TypeError if pattern is not a regexp or a string"
fails "String#match matches \\G at the start of the string"
fails "String#match with [pattern, position] when given a positive position matches the pattern against self starting at an optional index"
fails "String#match with [pattern, position] when given a negative position matches the pattern against self starting at an optional index"

fails "String#oct treats numeric digits as base-8 digits by default"
fails "String#oct accepts numbers formatted as binary"
fails "String#oct accepts numbers formatted as hexadecimal"
fails "String#oct accepts numbers formatted as decimal"
fails "String#oct accepts a single underscore separating digits"
fails "String#oct does not accept a sequence of underscores as part of a number"
fails "String#oct ignores characters that are incorrect for the base-8 digits"
fails "String#oct returns 0 if no characters can be interpreted as a base-8 number"
fails "String#oct returns 0 for strings with leading underscores"
fails "String#oct with a leading minus sign treats numeric digits as base-8 digits by default"
fails "String#oct with a leading minus sign accepts numbers formatted as binary"
fails "String#oct with a leading minus sign accepts numbers formatted as hexadecimal"
fails "String#oct with a leading minus sign accepts numbers formatted as decimal"
fails "String#oct with a leading plus sign treats numeric digits as base-8 digits by default"
fails "String#oct with a leading plus sign accepts numbers formatted as binary"
fails "String#oct with a leading plus sign accepts numbers formatted as hexadecimal"
fails "String#oct with a leading plus sign accepts numbers formatted as decimal"

fails "String.try_convert sends #to_str to the argument and raises TypeError if it's not a kind of String"
fails "String.try_convert does not rescue exceptions raised by #to_str"

fails "String#to_c returns a Complex object"
fails "String#to_c understands integers"
fails "String#to_c understands negative integers"
fails "String#to_c understands fractions (numerator/denominator) for the real part"
fails "String#to_c understands fractions (numerator/denominator) for the imaginary part"
fails "String#to_c understands negative fractions (-numerator/denominator) for the real part"
fails "String#to_c understands negative fractions (-numerator/denominator) for the imaginary part"
fails "String#to_c understands floats (a.b) for the real part"
fails "String#to_c understands floats (a.b) for the imaginary part"
fails "String#to_c understands negative floats (-a.b) for the real part"
fails "String#to_c understands negative floats (-a.b) for the imaginary part"
fails "String#to_c understands an integer followed by 'i' to mean that integer is the imaginary part"
fails "String#to_c understands a negative integer followed by 'i' to mean that negative integer is the imaginary part"
fails "String#to_c understands an 'i' by itself as denoting a complex number with an imaginary part of 1"
fails "String#to_c understands a '-i' by itself as denoting a complex number with an imaginary part of -1"
fails "String#to_c understands 'a+bi' to mean a complex number with 'a' as the real part, 'b' as the imaginary"
fails "String#to_c understands 'a-bi' to mean a complex number with 'a' as the real part, '-b' as the imaginary"
fails "String#to_c understands scientific notation for the real part"
fails "String#to_c understands negative scientific notation for the real part"
fails "String#to_c understands scientific notation for the imaginary part"
fails "String#to_c understands negative scientific notation for the imaginary part"
fails "String#to_c understands scientific notation for the real and imaginary part in the same String"
fails "String#to_c understands negative scientific notation for the real and imaginary part in the same String"
fails "String#to_c returns a complex number with 0 as the real part, 0 as the imaginary part for unrecognised Strings"

fails "String#to_i auto-detects base 8 via leading 0 when base = 0"
fails "String#to_i auto-detects base 2 via 0b when base = 0"
fails "String#to_i auto-detects base 10 via 0d when base = 0"
fails "String#to_i auto-detects base 8 via 0o when base = 0"
fails "String#to_i doesn't handle foreign base specifiers when base is > 0"
fails "String#to_i tries to convert the base to an integer using to_int"
fails "String#to_i raises an ArgumentError for illegal bases (1, < 0 or > 36)"
fails "String#to_i with bases parses a String in base 2"
fails "String#to_i with bases parses a String in base 3"
fails "String#to_i with bases parses a String in base 4"
fails "String#to_i with bases parses a String in base 5"
fails "String#to_i with bases parses a String in base 6"
fails "String#to_i with bases parses a String in base 7"
fails "String#to_i with bases parses a String in base 8"
fails "String#to_i with bases parses a String in base 9"
fails "String#to_i with bases parses a String in base 10"
fails "String#to_i with bases parses a String in base 11"
fails "String#to_i with bases parses a String in base 12"
fails "String#to_i with bases parses a String in base 13"
fails "String#to_i with bases parses a String in base 14"
fails "String#to_i with bases parses a String in base 15"
fails "String#to_i with bases parses a String in base 16"
fails "String#to_i with bases parses a String in base 17"
fails "String#to_i with bases parses a String in base 18"
fails "String#to_i with bases parses a String in base 19"
fails "String#to_i with bases parses a String in base 20"
fails "String#to_i with bases parses a String in base 21"
fails "String#to_i with bases parses a String in base 22"
fails "String#to_i with bases parses a String in base 23"
fails "String#to_i with bases parses a String in base 24"
fails "String#to_i with bases parses a String in base 25"
fails "String#to_i with bases parses a String in base 26"
fails "String#to_i with bases parses a String in base 27"
fails "String#to_i with bases parses a String in base 28"
fails "String#to_i with bases parses a String in base 29"
fails "String#to_i with bases parses a String in base 30"
fails "String#to_i with bases parses a String in base 31"
fails "String#to_i with bases parses a String in base 32"
fails "String#to_i with bases parses a String in base 33"
fails "String#to_i with bases parses a String in base 34"
fails "String#to_i with bases parses a String in base 35"
fails "String#to_i with bases parses a String in base 36"

fails "String#to_r returns a Rational object"
fails "String#to_r returns (0/1) for the empty String"
fails "String#to_r returns (n/1) for a String starting with a decimal _n_"
fails "String#to_r ignores trailing characters"
fails "String#to_r ignores leading spaces"
fails "String#to_r does not ignore arbitrary, non-numeric leading characters"
fails "String#to_r treats leading hypens as minus signs"
fails "String#to_r does not treat a leading period without a numeric prefix as a decimal point"
fails "String#to_r understands decimal points"
fails "String#to_r ignores underscores between numbers"
fails "String#to_r understands a forward slash as separating the numerator from the denominator"
fails "String#to_r returns (0/1) for Strings it can't parse"

fails "String#% raises an error if single % appears anywhere else"
fails "String#% raises an error if NULL or \\n appear anywhere else in the format string"
fails "String#% raises an ArgumentError for unused arguments when $DEBUG is true"
fails "String#% replaces trailing absolute argument specifier without type with percent sign"
fails "String#% raises an ArgumentError when given invalid argument specifiers"
fails "String#% raises an ArgumentError when multiple positional argument tokens are given for one format specifier"
fails "String#% raises an ArgumentError when multiple width star tokens are given for one format specifier"
fails "String#% raises an ArgumentError when a width star token is seen after a width token"
fails "String#% raises an ArgumentError when multiple precision tokens are given"
fails "String#% raises an ArgumentError when there are less arguments than format specifiers"
fails "String#% raises an ArgumentError when absolute and relative argument numbers are mixed"
fails "String#% always interprets an array argument as a list of argument parameters"
fails "String#% always interprets an array subclass argument as a list of argument parameters"
fails "String#% allows positional arguments for width star and precision star arguments"
fails "String#% allows negative width to imply '-' flag"
fails "String#% ignores negative precision"
fails "String#% calls to_int on width star and precision star tokens"
fails "String#% tries to convert the argument to Array by calling #to_ary"
fails "String#% doesn't return subclass instances when called on a subclass"
fails "String#% always taints the result when the format string is tainted"
fails "String#% supports binary formats using %b for positive numbers"
fails "String#% supports binary formats using %b for negative numbers"
fails "String#% supports binary formats using %B with same behaviour as %b except for using 0B instead of 0b for #"
fails "String#% supports character formats using %c"
fails "String#% raises an exception for multiple character strings as argument for %c"
fails "String#% calls to_str on argument for %c formats"
fails "String#% calls #to_ary on argument for %c formats"
fails "String#% calls #to_int on argument for %c formats, if the argument does not respond to #to_ary"
fails "String#% supports float formats using %e"
fails "String#% supports float formats using %E"
fails "String#% pads with spaces for %E with Inf, -Inf, and NaN"
fails "String#% supports float formats using %f"
fails "String#% supports float formats using %g"
fails "String#% supports float formats using %G"
fails "String#% supports octal formats using %o for positive numbers"
fails "String#% supports octal formats using %o for negative numbers"
fails "String#% taints result for %p when argument.inspect is tainted"
fails "String#% taints result for %s when argument is tainted"
fails "String#% raises an ArgumentError for huge precisions for %s"
fails "String#% supports negative bignums with %u or %d"
fails "String#% supports hex formats using %x for positive numbers"
fails "String#% supports hex formats using %x for negative numbers"
fails "String#% supports hex formats using %X for positive numbers"
fails "String#% supports hex formats using %X for negative numbers"
fails "String#% formats zero without prefix using %#x"
fails "String#% formats zero without prefix using %#X"
fails "String#% behaves as if calling Kernel#Integer for %b argument, if it does not respond to #to_ary"
fails "String#% behaves as if calling Kernel#Integer for %d argument, if it does not respond to #to_ary"
fails "String#% behaves as if calling Kernel#Integer for %i argument, if it does not respond to #to_ary"
fails "String#% behaves as if calling Kernel#Integer for %o argument, if it does not respond to #to_ary"
fails "String#% behaves as if calling Kernel#Integer for %u argument, if it does not respond to #to_ary"
fails "String#% behaves as if calling Kernel#Integer for %x argument, if it does not respond to #to_ary"
fails "String#% behaves as if calling Kernel#Integer for %X argument, if it does not respond to #to_ary"
fails "String#% tries to convert the passed argument to an Array using #to_ary"
fails "String#% behaves as if calling Kernel#Float for %e arguments, when the passed argument does not respond to #to_ary"
fails "String#% behaves as if calling Kernel#Float for %e arguments, when the passed argument is hexadecimal string"
fails "String#% tries to convert the passed argument to an Array using #to_ary"
fails "String#% behaves as if calling Kernel#Float for %E arguments, when the passed argument does not respond to #to_ary"
fails "String#% behaves as if calling Kernel#Float for %E arguments, when the passed argument is hexadecimal string"
fails "String#% tries to convert the passed argument to an Array using #to_ary"
fails "String#% behaves as if calling Kernel#Float for %f arguments, when the passed argument does not respond to #to_ary"
fails "String#% behaves as if calling Kernel#Float for %f arguments, when the passed argument is hexadecimal string"
fails "String#% tries to convert the passed argument to an Array using #to_ary"
fails "String#% behaves as if calling Kernel#Float for %g arguments, when the passed argument does not respond to #to_ary"
fails "String#% behaves as if calling Kernel#Float for %g arguments, when the passed argument is hexadecimal string"
fails "String#% tries to convert the passed argument to an Array using #to_ary"
fails "String#% behaves as if calling Kernel#Float for %G arguments, when the passed argument does not respond to #to_ary"
fails "String#% behaves as if calling Kernel#Float for %G arguments, when the passed argument is hexadecimal string"
fails "String#% when format string contains %{} sections replaces %{} sections with values from passed-in hash"
fails "String#% when format string contains %{} sections raises KeyError if key is missing from passed-in hash"
fails "String#% when format string contains %{} sections should raise ArgumentError if no hash given"
fails "String#% when format string contains %<> formats uses the named argument for the format's value"
fails "String#% when format string contains %<> formats raises KeyError if key is missing from passed-in hash"
fails "String#% when format string contains %<> formats should raise ArgumentError if no hash given"

fails "String#crypt returns a cryptographic hash of self by applying the UNIX crypt algorithm with the specified salt"
fails "String#crypt raises an ArgumentError when the salt is shorter than two characters"
fails "String#crypt calls #to_str to converts the salt arg to a String"
fails "String#crypt raises a type error when the salt arg can't be converted to a string"
fails "String#crypt taints the result if either salt or self is tainted"
fails "String#crypt doesn't return subclass instances"

fails "String#dump taints the result if self is tainted"
fails "String#dump untrusts the result if self is untrusted"
fails "String#dump returns a subclass instance"
fails "String#dump returns a string with special characters replaced with \\<char> notation"
fails "String#dump returns a string with \" and \\ escaped with a backslash"
fails "String#dump returns a string with \\#<char> when # is followed by $, @, {"
fails "String#dump returns a string with # not escaped when followed by any other character"
fails "String#dump returns a string with printable non-alphanumeric characters unescaped"
fails "String#dump returns a string with numeric characters unescaped"
fails "String#dump returns a string with upper-case alpha characters unescaped"
fails "String#dump returns a string with lower-case alpha characters unescaped"
fails "String#dump returns a string with non-printing ASCII characters replaced by \\x notation"
fails "String#dump returns a string with non-printing single-byte UTF-8 characters replaced by \\x notation"
fails "String#dump returns a string with multi-byte UTF-8 characters replaced by \\u{} notation with lower-case hex digits"
fails "String#dump includes .force_encoding(name) if the encoding isn't ASCII compatible"

fails "String#inspect taints the result if self is tainted"
fails "String#inspect untrusts the result if self is untrusted"
fails "String#inspect returns a string with special characters replaced with \\<char> notation"
fails "String#inspect returns a string with \\#<char> when # is followed by $, @, {"
fails "String#inspect returns a string with non-printing characters replaced by \\x notation"
fails "String#inspect returns a string with a NUL character replaced by \\000"
fails "String#inspect when default external is UTF-8 returns a string with non-printing characters replaced by \\u notation for Unicode strings"
fails "String#inspect when default external is UTF-8 returns a string with extended characters for Unicode strings"
end
25 changes: 13 additions & 12 deletions spec/rubyspecs
Original file line number Diff line number Diff line change
@@ -87,7 +87,7 @@ corelib/core/string/append_spec
corelib/core/string/ascii_only_spec
corelib/core/string/bytes_spec
corelib/core/string/bytesize_spec
# corelib/core/string/byteslice_spec - invalid regexp
corelib/core/string/byteslice_spec
corelib/core/string/capitalize_spec
corelib/core/string/case_compare_spec
corelib/core/string/casecmp_spec
@@ -101,10 +101,10 @@ corelib/core/string/codepoints_spec
corelib/core/string/comparison_spec
corelib/core/string/concat_spec
corelib/core/string/count_spec
# corelib/core/string/crypt_spec - not supported (can add these)
corelib/core/string/crypt_spec
corelib/core/string/delete_spec
corelib/core/string/downcase_spec
# corelib/core/string/dump_spec - parse error on "\\x05"
corelib/core/string/dump_spec
corelib/core/string/dup_spec
corelib/core/string/each_byte_spec
corelib/core/string/each_char_spec
@@ -120,25 +120,25 @@ corelib/core/string/eql_spec
corelib/core/string/equal_value_spec
corelib/core/string/force_encoding_spec
# corelib/core/string/getbyte_spec - parse error - "UTF-8 (\u{9865}} characters and hex escapes (\xDE)"
# corelib/core/string/gsub_spec - invalid regular expression
corelib/core/string/gsub_spec
corelib/core/string/hash_spec
corelib/core/string/hex_spec
corelib/core/string/include_spec
corelib/core/string/index_spec
corelib/core/string/initialize_spec
corelib/core/string/insert_spec
# corelib/core/string/inspect_spec - Encoding::CompatibilityError: incompatible character encodings: UTF-8 and ASCII-8BIT
corelib/core/string/inspect_spec
corelib/core/string/intern_spec
corelib/core/string/length_spec
corelib/core/string/lines_spec
corelib/core/string/ljust_spec
corelib/core/string/lstrip_spec
#core/string/match_spec - fails to find a shared group
# corelib/core/string/modulo_spec - lots of failing specs
corelib/core/string/match_spec
corelib/core/string/modulo_spec
corelib/core/string/multiply_spec
corelib/core/string/new_spec
corelib/core/string/next_spec
# # corelib/core/string/oct_spec - parse error on -01234
corelib/core/string/oct_spec
corelib/core/string/ord_spec
corelib/core/string/partition_spec
corelib/core/string/plus_spec
@@ -156,21 +156,22 @@ corelib/core/string/slice_spec
corelib/core/string/split_spec
corelib/core/string/squeeze_spec
corelib/core/string/start_with_spec
corelib/core/string/string_spec
corelib/core/string/strip_spec
corelib/core/string/sub_spec
corelib/core/string/succ_spec
corelib/core/string/sum_spec
corelib/core/string/swapcase_spec
# corelib/core/string/to_c_spec - lots of failing specs
corelib/core/string/to_c_spec
corelib/core/string/to_f_spec
# corelib/core/string/to_i_spec
# corelib/core/string/to_r_spec
corelib/core/string/to_i_spec
corelib/core/string/to_r_spec
corelib/core/string/to_str_spec
corelib/core/string/to_sym_spec
corelib/core/string/to_s_spec
corelib/core/string/tr_s_spec
corelib/core/string/tr_spec
# corelib/core/string/try_convert_spec
corelib/core/string/try_convert_spec
corelib/core/string/upcase_spec
corelib/core/string/upto_spec
corelib/core/string/valid_encoding_spec