summaryrefslogtreecommitdiff
path: root/test/fiddle/test_cparser.rb
diff options
context:
space:
mode:
authorhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-01-03 09:23:43 +0000
committerhsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-01-03 09:23:43 +0000
commit1ba6e8868c9e353be4dfeb3fc407aa2334b35f62 (patch)
treec42f33733dbc3456ee582d28ac32166971d75428 /test/fiddle/test_cparser.rb
parent68f7424bdeb9a8ec6e91e94937fe7cc72f8b890c (diff)
* ext/fiddle/lib/fiddle/cparser.rb: r49110 brake Fiddle::Import with
type_alias * test/fiddle/test_cparser.rb: added type_alias test for parse_ctype and parse_struct_signature. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49119 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/fiddle/test_cparser.rb')
-rw-r--r--test/fiddle/test_cparser.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/fiddle/test_cparser.rb b/test/fiddle/test_cparser.rb
index fb62a15bf94..4d4799d8d64 100644
--- a/test/fiddle/test_cparser.rb
+++ b/test/fiddle/test_cparser.rb
@@ -59,6 +59,14 @@ module Fiddle
assert_equal(TYPE_UINTPTR_T, parse_ctype("uintptr_t"))
end
+ def test_undefined_ctype
+ assert_raises(DLError) { parse_ctype('DWORD') }
+ end
+
+ def test_undefined_ctype_with_type_alias
+ assert_equal(-TYPE_LONG, parse_ctype('DWORD', {"DWORD" => "unsigned long"}))
+ end
+
def test_struct_basic
assert_equal [[TYPE_INT, TYPE_CHAR], ['i', 'c']], parse_struct_signature(['int i', 'char c'])
end
@@ -83,6 +91,14 @@ module Fiddle
assert_equal [[TYPE_INT,TYPE_VOIDP,TYPE_VOIDP], ['x', 'cb', 'name']], parse_struct_signature('int x; void (*cb)(); const char* name')
end
+ def test_struct_undefined
+ assert_raises(DLError) { parse_struct_signature(['int i', 'DWORD cb']) }
+ end
+
+ def test_struct_undefined_with_type_alias
+ assert_equal [[TYPE_INT,-TYPE_LONG], ['i', 'cb']], parse_struct_signature(['int i', 'DWORD cb'], {"DWORD" => "unsigned long"})
+ end
+
def test_signature_basic
func, ret, args = parse_signature('void func()')
assert_equal 'func', func