aaronp-zomg 1.0.2.20080827232412
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +25 -0
- data/Manifest.txt +238 -0
- data/README.txt +59 -0
- data/Rakefile +43 -0
- data/bin/omfg +56 -0
- data/lib/scanner.rex +169 -0
- data/lib/yacc.y +861 -0
- data/lib/zomg.rb +22 -0
- data/lib/zomg/idl.rb +14 -0
- data/lib/zomg/idl/nodes/attribute.rb +15 -0
- data/lib/zomg/idl/nodes/binary.rb +19 -0
- data/lib/zomg/idl/nodes/constant.rb +15 -0
- data/lib/zomg/idl/nodes/interface.rb +13 -0
- data/lib/zomg/idl/nodes/interface_header.rb +14 -0
- data/lib/zomg/idl/nodes/member.rb +14 -0
- data/lib/zomg/idl/nodes/node.rb +54 -0
- data/lib/zomg/idl/nodes/operation.rb +17 -0
- data/lib/zomg/idl/nodes/parameter.rb +18 -0
- data/lib/zomg/idl/nodes/typedef.rb +13 -0
- data/lib/zomg/idl/nodes/union.rb +14 -0
- data/lib/zomg/idl/parser.rb +54 -0
- data/lib/zomg/idl/visitable.rb +15 -0
- data/lib/zomg/idl/visitors/duhr.rb +24 -0
- data/lib/zomg/idl/visitors/ruby_sexp.rb +204 -0
- data/lib/zomg/idl/visitors/sexp.rb +274 -0
- data/lib/zomg/version.rb +3 -0
- data/test/assets/array/array1.idl +60 -0
- data/test/assets/array/array2.idl +38 -0
- data/test/assets/array/array3.idl +8 -0
- data/test/assets/array/array4.idl +7 -0
- data/test/assets/array/array5.idl +80 -0
- data/test/assets/attribute/grid_0attribs_2methods.idl +16 -0
- data/test/assets/attribute/grid_1ROattribs_1attribs_0methods.idl +19 -0
- data/test/assets/attribute/grid_1ROattribs_1attribs_1methods.idl +19 -0
- data/test/assets/attribute/grid_1ROattribs_1attribs_2methods.idl +17 -0
- data/test/assets/attribute/grid_1ROattribs_1methods.idl +16 -0
- data/test/assets/attribute/grid_1ROattribs_2methods.idl +16 -0
- data/test/assets/attribute/grid_1attribs_1methods.idl +17 -0
- data/test/assets/attribute/grid_1attribs_2methods.idl +17 -0
- data/test/assets/attribute/grid_2ROattribs_0methods.idl +16 -0
- data/test/assets/attribute/grid_2ROattribs_1methods.idl +16 -0
- data/test/assets/attribute/grid_2ROattribs_2methods.idl +16 -0
- data/test/assets/attribute/grid_2attribs_0methods.idl +19 -0
- data/test/assets/attribute/grid_2attribs_1methods.idl +19 -0
- data/test/assets/attribute/grid_2attribs_2methods.idl +19 -0
- data/test/assets/comment/c_style_comments.idl +63 -0
- data/test/assets/comment/comment1.idl +57 -0
- data/test/assets/comment/cpp_style_comments.idl +168 -0
- data/test/assets/comment/shortform.idl +0 -0
- data/test/assets/complex/TestCodeSets.idl +10 -0
- data/test/assets/complex/TestIntfContext.idl +13 -0
- data/test/assets/complex/TestIntfLongLong.idl +51 -0
- data/test/assets/complex/TestIntfWChar.idl +52 -0
- data/test/assets/complex/any1.idl +22 -0
- data/test/assets/complex/complex1.idl +495 -0
- data/test/assets/complex/complex2.idl +730 -0
- data/test/assets/complex/complex3.idl +181 -0
- data/test/assets/complex/complex4.idl +181 -0
- data/test/assets/complex/interop_wchar.idl +60 -0
- data/test/assets/constant/constant1.idl +37 -0
- data/test/assets/constant/constant2.idl +29 -0
- data/test/assets/constant/constant3.idl +50 -0
- data/test/assets/constant/constant4.idl +21 -0
- data/test/assets/constant/constant5.idl +65 -0
- data/test/assets/constant/constant6.idl +144 -0
- data/test/assets/constant/constant7.idl +30 -0
- data/test/assets/enum/enum1.idl +13 -0
- data/test/assets/exception/TestIntfExceptions.idl +69 -0
- data/test/assets/exception/TestIntfExceptionsExt_2_0.idl +34 -0
- data/test/assets/exception/TestIntfExceptionsExt_2_3.idl +24 -0
- data/test/assets/exception/ex1.idl +6 -0
- data/test/assets/exception/ex2.idl +18 -0
- data/test/assets/exception/ex3.idl +10 -0
- data/test/assets/exception/ex4.idl +20 -0
- data/test/assets/exception/sc.idl +0 -0
- data/test/assets/exception/simple1.idl +18 -0
- data/test/assets/exception/simple2.idl +25 -0
- data/test/assets/factory/factory1.idl +77 -0
- data/test/assets/factory/objref.idl +25 -0
- data/test/assets/forward/forward.idl +15 -0
- data/test/assets/forward/forward1.idl +13 -0
- data/test/assets/forward/fwd_incl1.idl +6 -0
- data/test/assets/forward/fwd_incl2.idl +7 -0
- data/test/assets/include/a.idl +23 -0
- data/test/assets/include/b.idl +16 -0
- data/test/assets/include/employee.idl +12 -0
- data/test/assets/include/include1.idl +10 -0
- data/test/assets/include/include2.idl +5 -0
- data/test/assets/include/manager.idl +10 -0
- data/test/assets/include/pragma.idl +41 -0
- data/test/assets/include/rookie.idl +13 -0
- data/test/assets/include/rookiemanager.idl +15 -0
- data/test/assets/include/sample.idl +58 -0
- data/test/assets/include/sample_incl.idl +406 -0
- data/test/assets/inherit/IDL1.idl +18 -0
- data/test/assets/inherit/IDL2.idl +18 -0
- data/test/assets/inherit/IDL3.idl +18 -0
- data/test/assets/inherit/IDL4.idl +17 -0
- data/test/assets/inherit/diamond_inheritance.idl +31 -0
- data/test/assets/inherit/inherit.idl +27 -0
- data/test/assets/limit/longidentifiers.idl +25 -0
- data/test/assets/limit/namelens.idl +26 -0
- data/test/assets/limit/tpztest.idl +21 -0
- data/test/assets/module/module1.idl +29 -0
- data/test/assets/module/module2.idl +34 -0
- data/test/assets/module/module3.idl +20 -0
- data/test/assets/module/module4.idl +15 -0
- data/test/assets/nested/nested1.idl +5 -0
- data/test/assets/nested/nested2.idl +11 -0
- data/test/assets/operations/Benchmark.idl +331 -0
- data/test/assets/operations/CCS.idl +82 -0
- data/test/assets/operations/TestIntf.idl +40 -0
- data/test/assets/operations/TestIntfBasic.idl +653 -0
- data/test/assets/operations/atomic.idl +40 -0
- data/test/assets/operations/dif2.idl +48 -0
- data/test/assets/operations/interface1.idl +16 -0
- data/test/assets/operations/parameters.idl +111 -0
- data/test/assets/operations/perf.idl +84 -0
- data/test/assets/operations/timer.idl +104 -0
- data/test/assets/preprocess/base_for_diamond_inheritance_with_macros.idl +17 -0
- data/test/assets/preprocess/basic_macro_marshalling.idl +54 -0
- data/test/assets/preprocess/diamond_inheritance_with_macros.idl +74 -0
- data/test/assets/preprocess/macro1.idl +52 -0
- data/test/assets/preprocess/preprocess1.idl +246 -0
- data/test/assets/preprocess/preprocess2.idl +3 -0
- data/test/assets/recursion/loop.idl +28 -0
- data/test/assets/recursion/recursion1.idl +47 -0
- data/test/assets/recursion/recursion2.idl +74 -0
- data/test/assets/scenarios/filestat.idl +69 -0
- data/test/assets/scenarios/gateway.idl +176 -0
- data/test/assets/scenarios/library.idl +20 -0
- data/test/assets/scenarios/phone.idl +24 -0
- data/test/assets/scenarios/ticketservice.idl +118 -0
- data/test/assets/scope/scope01.idl +58 -0
- data/test/assets/scope/scope02.idl +25 -0
- data/test/assets/scope/scope03.idl +22 -0
- data/test/assets/scope/scope04.idl +27 -0
- data/test/assets/scope/scope05.idl +30 -0
- data/test/assets/scope/scope06.idl +51 -0
- data/test/assets/scope/scope07.idl +20 -0
- data/test/assets/scope/scope08.idl +88 -0
- data/test/assets/scope/scope09.idl +21 -0
- data/test/assets/scope/scope10.idl +95 -0
- data/test/assets/scope/scope11.idl +62 -0
- data/test/assets/scope/scope12.idl +117 -0
- data/test/assets/scope/scope13.idl +117 -0
- data/test/assets/scope/scope14.idl +117 -0
- data/test/assets/scope/scope15.idl +117 -0
- data/test/assets/scope/scope16.idl +117 -0
- data/test/assets/scope/scope17.idl +117 -0
- data/test/assets/scope/scope18.idl +117 -0
- data/test/assets/scope/scope19.idl +117 -0
- data/test/assets/scope/scope20.idl +215 -0
- data/test/assets/scope/scope21.idl +215 -0
- data/test/assets/scope/scope22.idl +205 -0
- data/test/assets/scope/scope23.idl +261 -0
- data/test/assets/scope/scope24.idl +376 -0
- data/test/assets/scope/scope25.idl +266 -0
- data/test/assets/scope/scope26.idl +180 -0
- data/test/assets/scope/scope27.idl +184 -0
- data/test/assets/scope/scope28.idl +182 -0
- data/test/assets/scope/scope29.idl +182 -0
- data/test/assets/scope/scope30.idl +40 -0
- data/test/assets/scope/scope31.idl +33 -0
- data/test/assets/scope/scope32.idl +37 -0
- data/test/assets/scope/scope33.idl +50 -0
- data/test/assets/scope/scope34.idl +97 -0
- data/test/assets/scope/scope35.idl +72 -0
- data/test/assets/scope/scope36.idl +167 -0
- data/test/assets/scope/scope37.idl +57 -0
- data/test/assets/scope/scope38.idl +38 -0
- data/test/assets/scope/scope39.idl +38 -0
- data/test/assets/scope/scope40.idl +38 -0
- data/test/assets/scope/scope41.idl +24 -0
- data/test/assets/scope/scope42.idl +64 -0
- data/test/assets/scope/scope43.idl +66 -0
- data/test/assets/scope/scope44.idl +52 -0
- data/test/assets/sequence/sequence1.idl +24 -0
- data/test/assets/sequence/sequence2.idl +9 -0
- data/test/assets/simple/basictypes1.idl +80 -0
- data/test/assets/simple/basictypes2.idl +197 -0
- data/test/assets/simple/basictypes3.idl +23 -0
- data/test/assets/simple/basictypes4.idl +73 -0
- data/test/assets/simple/basictypes5.idl +29 -0
- data/test/assets/simple/basictypes6.idl +63 -0
- data/test/assets/simple/simple1.idl +45 -0
- data/test/assets/simple/simple2.idl +61 -0
- data/test/assets/simple/simple3.idl +36 -0
- data/test/assets/string/string1.idl +11 -0
- data/test/assets/string/string2.idl +29 -0
- data/test/assets/struct/struct1.idl +20 -0
- data/test/assets/struct/struct2.idl +21 -0
- data/test/assets/struct/struct3.idl +42 -0
- data/test/assets/struct/struct4.idl +57 -0
- data/test/assets/struct/struct5.idl +71 -0
- data/test/assets/typecode/orb.idl +0 -0
- data/test/assets/typecode/pseudo.idl +25 -0
- data/test/assets/typedef/shorthand_typedef_struct_insideIF.idl +17 -0
- data/test/assets/typedef/shorthand_typedef_struct_insideIF_noMO.idl +16 -0
- data/test/assets/typedef/shorthand_typedef_struct_insideMO.idl +17 -0
- data/test/assets/typedef/shorthand_typedef_struct_outsideMO.idl +17 -0
- data/test/assets/typedef/typedef1.idl +8 -0
- data/test/assets/typedef/typedef2.idl +22 -0
- data/test/assets/typedef/typedef_struct_insideIF.idl +18 -0
- data/test/assets/typedef/typedef_struct_insideMO.idl +18 -0
- data/test/assets/typedef/typedef_struct_outsideMO.idl +18 -0
- data/test/assets/union/union1.idl +31 -0
- data/test/assets/union/union2.idl +22 -0
- data/test/assets/union/union3.idl +26 -0
- data/test/conversions/test_attribute.rb +46 -0
- data/test/conversions/test_enum.rb +25 -0
- data/test/conversions/test_exception.rb +24 -0
- data/test/conversions/test_forward_declaration.rb +22 -0
- data/test/conversions/test_interface.rb +30 -0
- data/test/conversions/test_module.rb +24 -0
- data/test/conversions/test_struct.rb +25 -0
- data/test/conversions/test_typedef.rb +22 -0
- data/test/conversions/test_union.rb +27 -0
- data/test/conversions/test_value_box_dcl.rb +22 -0
- data/test/helper.rb +23 -0
- data/test/simple/test_basictypes1.rb +87 -0
- data/test/simple/test_basictypes2.rb +18 -0
- data/test/simple/test_basictypes3.rb +32 -0
- data/test/simple/test_basictypes4.rb +25 -0
- data/test/simple/test_basictypes5.rb +17 -0
- data/test/simple/test_basictypes6.rb +19 -0
- data/test/simple/test_simple1.rb +40 -0
- data/test/simple/test_simple2.rb +48 -0
- data/test/simple/test_simple3.rb +20 -0
- data/test/test_array.rb +22 -0
- data/test/test_assets.rb +33 -0
- data/test/test_complex.rb +17 -0
- data/test/test_node.rb +16 -0
- data/test/test_parser.rb +17 -0
- data/test/test_scanner.rb +234 -0
- metadata +334 -0
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
module ZOMG
|
4
|
+
module Conversions
|
5
|
+
class EnumTest < ZOMG::Test
|
6
|
+
def setup
|
7
|
+
@tree = ZOMG::IDL.parse(<<-eoidl)
|
8
|
+
enum Foo {
|
9
|
+
a,
|
10
|
+
b
|
11
|
+
};
|
12
|
+
eoidl
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_to_ruby_sexp
|
16
|
+
sexp = nil
|
17
|
+
ruby_sexp = [:block, [:cdecl, :Foo, [:hash, [:lit, :a], [:lit, :a], [:lit, :b], [:lit, :b]]]]
|
18
|
+
assert_nothing_raised {
|
19
|
+
sexp = @tree.to_ruby_sexp
|
20
|
+
}
|
21
|
+
assert_equal(ruby_sexp, sexp)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
module ZOMG
|
4
|
+
module Conversions
|
5
|
+
class ExceptionTest < ZOMG::Test
|
6
|
+
def setup
|
7
|
+
@tree = ZOMG::IDL.parse(<<-eoidl)
|
8
|
+
exception not_implemented {};
|
9
|
+
exception AvocadoExcpt{
|
10
|
+
::Avocado ex1;
|
11
|
+
};
|
12
|
+
eoidl
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_to_ruby_sexp
|
16
|
+
sexp = nil
|
17
|
+
assert_nothing_raised {
|
18
|
+
sexp = @tree.to_ruby_sexp
|
19
|
+
}
|
20
|
+
assert_equal([:block, [:class, :Not_implemented, [:const, :Exception], [:scope]], [:class, :AvocadoExcpt, [:const, :Exception], [:scope, [:fcall, :attr_accessor, [:array, [:lit, :ex1]]]]]], sexp)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
module ZOMG
|
4
|
+
module Conversions
|
5
|
+
class ForwardDeclarationTest < ZOMG::Test
|
6
|
+
def setup
|
7
|
+
@tree = ZOMG::IDL.parse(<<-eoidl)
|
8
|
+
interface A;
|
9
|
+
eoidl
|
10
|
+
end
|
11
|
+
|
12
|
+
# We don't bother with forward declarations in Ruby
|
13
|
+
def test_to_ruby_sexp
|
14
|
+
sexp = nil
|
15
|
+
assert_nothing_raised {
|
16
|
+
sexp = @tree.to_ruby_sexp
|
17
|
+
}
|
18
|
+
assert_equal([:block, nil], sexp)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
module ZOMG
|
4
|
+
module Conversions
|
5
|
+
class InterfaceTest < ZOMG::Test
|
6
|
+
def setup
|
7
|
+
@tree = ZOMG::IDL.parse(<<-eoidl)
|
8
|
+
interface Foo {
|
9
|
+
void a ( );
|
10
|
+
short b ( in short a );
|
11
|
+
long c ( in short a, out IntSequence b, inout float c );
|
12
|
+
};
|
13
|
+
|
14
|
+
interface Bar: Foo, Baz {
|
15
|
+
void d ( );
|
16
|
+
};
|
17
|
+
eoidl
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_to_ruby_sexp
|
21
|
+
sexp = nil
|
22
|
+
ruby_sexp = [:block, [:module, :Foo, [:scope, [:block, [:defn, :a, [:scope, [:block, [:args], [:fcall, :raise, [:array, [:call, [:const, :NotImplementedError], :new]]]]]], [:defn, :b, [:scope, [:block, [:args, :a], [:fcall, :raise, [:array, [:call, [:const, :NotImplementedError], :new]]]]]], [:defn, :c, [:scope, [:block, [:args, :a, :b, :c], [:fcall, :raise, [:array, [:call, [:const, :NotImplementedError], :new]]]]]]]]], [:module, :Bar, [:scope, [:block, [:fcall, :include, [:array, [:const, :Foo], [:const, :Baz]]], [:defn, :d, [:scope, [:block, [:args], [:fcall, :raise, [:array, [:call, [:const, :NotImplementedError], :new]]]]]]]]]]
|
23
|
+
assert_nothing_raised {
|
24
|
+
sexp = @tree.to_ruby_sexp
|
25
|
+
}
|
26
|
+
assert_equal(ruby_sexp, sexp)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
module ZOMG
|
4
|
+
module Conversions
|
5
|
+
class ModuleTest < ZOMG::Test
|
6
|
+
def setup
|
7
|
+
@parser = ZOMG::IDL::Parser.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_module
|
11
|
+
tree = @parser.parse(<<-eoidl)
|
12
|
+
module dom
|
13
|
+
{
|
14
|
+
const unsigned short INDEX_SIZE_ERR = 1;
|
15
|
+
};
|
16
|
+
eoidl
|
17
|
+
assert_equal(
|
18
|
+
[:block, [:module, :Dom, [:scope, [:block, [:cdecl, :INDEX_SIZE_ERR, [:lit, 1]]]]]],
|
19
|
+
tree.to_ruby_sexp
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
module ZOMG
|
4
|
+
module Conversions
|
5
|
+
class StructTest < ZOMG::Test
|
6
|
+
def setup
|
7
|
+
@tree = ZOMG::IDL.parse(<<-eoidl)
|
8
|
+
struct Foo {
|
9
|
+
short a;
|
10
|
+
long b;
|
11
|
+
};
|
12
|
+
eoidl
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_to_ruby_sexp
|
16
|
+
sexp = nil
|
17
|
+
ruby_sexp = [:block, [:cdecl, :Foo, [:call, [:const, :Struct], :new, [:array, [:lit, :a], [:lit, :b]]]]]
|
18
|
+
assert_nothing_raised {
|
19
|
+
sexp = @tree.to_ruby_sexp
|
20
|
+
}
|
21
|
+
assert_equal(ruby_sexp, sexp)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
module ZOMG
|
4
|
+
module Conversions
|
5
|
+
class TypedefTest < ZOMG::Test
|
6
|
+
def setup
|
7
|
+
@tree = ZOMG::IDL.parse(<<-eoidl)
|
8
|
+
typedef long IntSequence[10];
|
9
|
+
eoidl
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_to_ruby_sexp
|
13
|
+
sexp = nil
|
14
|
+
ruby_sexp = [:block, nil]
|
15
|
+
assert_nothing_raised {
|
16
|
+
sexp = @tree.to_ruby_sexp
|
17
|
+
}
|
18
|
+
assert_equal(ruby_sexp, sexp)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
module ZOMG
|
4
|
+
module Conversions
|
5
|
+
class UnionTest < ZOMG::Test
|
6
|
+
def setup
|
7
|
+
@tree = ZOMG::IDL.parse(<<-eoidl)
|
8
|
+
union Foo switch(long) {
|
9
|
+
case 10: string a;
|
10
|
+
case 15:
|
11
|
+
case 20: short b;
|
12
|
+
default: char c;
|
13
|
+
};
|
14
|
+
eoidl
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_to_ruby_sexp
|
18
|
+
sexp = nil
|
19
|
+
ruby_sexp = [:block, [:cdecl, :Foo, [:call, [:const, :Struct], :new, [:array, [:lit, :a], [:lit, :b], [:lit, :c]]]]]
|
20
|
+
assert_nothing_raised {
|
21
|
+
sexp = @tree.to_ruby_sexp
|
22
|
+
}
|
23
|
+
assert_equal(ruby_sexp, sexp)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
module ZOMG
|
4
|
+
module Conversions
|
5
|
+
class ValueBoxDclTest < ZOMG::Test
|
6
|
+
def setup
|
7
|
+
@tree = ZOMG::IDL.parse(<<-eoidl)
|
8
|
+
valuetype DOMString sequence<unsigned short>;
|
9
|
+
eoidl
|
10
|
+
end
|
11
|
+
|
12
|
+
# We don't bother with value boxes. Yay typeless!
|
13
|
+
def test_to_ruby_sexp
|
14
|
+
sexp = nil
|
15
|
+
assert_nothing_raised {
|
16
|
+
sexp = @tree.to_ruby_sexp
|
17
|
+
}
|
18
|
+
assert_equal([:block, nil], sexp)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'zomg'
|
4
|
+
|
5
|
+
module ZOMG
|
6
|
+
class Test < Test::Unit::TestCase
|
7
|
+
include ZOMG::IDL::Nodes
|
8
|
+
ASSETS = File.expand_path(File.join(File.dirname(__FILE__), 'assets'))
|
9
|
+
|
10
|
+
undef :default_test
|
11
|
+
|
12
|
+
def assert_sexp(sexp, obj)
|
13
|
+
assert_equal(sexp, obj.to_sexp)
|
14
|
+
end
|
15
|
+
|
16
|
+
def method_missing(name, *args)
|
17
|
+
super unless args[0]
|
18
|
+
file = File.join(ASSETS, name.to_s, args[0])
|
19
|
+
super unless File.exists?(file)
|
20
|
+
file
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class BasicTypes1Test < ZOMG::Test
|
4
|
+
def setup
|
5
|
+
@tree = ZOMG::IDL::Parser.parse_file(simple('basictypes1.idl'))
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_interface
|
9
|
+
assert_equal(6, @tree.children.length)
|
10
|
+
(_, _, _, _, _, interface) = *(@tree.children)
|
11
|
+
interface.children.each do |child|
|
12
|
+
assert_instance_of(Operation, child)
|
13
|
+
assert_nothing_raised {
|
14
|
+
child.to_sexp
|
15
|
+
}
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_typedef_long
|
20
|
+
assert_equal(6, @tree.children.length)
|
21
|
+
(_, _, _, long, seq, _) = *(@tree.children)
|
22
|
+
assert long
|
23
|
+
assert seq
|
24
|
+
|
25
|
+
assert_instance_of(Typedef, long)
|
26
|
+
assert_instance_of(Typedef, seq)
|
27
|
+
assert_sexp([:typedef, :long, [[:array_decl, "IntSequence", [[:size, [:int, 10]]]]]], long)
|
28
|
+
assert_sexp([:typedef, [:sequence, [:long]], [[:decl, "longSeq"]]], seq)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_union
|
32
|
+
assert_equal(6, @tree.children.length)
|
33
|
+
(_, _, union, _, _, _) = *(@tree.children)
|
34
|
+
assert union
|
35
|
+
assert_instance_of(Union, union)
|
36
|
+
assert_equal('U', union.name)
|
37
|
+
assert_instance_of(Long, union.switch_type)
|
38
|
+
assert_instance_of(Array, union.children)
|
39
|
+
assert_equal(5, union.children.length)
|
40
|
+
union.children.each { |child| assert_instance_of(Case, child) }
|
41
|
+
[ CaseLabel,
|
42
|
+
CaseLabel,
|
43
|
+
CaseLabel,
|
44
|
+
CaseLabel,
|
45
|
+
DefaultLabel ].each_with_index { |l,i|
|
46
|
+
assert_instance_of(l, union.children[i].children[0])
|
47
|
+
}
|
48
|
+
assert_equal([10, 20, 50, 60], union.children.find_all { |child|
|
49
|
+
child.children[0].is_a?(CaseLabel)
|
50
|
+
}.map { |cl| cl.children[0].to_i })
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_enum
|
54
|
+
assert_equal(6, @tree.children.length)
|
55
|
+
(_, enum, _, _, _, _) = *(@tree.children)
|
56
|
+
assert enum
|
57
|
+
assert_instance_of(Enum, enum)
|
58
|
+
assert_equal('Color', enum.name)
|
59
|
+
assert_equal(4, enum.children.length)
|
60
|
+
assert_equal(%w{ blue green red black }.sort, enum.children.sort)
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_struct
|
64
|
+
assert_equal(6, @tree.children.length)
|
65
|
+
(struct, _, _, _, _, _) = *(@tree.children)
|
66
|
+
assert struct
|
67
|
+
assert_instance_of(Struct, struct)
|
68
|
+
assert_equal('BasicTypes', struct.name)
|
69
|
+
assert_instance_of(Array, struct.children)
|
70
|
+
assert_equal(10, struct.children.length)
|
71
|
+
[
|
72
|
+
Short,
|
73
|
+
UnsignedShort,
|
74
|
+
Long,
|
75
|
+
UnsignedLong,
|
76
|
+
Float,
|
77
|
+
Double,
|
78
|
+
Char,
|
79
|
+
String,
|
80
|
+
Boolean,
|
81
|
+
Octet
|
82
|
+
].each_with_index do |type, i|
|
83
|
+
assert_instance_of(Member, struct.children[i])
|
84
|
+
assert_instance_of(type, struct.children[i].type)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class BasicTypes2Test < ZOMG::Test
|
4
|
+
def setup
|
5
|
+
@tree = ZOMG::IDL::Parser.parse_file(simple('basictypes2.idl'))
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_to_sexp
|
9
|
+
@tree.to_sexp.flatten.each do |member|
|
10
|
+
assert(
|
11
|
+
[ ::String,
|
12
|
+
::Symbol,
|
13
|
+
Numeric ].any? { |m| member.is_a?(m) } ||
|
14
|
+
[true, false, nil].any? { |m| member == m }
|
15
|
+
)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class BasicTypes3Test < ZOMG::Test
|
4
|
+
def setup
|
5
|
+
@tree = ZOMG::IDL::Parser.parse_file(simple('basictypes3.idl'))
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_readonly
|
9
|
+
assert_sexp(
|
10
|
+
[:attribute, :readonly, :long, [[:decl, "l2"]]],
|
11
|
+
@tree.children[1].children.first
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_header
|
16
|
+
i2 = @tree.children[1]
|
17
|
+
assert_sexp([:header, false, "ex2", [[:scoped_name, "ex1", []]]],
|
18
|
+
i2.header
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_to_sexp
|
23
|
+
@tree.to_sexp.flatten.each do |member|
|
24
|
+
assert(
|
25
|
+
[ ::String,
|
26
|
+
::Symbol,
|
27
|
+
Numeric ].any? { |m| member.is_a?(m) } ||
|
28
|
+
[true, false, nil].any? { |m| member == m }
|
29
|
+
)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class BasicTypes4Test < ZOMG::Test
|
4
|
+
def setup
|
5
|
+
@tree = ZOMG::IDL::Parser.parse_file(simple('basictypes4.idl'))
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_module_to_sexp
|
9
|
+
assert_sexp(
|
10
|
+
[:typedef, [:string, [[:int, 10]]], [[:decl, "BndString"]]],
|
11
|
+
@tree.duhr.Module[0].Interface[0].Typedef[0]
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_to_sexp
|
16
|
+
@tree.to_sexp.flatten.each do |member|
|
17
|
+
assert(
|
18
|
+
[ ::String,
|
19
|
+
::Symbol,
|
20
|
+
Numeric ].any? { |m| member.is_a?(m) } ||
|
21
|
+
[true, false, nil].any? { |m| member == m }
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class BasicTypes5Test < ZOMG::Test
|
4
|
+
def setup
|
5
|
+
@tree = ZOMG::IDL::Parser.parse_file(simple('basictypes5.idl'))
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_exception
|
9
|
+
assert_sexp([:exception, "not_implemented", []],
|
10
|
+
@tree.duhr.Exception[0]
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_to_sexp
|
15
|
+
assert_nothing_raised { @tree.to_sexp }
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class BasicTypes6Test < ZOMG::Test
|
4
|
+
def setup
|
5
|
+
@tree = ZOMG::IDL::Parser.parse_file(simple('basictypes6.idl'))
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_case
|
9
|
+
assert_sexp([:label, [:charlit, "'L'"]],
|
10
|
+
@tree.duhr.Interface[0].Union[0].Case[0].CaseLabel[0]
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_to_sexp
|
15
|
+
assert_nothing_raised {
|
16
|
+
@tree.to_sexp
|
17
|
+
}
|
18
|
+
end
|
19
|
+
end
|