summaryrefslogtreecommitdiff
path: root/test/ffi/parser.lua
diff options
context:
space:
mode:
Diffstat (limited to 'test/ffi/parser.lua')
-rw-r--r--test/ffi/parser.lua71
1 files changed, 71 insertions, 0 deletions
diff --git a/test/ffi/parser.lua b/test/ffi/parser.lua
index 66e041d2..0a54ed1f 100644
--- a/test/ffi/parser.lua
+++ b/test/ffi/parser.lua
@@ -2,6 +2,8 @@ local utility = require 'utility'
local cdriver = require 'LuaJIT.c-parser.cdriver'
rawset(_G, 'TEST', true)
+local ctypes = require 'LuaJIT.c-parser.ctypes'
+ctypes.TESTMODE = true
function TEST(wanted, full)
return function (script)
@@ -19,6 +21,75 @@ end
TEST {
+ name = 'union@a',
+ type = {
+ name = 'a',
+ type = 'union',
+ fields = {
+ { name = 'b', type = { 'int' } },
+ { name = 'c', type = { 'int8_t' } }
+ }
+ }
+} [[
+ union a{
+ int b;
+ int8_t c;
+ };
+]]
+
+TEST {
+ name = 'union@a',
+ type = {
+ name = 'a',
+ type = 'union',
+ }
+} [[
+ union a{};
+]]
+
+TEST {
+ name = 'enum@anonymous',
+ type = {
+ name = 'a',
+ type = 'enum',
+ values = {
+ { name = 'a', value = { 1 } },
+ { name = 'b', value = { 'a' } },
+ }
+ }
+} [[
+ enum {
+ a = 1,
+ b = a,
+ };
+]]
+
+TEST {
+ name = 'enum@a',
+ type = {
+ name = 'a',
+ type = 'enum',
+ values = {
+ { name = 'b', value = { op = '|', { 1 }, { 2 } } },
+ }
+ }
+} [[
+ enum a{
+ b = 1|2,
+ };
+]]
+
+TEST {
+ name = 'enum@a',
+ type = {
+ name = 'a',
+ type = 'enum',
+ }
+} [[
+ enum a{};
+]]
+
+TEST {
name = 'struct@a',
type = {
name = 'a',