Commit Graph

467 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
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
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
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
dreamedge 0b8a0f4bb4 add Module#module_function 2014-07-18 09:50:54 +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 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
Jun Hiroe 6a2eced74e Fix assert_equal argument order in test/t/proc.rb 2014-05-25 00:34:40 +09:00
Yukihiro "Matz" Matsumoto fc557085d8 Merge pull request #2304 from ksss/class-new
Class.new do not call `class_eval'
2014-05-22 14:12:03 +09:00
ksss 1f3d7e939f Class.new add test case 2014-05-22 00:11:40 +09:00
ksss 0bd8e48773 Module#initialize set created object
for block argument
2014-05-21 23:09:19 +09:00
yui-knk 756bfa6cd2 Correct comment in exception test. 2014-05-20 23:02:47 +09:00
Yukihiro "Matz" Matsumoto 929328ad3b Merge pull request #2295 from ksss/module-initialize
Implement Module#initialize (15.2.2.4.31)
2014-05-20 16:22:11 +09:00
Yukihiro "Matz" Matsumoto 7195600dbf Merge branch 'master' of github.com:mruby/mruby 2014-05-20 11:27:06 +09:00
Yukihiro "Matz" Matsumoto 4b6de9dea6 update raise in ensure test 2014-05-20 11:25:17 +09:00
Yukihiro "Matz" Matsumoto 3fc8f0435a correct comment; ref #2297 2014-05-20 11:24:15 +09:00
Yukihiro "Matz" Matsumoto b0477f1d3f Merge branch 'add-exception-test' of https://github.com/yui-knk/mruby into yui-knk-add-exception-test 2014-05-20 11:22:49 +09:00
yui-knk f55851cb74 Add 'Raise in rescue' test to exception. 2014-05-20 00:02:03 +09:00
take_cheeze d8d07a2345 Move Kernel.local_variables to core. 2014-05-19 22:05:02 +09:00
ksss ffbf90bdc8 Implement Module#initialize (15.2.2.4.31) 2014-05-19 19:28:42 +09:00