source: EcnlProtoTool/trunk/mruby-1.3.0/mrbgems/mruby-bin-mruby/bintest/mruby.rb@ 331

Last change on this file since 331 was 331, checked in by coas-nagasima, 6 years ago

prototoolに関連するプロジェクトをnewlibからmuslを使うよう変更・更新
ntshellをnewlibの下位の実装から、muslのsyscallの実装に変更・更新
以下のOSSをアップデート
・mruby-1.3.0
・musl-1.1.18
・onigmo-6.1.3
・tcc-0.9.27
以下のOSSを追加
・openssl-1.1.0e
・curl-7.57.0
・zlib-1.2.11
以下のmrbgemsを追加
・iij/mruby-digest
・iij/mruby-env
・iij/mruby-errno
・iij/mruby-iijson
・iij/mruby-ipaddr
・iij/mruby-mock
・iij/mruby-require
・iij/mruby-tls-openssl

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-ruby;charset=UTF-8
File size: 1.5 KB
Line 
1require 'tempfile'
2
3assert('regression for #1564') do
4 o = `#{cmd('mruby')} -e #{shellquote('<<')} 2>&1`
5 assert_include o, "-e:1:2: syntax error"
6 o = `#{cmd('mruby')} -e #{shellquote('<<-')} 2>&1`
7 assert_include o, "-e:1:3: syntax error"
8end
9
10assert('regression for #1572') do
11 script, bin = Tempfile.new('test.rb'), Tempfile.new('test.mrb')
12 File.write script.path, 'p "ok"'
13 system "#{cmd('mrbc')} -g -o #{bin.path} #{script.path}"
14 o = `#{cmd('mruby')} -b #{bin.path}`.strip
15 assert_equal o, '"ok"'
16end
17
18assert '$0 value' do
19 script, bin = Tempfile.new('test.rb'), Tempfile.new('test.mrb')
20
21 # .rb script
22 script.write "p $0\n"
23 script.flush
24 assert_equal "\"#{script.path}\"", `#{cmd('mruby')} "#{script.path}"`.chomp
25
26 # .mrb file
27 `#{cmd('mrbc')} -o "#{bin.path}" "#{script.path}"`
28 assert_equal "\"#{bin.path}\"", `#{cmd('mruby')} -b "#{bin.path}"`.chomp
29
30 # one liner
31 assert_equal '"-e"', `#{cmd('mruby')} -e #{shellquote('p $0')}`.chomp
32end
33
34assert '__END__', '8.6' do
35 script = Tempfile.new('test.rb')
36
37 script.write <<EOS
38p 'test'
39 __END__ = 'fin'
40p __END__
41__END__
42p 'legend'
43EOS
44 script.flush
45 assert_equal "\"test\"\n\"fin\"\n", `#{cmd('mruby')} #{script.path}`
46end
47
48assert('garbage collecting built-in classes') do
49 script = Tempfile.new('test.rb')
50
51 script.write <<RUBY
52NilClass = nil
53GC.start
54Array.dup
55print nil.class.to_s
56RUBY
57 script.flush
58 assert_equal "NilClass", `#{cmd('mruby')} #{script.path}`
59 assert_equal 0, $?.exitstatus
60end
Note: See TracBrowser for help on using the repository browser.