source: EcnlProtoTool/trunk/mruby-1.2.0/mrbgems/mruby-bin-mruby/bintest/mruby.rb@ 270

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

mruby版ECNLプロトタイピング・ツールを追加

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-ruby
File size: 1.2 KB
Line 
1require 'tempfile'
2
3assert('regression for #1564') do
4 o = `#{cmd('mruby')} -e #{shellquote('<<')} 2>&1`
5 assert_equal o, "-e:1:2: syntax error, unexpected tLSHFT\n"
6 o = `#{cmd('mruby')} -e #{shellquote('<<-')} 2>&1`
7 assert_equal o, "-e:1:3: syntax error, unexpected tLSHFT\n"
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
Note: See TracBrowser for help on using the repository browser.