32 Commits

Author SHA1 Message Date
Yukihiro "Matz" Matsumoto 65e0e5bbd3 class.c (mrb_method_missing): add receiver's class to clarify
We needed to modify a lot of test code that expected the old style.
2024-11-15 15:13:24 +09:00
Chris Reuter 5c4273f944 Added testing support for cross-MinGW builds.
This adds a build_config that will cross-build a Windows executable
using the MinGW cross-compiler and will also run the unit (i.e.
'rake test') using Wine.

For this to work, I made some modifications to the underlying test
scripts as well as some minor changes to a couple of the tests
themselves.
2021-10-21 21:58:45 -04:00
Yukihiro "Matz" Matsumoto 4d249c28d9 Skip tests that use Float inside; ref #5421 2021-04-24 12:04:08 +09:00
Yukihiro "Matz" Matsumoto 590c1073fc should have removed codegen error: prefix from the test. 2021-03-31 11:35:56 +09:00
dearblue a045b6b8d9 Allow to mixed and specify *.rb and *.mrb in bin/mruby
It is not decides by the extension.
In order to be recognized as a `.mrb` file, the following three points must be satisfied:
- File starts with "RITE"
- At least `sizeof(struct rite_binary_header)` bytes can be read
- `NUL` is included in the first 64 bytes of the file
If these are not met, it is judged as a text file and it is processed as a Ruby script.

The `bin/mruby -b` switch is still available which treats the given file as a `.mrb` file.

New `MRB_API` function:
- `include/mruby/compile.h` and `mrbgems/mruby-compiler/core/parse.y`
  - `mrb_load_detect_file_cxt()` (remove with `MRB_DISABLE_STDIO`)

NOTE:
- Even script files now always open in binary mode for `bin/mruby`.
  The `\r\n` is handled by the `nextc()` function already, so there is no problem even on Windows.
- The `nextc0()` function in `mrbgems/mruby-compiler/core/parse.y` can now specify a string buffer and a file pointer at the same time.
  In this case, get it from the string buffer first.

This patch includes modifies by comment of https://github.com/mruby/mruby/pull/5157.
2020-11-21 19:05:46 +09:00
mimaki 943029954f Fix mruby -v option test. 2020-11-01 14:19:19 +09:00
dearblue 0aa5aa1de2 Add test for top level local variables are in file scope; ref #4931 2020-01-29 23:29:48 +09:00
Yukihiro "Matz" Matsumoto ef95a9fa93 Use a string as a common regexp representation; ref #4847 2019-11-30 21:10:36 +09:00
KOBAYASHI Shuji 49653b81ea Quit mruby -v immediately if no program is given for Ruby compatibility 2019-11-30 19:52:22 +09:00
KOBAYASHI Shuji df437eebcc Fix mruby --verbose (regression by #4827)
#### Before this patch:

  ```
  $ bin/mruby --verbose -e 'p 1'
  bin/mruby: Cannot open program file: --verbose
  ```

#### After this patch:

  ```
  $ bin/mruby --verbose -e 'p 1'
  00001 NODE_SCOPE:
  (snip)
  irep 0x7fe97041df30 nregs=4 nlocals=1 pools=0 syms=1 reps=0 iseq=11
  file: -e
      1 000 OP_LOADSELF R1
  (snip)

  1
  ```
2019-11-29 19:02:04 +09:00
KOBAYASHI Shuji f4b528e07a Support -- (end of options) to mruby command
#### Before this patch:

  ```
  $ bin/mruby -e 'p ARGV' -- -x
  bin/mruby: invalid option -- (-h will show valid options)
  ```

#### After this patch:

  ```
  $ bin/mruby -e 'p ARGV' -- -x
  ["-x"]
  ```
2019-11-27 19:51:43 +09:00
KOBAYASHI Shuji f9bd414350 Fix ARGV value in mruby command (regression by #4827)
#### Before this patch:

  ```
  $ bin/mruby -e 'p ARGV' a b
  ["bin/mruby", "-e", "p ARGV", "a", "b"]
  ```

#### After this patch:

  ```
  $ bin/mruby -e 'p ARGV' a b
  ["a", "b"]
  ```
2019-11-25 21:56:27 +09:00
KOBAYASHI Shuji 9de7130a9a Support short options concatenation to mruby command
#### Before this patch:

  ```
  $ bin/mruby -ce 1
  bin/mruby: Cannot open program file: 1
  ```

#### After this patch:

  ```
  $ bin/mruby -ce 1
  Syntax OK
  ```
2019-11-17 16:38:50 +09:00
KOBAYASHI Shuji 44381f0a0c Refine message to skip in nested assert
- I think "Info" is used only to `skip`, so change to "Skip".
- Changed the default value of `assert` and specify the argument explicitly
  at the caller of `assert` because it is unnatural "Assertion failed" is
  output even though the assertion doesn't fail.

== Example:

  def assert_foo(exp, act)
    assert do
      assert_equal exp[0], act[0]
      assert_equal exp[1], act[1]
    end
  end

  def assert_bar(exp, act)
    assert do
      skip
    end
  end

  def assert_baz(exp, act)
    assert do
      assert_equal exp, act
      assert_bar exp, act
    end
  end

  assert 'test#skip_in_nested_assert' do
    assert_baz 1, 1
  end

  === Before this patch:

    ?..
    Info: test#skip_in_nested_assert (core)
     - Assertion[1]
        Info: Assertion failed (core)
         - Assertion[1-2]
            Skip: Assertion failed (core)
      Total: 3
         OK: 2
         KO: 0
      Crash: 0
    Warning: 0
       Skip: 1

  === After this patch:

    ???
    Skip: test#skip_in_nested_assert (core)
     - Assertion[1]
        Skip: assert (core)
         - Assertion[1-2]
            Skip: assert (core)
      Total: 3
         OK: 0
         KO: 0
      Crash: 0
    Warning: 0
       Skip: 3
2019-07-30 13:05:01 +09:00
dearblue a215292b6a Use nested assert 2019-06-29 11:54:17 +09:00
Yukihiro "Matz" Matsumoto 35319bed01 Use a normal method instead of a lambda in bintest/mruby; ref #4416 2019-05-02 23:03:38 +09:00
KOBAYASHI Shuji 2a94bf8fbd Small fix in mruby-bin-mruby
- Modify some error messages for consistency.
- Add test for codegen error.
- Use regular expression for error message matching in test.
2019-05-01 16:49:56 +09:00
KOBAYASHI Shuji 9bd17226d5 Refine error message output for mruby command
- Write message to stderr instead of stdout.
- Avoid duplicate message output (`SyntaxError`, `ScriptError` etc).
- Refine invalid option message.
- Suppress redundant usage output.
- Fix some incorrect exit code.
2019-04-30 16:58:01 +09:00
KOBAYASHI Shuji 0740595f85 Change the order of "expected" and "actual" in test 2019-01-09 20:00:17 +09:00
KOBAYASHI Shuji 68735d1261 Fix dump/load float leteral evaluate to infinity
Example:

  # example.rb
  p(2e308)
  p(-2e308)

  Good:

    $ bin/mruby example.rb
    inf
    -inf

  Bad:

    $ bin/mrbc example.rb
    $ bin/mruby -b example.mrb
    0
    -0

Cause:

  Float infinity representation is `inf` on dump and it is converted by
  corresponding `String#to_f` on load.

Treatment:

  - Introduce new representations (`i`: +infinity, `I`: -infinity)
  - Allow old representations (`inf`, `-inf`, `infinity`, `-infinity`) too
  - Raise error for unknown representations (use corresponding `Kernel#Float`)
2019-01-08 20:43:23 +09:00
Hiroshi Mimaki d973a8ebc4 Add -r option for mruby and mirb. 2018-05-07 18:17:50 +09:00
Hiroshi Mimaki 0c01afc3c9 Fix CI build errors and warnings. 2018-05-07 12:23:32 +09:00
Hiroshi Mimaki 1d16646506 Add -d option for mruby and mirb. 2018-05-02 20:52:02 +09:00
Tomoyuki Sahara da4f8e19fa replace "yylval" with "pylval" to make it compile with byacc. 2017-02-24 11:47:48 +09:00
Uchio KONDO ab5812d0d8 Use standard Module(Class)#to_s 2017-02-02 18:09:27 +09:00
Bouke van der Bijl f7a891fa89 Mark all the built-in classes during GC sweep
Reported by https://hackerone.com/haquaman
2016-12-07 15:14:12 -05:00
Yasuhiro Matsumoto 545d649eff fix tests on windows.
'bin/mruby' not work on windows. so correct command name and quoted arguments.
2015-09-30 16:13:02 +09:00
take_cheeze aa187956cf Add test for end-of-program marker. 2014-06-08 01:38:44 +09:00
take_cheeze 18718e065a Add test of $0 value in bin/mruby related to #2103 . 2014-04-22 19:19:08 +09:00
take_cheeze 24e3e33cb6 use tempfile module 2014-03-03 17:01:47 +09:00
fleuria 995e0f89cf add regression for #1572 2013-11-16 15:05:15 +08:00
fleuria 2d646a13f7 add regression for #1564 2013-11-16 14:32:43 +08:00