Made parser able to report multiple errors per call, using new Voodoo::Parser::Multip...
[voodoo-lang.git] / test / test_output_name.rb
blob6eca3a8f7ee14251eb7c23f97029580adfb9cbb2
1 # Test that output_file_name and output_file_suffix produce the
2 # right results for all code generators
4 # List of test cases.
5 # For each test case, lists:
6 # 1. The architecture
7 # 2. The format
8 # 3. The expected suffix
9 tests = [[:amd64, :elf, '.o'],
10          [:amd64, :nasm, '.asm'],
11          [:i386, :elf, '.o'],
12          [:i386, :nasm, '.asm'],
13          [:mips, :elf, '.o'],
14          [:mips, :gas, '.s'],
15          [:mipsel, :elf, '.o'],
16          [:mipsel, :gas, '.s']]
18 require 'voodoo'
20 prefix = 'plover'
22 errors = 0
24 tests.each do |test|
25   arch, fmt, suffix = test
26   generator = Voodoo::CodeGenerator.get_generator :architecture => arch,
27                                                   :format => fmt
28   
29   x = generator.output_file_suffix
30   if x != suffix
31     $stderr.puts "#{arch.inspect}, #{fmt.inspect} -- " +
32       "expected #{suffix.inspect}, but got #{x.inspect}"
33     errors = errors + 1
34   end
36   expect = prefix + suffix
37   y = generator.output_file_name "#{prefix}.voo"
38   if y != expect
39     $stderr.puts "#{arch.inspect}, #{fmt.inspect} -- " +
40       "expected #{expect.inspect}, but got #{y.inspect}"
41     errors = errors + 1
42   end
43   
44 end
46 if errors == 0
47   puts "pass"
48 else
49   puts "#{errors} tests failed"
50   exit 1
51 end