Commit Graph

626 Commits

Author SHA1 Message Date
cremno 5cd877be7f fix masgn nosplat array rhs bug
The rest lhs variable has to be an empty array if rhs is an array with
less elements than pre + post lhs variables. The codegen generated
OP_ARRAY with an invalid length (such as 127 for *a, b = []) because rn
was negative.
2015-05-31 13:30:49 +02:00
Yukihiro "Matz" Matsumoto 9ef4bbb10d update test/t/syntax.rb to success on CRuby 2015-05-31 18:29:26 +09:00
Yukihiro "Matz" Matsumoto 8dd6b0fd09 Merge branch 'failing-multiple-assignments-with-rest-tests' of https://github.com/cremno/mruby into cremno-failing-multiple-assignments-with-rest-tests 2015-05-31 17:02:45 +09:00
cremno 59ea323976 check if outer is a class or module
For modules this check didn't exist yet. Also call #inspect.
2015-05-29 14:58:53 +02:00
cremno ba3a0c22a5 add multiple assignment with rest tests 2015-05-29 12:17:13 +02:00
take_cheeze ab565f16bc Use mrb_funcall instead of mrb_load_string in test driver.
Related to #2760.
2015-05-15 16:06:03 +09:00
cremno 2aa59393ba fix splat without assignment; fix #2781
The parser generates NODE_NIL for tSTAR without argument in masgns. The
codegen didn't handle that.
2015-05-07 16:58:43 +02:00
Miura Hideki eb3af3752f Fix to avoid warning 2015-04-17 20:04:07 +09:00
Miura Hideki a21d3f627e Add test of negative arguments for Integer#% 2015-04-17 17:26:12 +09:00
Kouhei Sutou 4b4ddd5a28 Fix a bug that no expression case doesn't return valid value
Here is a script that reproduces this problem:

     x = case
         when true; 1
         end
     p x # => main # 1 is expected
2015-02-24 20:53:12 +09:00
Kouhei Sutou 584d6de3c2 Fix a bug that if and no return value case can't return true clause value
Here is a script that reproduce this problem:

     x = if true
           1
         else
           case 2
           when 3
           end
           4
         end
     p x # => nil # 1 is expected
2015-02-24 00:16:41 +09:00
Kouhei Sutou 8cb40fcda7 Fix ensure with yield context on break and return
How to reproduce:

    class A
      def x
        yield
      ensure
        y
      end

      def y
      end
    end

    # Work
    A.new.x do
    end

    # Not work
    # trace:
    # 	[2] /tmp/a.rb:5:in A.x
    # 	[0] /tmp/a.rb:15
    # /tmp/a.rb:5: undefined method 'y' for main (NoMethodError)
    A.new.x do
      break
    end

    # trace:
    # 	[2] /tmp/a.rb:5:in A.call
    # 	[0] /tmp/a.rb:19
    # /tmp/a.rb:5: undefined method 'y' for main (NoMethodError)
    lambda do
      A.new.x do
        return
      end
    end.call

`self` in ensure is broken when yield and break/return are used.
2015-02-05 22:40:25 +09:00
Daniel Bovensiepen a3111f144c Round execution time 2015-01-03 17:53:32 +08:00
Kouhei Sutou 5ec676aa37 Fix splat and multiple assignments
Case1: From variable

Code:

    a = [1, 2, 3, 4, 5]
    b, c, *d = a

    p [a, b, c, d]

Before:

    [[1, 2, 3, 4, 5], 1, 2, []]

After:

    [[1, 2, 3, 4, 5], 1, 2, [3, 4, 5]]

Ruby:

    [[1, 2, 3, 4, 5], 1, 2, [3, 4, 5]]

Case2: From variables

Code:

    a = [1, 2, 3]
    b = [4, 5, 6, 7]
    c, d, *e, f, g = *a, *b

    p [a, b, c, d, e, f, g]

Before:

    [[1, 2, 3], [4, 5, 6, 7], 1, 2, [], 6, 7]

After:

    [[1, 2, 3], [4, 5, 6, 7], 1, 2, [3, 4, 5], 6, 7]

Ruby:

    [[1, 2, 3], [4, 5, 6, 7], 1, 2, [3, 4, 5], 6, 7]

Case 3: "for"

Code:

    a = [1, 2, 3, 4, 5, 6, 7]
    for b, c, *d, e, f in [a] do
      p [a, b, c, d, e, f]
    end

Before:

    [[1, 2, 3, 4, 5, 6, 7], 1, 2, [], nil, nil]

After:

    [[1, 2, 3, 4, 5, 6, 7], 1, 2, [3, 4, 5], 6, 7]

Ruby:

    [[1, 2, 3, 4, 5, 6, 7], 1, 2, [3, 4, 5], 6, 7]
2014-12-23 21:16:01 +09:00
h2so5 05b00a14c5 String#[] should reject nil index 2014-12-17 14:01:39 +09:00
Yukihiro "Matz" Matsumoto bcf8ad87e6 add multiple assignment decomposition test 2014-11-27 16:21:48 +09:00
Robert Mosolgo 0133d9ac70 fix(String) String#[] accepts float; close #2650 #2651 2014-11-26 01:03:38 +09:00
Yukihiro "Matz" Matsumoto 69ba4f0ed5 instance_methods etc should not include undef'ed method names; based on a patch from @cremno; fix #2613 2014-10-20 11:11:26 +09:00
Tatsuhiko Kubo bd6dc0da77 Add test for Numeric#pow. 2014-08-25 17:18:24 +09:00
Tatsuhiko Kubo 2b283393c6 Remove empty lines. 2014-08-20 12:07:36 +09:00
Tatsuhiko Kubo effc44f265 Fix error handlings for mrb_open_core(). 2014-08-20 05:48:09 +09:00
Kouhei Sutou e75e2083fd Fix a bug that class variable can't be referenced from class method
Class method defined in singleton class should be evaluated in class
context not singleton class context.

fix #2515
2014-08-09 15:06:17 +09:00
Yukihiro "Matz" Matsumoto e2f7e485e7 Merge pull request #2478 from dreamedge/add_module_function
add Module#module_function
2014-07-26 09:35:58 +09:00
ksss 67fbcf8b2a Fix memory leak for test driver 2014-07-23 14:14:09 +00:00
take_cheeze a24729044a Print backtrace of crashed test in verbose mode. 2014-07-19 22:33:13 +09:00
dreamedge 0b8a0f4bb4 add Module#module_function 2014-07-18 09:50:54 +09:00
take_cheeze a9c52675e6 Set $mrbtest_verbose flag in mrb_init_test_driver. 2014-07-14 21:11:14 +09:00
take_cheeze 3b8a797a4c Fix rake failure since mrbtest_objs isn't flattened.
Append generated test object to `@test_objs` of mrbgem spec.
Add method `custom_test_init?` to check whether mrbgem has custom test init function.
2014-07-12 21:41:44 +09:00
take_cheeze 03866f25f8 Run mrbgem and core tests on minimum dependencies.
Solves #2355.

In test drivers:
* Uses `mrb_t_pass_result` to check and pass test result to main `mrb_state`.
* Adds `mrb_init_test_driver` to init test `mrb_state`.
2014-07-12 14:11:18 +09:00
Yukihiro "Matz" Matsumoto 023908afc2 remove unused return_value 2014-07-09 17:01:59 +09:00
take_cheeze ab779b7ad8 Use mrb_print_error to print exception instead of mrb_p. 2014-07-08 22:25:32 +09:00
take_cheeze 5bb0a1fb5e Print error instead of printing return value of report. 2014-07-08 22:24:35 +09:00
Yukihiro "Matz" Matsumoto ba0ddb7819 fix conflict resolution mistake 2014-06-19 01:55:39 +09:00
Yukihiro "Matz" Matsumoto a47cc0c211 resolve conflict 2014-06-18 23:44:24 +09:00
Yukihiro "Matz" Matsumoto 42f5b741ea remove superclass test for classes that do not exist in mruby (core) 2014-06-18 15:54:43 +09:00
take_cheeze 77047b5ed4 Test all ISO defined classes direct superclass except Object class.
Move mrbgems ISO direct superclass test to `superclass.rb`.
Skips test if class isn't defined.
Close #2332.
2014-06-15 17:07:01 +09:00
take_cheeze ec5b055694 Move direct superclass checking to test/t/superclass.rb. 2014-06-15 15:02:21 +09:00
ksss bd53818999 str_replace: self should not be shared and nofree 2014-06-11 14:42:18 +00:00
Yukihiro "Matz" Matsumoto 6459a98448 move String#clear to mruby-string-ext; ref #2370 2014-06-07 22:28:42 +09:00
Jun Hiroe 9709fe79a3 Implement String#clear 2014-06-07 16:15:32 +09:00
take_cheeze fb3c2f6b08 Add generator script to dependency so that it will regenerate C codes when it's modified. 2014-06-04 22:53:36 +09:00
take_cheeze acec9d1ff1 Implement NoMethodError#args. 2014-06-02 22:38:02 +09:00
Yukihiro "Matz" Matsumoto 35d4137da1 remove part of 9cd71916 test for same reason as 5306e47 2014-06-01 02:51:04 +09:00
Yukihiro "Matz" Matsumoto 84116c26c9 Merge pull request #2320 from yui-knk/test-enumerable
Replace assert_true with assert_equal.
2014-05-25 22:38:25 +09:00
Yukihiro "Matz" Matsumoto 77942f70a5 Merge pull request #2316 from ksss/test-exception
Exception#exception fix test
2014-05-25 22:37:10 +09:00
Yukihiro "Matz" Matsumoto 7c30097183 Merge pull request #2315 from suzukaze/fix-test-proc
Fix assert_equal argument order in test/t/proc.rb
2014-05-25 22:36:05 +09:00
yui-knk 83986e2636 Replace assert_true with assert_equal. 2014-05-25 20:19:41 +09:00
yui-knk 2f952a8f95 Change to use assert method. 2014-05-25 18:56:33 +09:00
yui-knk 6bdeebe3b0 fix typo. 2014-05-25 18:50:43 +09:00
ksss bc0cf69a83 Exception#exception fix test
Exception.exception is not call Exception#exception.
Test for Exception#exception should call Exception#exception method.
2014-05-25 11:18:39 +09:00