Commit Graph

859 Commits

Author SHA1 Message Date
KOBAYASHI Shuji cdb458ed4e Commented out String#scan because it is not implemented yet 2019-04-21 20:34:39 +09:00
KOBAYASHI Shuji 4a8b88f775 Add type check (conversion) in String#[]=
Before this patch:

  'a'[0] = 1        #=> 1
  'a'[:a] = '1'     #=> ArgumentError
  'a'[:a, 0] = '1'  #=> ArgumentError
  'a'[0, :a] = '1'  #=> ArgumentError
  'a'[0, 1] = 1     #=> 1

After this patch / Ruby:

  'a'[0] = 1        #=> TypeError
  'a'[:a] = '1'     #=> TypeError
  'a'[:a, 0] = '1'  #=> TypeError
  'a'[0, :a] = '1'  #=> TypeError
  'a'[0, 1] = 1     #=> TypeError
2019-04-19 20:14:23 +09:00
KOBAYASHI Shuji 6626fbc500 Refine assert_float
Avoid arithmetic operations when `exp` and/or `act` are infinity or NaN.
2019-04-12 22:27:07 +09:00
KOBAYASHI Shuji 7b0ebed033 Use mrb_immediate_p() in mrb_obj_freeze() and mrb_obj_frozen() 2019-04-10 19:19:53 +09:00
KOBAYASHI Shuji f65b35dc9f Fix test for Array#slice 2019-04-07 21:31:12 +09:00
KOBAYASHI Shuji 623e15936a Module#alias_method should return self in ISO standard 2019-04-05 19:03:46 +09:00
KOBAYASHI Shuji 9b024dcf7a Fix warning: '*' interpreted as argument prefix 2019-03-31 14:52:18 +09:00
KOBAYASHI Shuji 4e9c90ed47 Add pass and flunk to test/assert.rb 2019-03-30 13:19:31 +09:00
KOBAYASHI Shuji 0b6696cc28 Fix dealing with infinity and NaN in test/assert.rb:assert_float
`assert_float` is always passed when expected value and/or actual value are
infinity or NaN. This behavior seems unintentional.

Before this patch:

    assert_float(Float::INFINITY, 1.0)  #=> pass
    assert_float(-Float::INFINITY, 1)   #=> pass
    assert_float(1, 1/0)                #=> pass
    assert_float(1, -1/0)               #=> pass
    assert_float(1.0, Float::NAN)       #=> pass
    assert_float(Float::NAN, 1)         #=> pass

After this patch:

    assert_float(Float::INFINITY, 1.0)  #=> fail: Expected 1.0 to be Infinity.
    assert_float(-Float::INFINITY, 1)   #=> fail: Expected 1 to be -Infinity.
    assert_float(1, 1/0)                #=> fail: Expected Infinity to be 1.
    assert_float(1, -1/0)               #=> fail: Expected -Infinity to be 1.
    assert_float(1.0, Float::NAN)       #=> fail: Expected NaN to be 1.0.
    assert_float(Float::NAN, 1)         #=> fail: Expected 1 to be NaN.
2019-03-26 22:12:09 +09:00
KOBAYASHI Shuji b489ddcbd1 Remove implementation of Symbol#===
For reducing program size.
2019-03-25 21:39:11 +09:00
Yukihiro "Matz" Matsumoto f7e05c7d22 Update float test values to avoid precision errors. 2019-03-25 16:54:34 +09:00
Yukihiro "Matz" Matsumoto ce67561511 Avoid infinite binary floating numbers in float. 2019-03-25 16:21:50 +09:00
KOBAYASHI Shuji df4b081392 Refactor t_print for test 2019-03-23 19:27:21 +09:00
KOBAYASHI Shuji 04fc265858 Simplify assert_step in test/t/numeric.rb 2019-03-22 18:37:37 +09:00
Yukihiro "Matz" Matsumoto 84241d3dba Merge pull request #4334 from shuujii/remove-redundant-content-in-assertion-failure-message-and-diff
Remove redundant content in assertion failure message and diff
2019-03-22 14:40:19 +09:00
KOBAYASHI Shuji a41b02ab91 Fix Float#eql? 2019-03-21 21:36:54 +09:00
KOBAYASHI Shuji 2b72baccf3 Remove redundant content in assertion failure message and diff
Based on minitest RubyGem.

Example of before this patch:

    - Assertion[1] Failed: Expected 1 to be 2
       Expected: 2
         Actual: 1
    - Assertion[2] Failed: Expected [1, 3] to include 2
       Collection: [1, 3]
           Object: 2

Example of after this patch:

    - Assertion[1]
       Expected: 2
         Actual: 1
    - Assertion[2]
       Expected [1, 3] to include 2.
2019-03-21 20:53:52 +09:00
KOBAYASHI Shuji fbad7a1595 Use FrozenError instead of RuntimeError in frozen object modification test 2019-03-19 20:48:32 +09:00
KOBAYASHI Shuji b588e5a5b7 Fix class/instance variable name validation
- `@@?` etc are invalid class variable name.
- `@1` etc are invalid instance variable name.
2019-03-17 16:58:31 +09:00
Yukihiro "Matz" Matsumoto a1e1201148 Merge pull request #4328 from shuujii/fix-constant-name-validation
Fix constant name validation
2019-03-15 21:19:48 +09:00
Yukihiro "Matz" Matsumoto 298807fa4e Avoid using infinite binary floating point numbers in tests. 2019-03-15 15:25:43 +09:00
KOBAYASHI Shuji 16b1b2978e Fix constant name validation
`X!` etc are invalid constant name.
2019-03-14 23:09:05 +09:00
KOBAYASHI Shuji c3122c887a Do not raise an exception when bintest fail
- An exception do not raise when mrbtest fail.
- There are no useful informations in exception message and backtrace.
2019-03-13 22:04:14 +09:00
KOBAYASHI Shuji 7d1a8d3f8e Add bintest header 2019-03-10 21:46:24 +09:00
KOBAYASHI Shuji 968e3b9400 Set GEMNAME on bintest 2019-03-07 22:16:47 +09:00
KOBAYASHI Shuji 650ca7da17 Count skip tests 2019-03-05 19:53:25 +09:00
KOBAYASHI Shuji ee537eceee GEMNAME is undefined in bintest
ref: https://github.com/mruby/mruby/pull/4296#discussion_r261868710
2019-03-04 00:18:54 +09:00
KOBAYASHI Shuji c6b8106924 Simplify MRubyTestSkip in test/assert.rb 2019-03-03 18:58:11 +09:00
KOBAYASHI Shuji 729ab86d49 Fix missing assertion in test/t/class.rb 2019-03-02 18:55:02 +09:00
Yukihiro "Matz" Matsumoto e5649eba70 Remove useless regression tests; ref #4306 2019-03-02 14:01:52 +09:00
Yukihiro "Matz" Matsumoto 997cc8238d Remove useless regression tests; fix #4306 2019-03-02 14:00:25 +09:00
Yukihiro "Matz" Matsumoto f1fb2bf29e Remove ?A style string literals from string tests; #4303
We have a plan to obsolete this style in the future.
2019-02-28 12:55:44 +09:00
dearblue f9a568adcb Add test for string literal concatenation 2019-02-27 22:58:13 +09:00
KOBAYASHI Shuji fdb7f9dad3 Remove unneeded => in test skip/error messages 2019-02-26 21:32:34 +09:00
KOBAYASHI Shuji 5c40203930 Refine mrbgem name in assertion failure/skip message for core test 2019-02-24 19:21:40 +09:00
Yukihiro "Matz" Matsumoto 769b56c3ae Merge pull request #4290 from shuujii/refactor-exception-handling-in-assert
Refactor exception handling in `assert`
2019-02-21 22:37:09 +09:00
KOBAYASHI Shuji ad789944db Refactor exception handling in assert 2019-02-21 17:44:45 +09:00
KOBAYASHI Shuji 244abdae09 assert_true/assert_false should pass when actual is only true/false
For the following reasons:

- Previous behavior is confusable because it's different from test/unit rubygem's `assert_true`
- Tests may pass unintentionally in an inappropriate way; ref #4285 #4287
2019-02-20 18:49:38 +09:00
KOBAYASHI Shuji 8a7298e069 Use more appropriate assertion methods 2019-02-19 20:02:50 +09:00
KOBAYASHI Shuji d68eb3d043 Fix wrong assertion method in some tests 2019-02-18 21:24:20 +09:00
KOBAYASHI Shuji 6cdac5efb6 Lazy message/diff creation for assertion in test/assert.rb
Include the following changes too:

- Extract part of logic with block to a method
- Use `var ||= ...` instead of `var = ... unless var`
- Unify using parentheses for `t_print`
- Change methods order
2019-02-14 09:04:42 +09:00
KOBAYASHI Shuji e60f5f5cee Always through assert_true for assertion methods in test/assert.rb 2019-02-09 21:48:12 +09:00
KOBAYASHI Shuji abbc501433 class/module expression with empty body should return nil
Before:

  p(class A end)          #=> A
  p(class << self; end)   #=> #<Class:#<Object:0x7fdc3880e420>>
  p(module B end)         #=> B

After/Ruby:

  p(class A end)          #=> nil
  p(class << self; end)   #=> nil
  p(module B end)         #=> nil
2019-01-28 21:29:55 +09:00
KOBAYASHI Shuji 6d5a62cf5f Fix tests for String#reverse with MRB_UTF8_STRING 2019-01-22 19:37:14 +09:00
KOBAYASHI Shuji cfe3654fd1 Fix assertion name for Numeric#** test 2019-01-17 21:16:02 +09:00
KOBAYASHI Shuji de5da4b7f6 Fix coercing for first step counter in Numeric#step
Before:

  a=[]; 7.step(4, -3.0) { |c| a << c }; p a  #=> [7, 4.0]

After / Ruby:

  a=[]; 7.step(4, -3.0) { |c| a << c }; p a  #=> [7.0, 4.0]
2019-01-15 21:41:54 +09:00
KOBAYASHI Shuji 9f081183d2 Improve compatibility to CRuby for Float#to_s
Bfore:

  Float::INFINITY.to_s  #=> "inf"
  50.0.to_s             #=> "50"
  1e20.to_s             #=> "1e+20"

After / CRuby:

  Float::INFINITY.to_s  #=> "Infinity"
  50.0.to_s             #=> "50.0"
  1e20.to_s             #=> "1.0e+20"
2019-01-13 19:59:22 +09:00
KOBAYASHI Shuji 8b951710fe Use __send__ instead of send; ref #4207 2019-01-12 22:21:34 +09:00
KOBAYASHI Shuji 6f395a58d2 Add assert_same and assert_not_same 2019-01-05 20:41:09 +09:00
Yukihiro "Matz" Matsumoto cca19532c5 Remove Kernel#class_defined? which is not available in CRuby; #3829 2019-01-03 11:34:35 +09:00