3 assert('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"
10 assert('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 '"ok"', o
19 script, bin = Tempfile.new('test.rb'), Tempfile.new('test.mrb')
24 assert_equal "\"#{script.path}\"", `#{cmd('mruby')} "#{script.path}"`.chomp
27 `#{cmd('mrbc')} -o "#{bin.path}" "#{script.path}"`
28 assert_equal "\"#{bin.path}\"", `#{cmd('mruby')} -b "#{bin.path}"`.chomp
31 assert_equal '"-e"', `#{cmd('mruby')} -e #{shellquote('p $0')}`.chomp
34 assert('float literal') do
35 script, bin = Tempfile.new('test.rb'), Tempfile.new('test.mrb')
36 File.write script.path, 'p [3.21, 2e308.infinite?, -2e308.infinite?]'
37 system "#{cmd('mrbc')} -g -o #{bin.path} #{script.path}"
38 assert_equal "[3.21, 1, -1]", `#{cmd('mruby')} -b #{bin.path}`.chomp!
41 assert '__END__', '8.6' do
42 script = Tempfile.new('test.rb')
52 assert_equal "\"test\"\n\"fin\"\n", `#{cmd('mruby')} #{script.path}`
55 assert('garbage collecting built-in classes') do
56 script = Tempfile.new('test.rb')
65 assert_equal "NilClass", `#{cmd('mruby')} #{script.path}`
66 assert_equal 0, $?.exitstatus
69 assert('mruby -d option') do
70 o = `#{cmd('mruby')} -e #{shellquote('p $DEBUG')}`
71 assert_equal "false\n", o
72 o = `#{cmd('mruby')} -d -e #{shellquote('p $DEBUG')}`
73 assert_equal "true\n", o
76 assert('mruby -r option') do
77 lib = Tempfile.new('lib.rb')
87 script = Tempfile.new('test.rb')
92 assert_equal 'hoge', `#{cmd('mruby')} -r #{lib.path} #{script.path}`
93 assert_equal 0, $?.exitstatus
95 assert_equal 'hogeClass', `#{cmd('mruby')} -r #{lib.path} -r #{script.path} -e #{shellquote('print Hoge.class')}`
96 assert_equal 0, $?.exitstatus