~ubuntu-branches/ubuntu/quantal/ruby1.9.1/quantal

« back to all changes in this revision

Viewing changes to test/mkmf/test_convertible.rb

  • Committer: Bazaar Package Importer
  • Author(s): Lucas Nussbaum
  • Date: 2011-09-24 19:16:17 UTC
  • mfrom: (1.1.8 upstream) (13.1.7 experimental)
  • Revision ID: james.westby@ubuntu.com-20110924191617-o1qz4rcmqjot8zuy
Tags: 1.9.3~rc1-1
* New upstream release: 1.9.3 RC1.
  + Includes load.c fixes. Closes: #639959.
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
require_relative 'base'
 
2
 
 
3
class TestMkmf
 
4
  class TestConvertible < TestMkmf
 
5
    def test_typeof_builtin
 
6
      ["", ["signed ", ""], "unsigned "].each do |signed, prefix|
 
7
        %w[short int long].each do |type|
 
8
          assert_equal((prefix || signed)+type,
 
9
                       mkmf {convertible_int(signed+type)}, MKMFLOG)
 
10
        end
 
11
      end
 
12
    end
 
13
 
 
14
    def test_typeof_typedef
 
15
      ["", ["signed ", ""], "unsigned "].each do |signed, prefix|
 
16
        %w[short int long].each do |type|
 
17
          open("confdefs.h", "w") {|f|
 
18
            f.puts "typedef #{signed}#{type} test1_t;"
 
19
          }
 
20
          $defs.clear
 
21
          assert_equal((prefix || signed)+type,
 
22
                       mkmf {convertible_int("test1_t", "confdefs.h")}, MKMFLOG)
 
23
          (u = signed[/^u/]) and u.upcase!
 
24
          assert_include($defs, "-DTYPEOF_TEST1_T="+"#{prefix||signed}#{type}".quote)
 
25
          assert_include($defs, "-DPRI_TEST1T_PREFIX=PRI_#{type.upcase}_PREFIX")
 
26
          assert_include($defs, "-DTEST1T2NUM=#{u}#{type.upcase}2NUM")
 
27
          assert_include($defs, "-DNUM2TEST1T=NUM2#{u}#{type.upcase}")
 
28
        end
 
29
      end
 
30
    end
 
31
  end
 
32
end