cauterize 0.0.1.pre13 → 0.0.1.pre14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +33 -33
- data/.rspec +1 -1
- data/.travisci.yml +4 -4
- data/Gemfile +4 -4
- data/LICENSE.txt +21 -21
- data/README.md +177 -177
- data/Rakefile +54 -54
- data/bin/cauterize +61 -61
- data/cauterize.gemspec +27 -27
- data/example/Cauterize +68 -68
- data/example/build.sh +25 -25
- data/example/c_example_support/empty_main.c +1 -1
- data/example/c_example_support/example_project_config.c +11 -11
- data/example/c_example_support/example_project_config.h +15 -15
- data/example/ruby_ex.rb +14 -14
- data/lib/cauterize.rb +117 -117
- data/lib/cauterize/base_type.rb +78 -78
- data/lib/cauterize/builders.rb +41 -41
- data/lib/cauterize/builders/c/buildable.rb +91 -91
- data/lib/cauterize/builders/c/builtin.rb +43 -43
- data/lib/cauterize/builders/c/composite.rb +57 -57
- data/lib/cauterize/builders/c/enumeration.rb +60 -60
- data/lib/cauterize/builders/c/fixed_array.rb +74 -74
- data/lib/cauterize/builders/c/group.rb +143 -143
- data/lib/cauterize/builders/c/scalar.rb +34 -34
- data/lib/cauterize/builders/c/variable_array.rb +98 -98
- data/lib/cauterize/builders/cs/buildable.rb +59 -59
- data/lib/cauterize/builders/cs/builtin.rb +22 -22
- data/lib/cauterize/builders/cs/composite.rb +21 -21
- data/lib/cauterize/builders/cs/csarray.rb +32 -32
- data/lib/cauterize/builders/cs/enumeration.rb +21 -21
- data/lib/cauterize/builders/cs/fixed_array.rb +27 -27
- data/lib/cauterize/builders/cs/group.rb +32 -32
- data/lib/cauterize/builders/cs/scalar.rb +10 -10
- data/lib/cauterize/builders/cs/variable_array.rb +40 -34
- data/lib/cauterize/builders/doc/buildable.rb +30 -30
- data/lib/cauterize/builders/doc/builtin.rb +21 -21
- data/lib/cauterize/builders/doc/composite.rb +23 -23
- data/lib/cauterize/builders/doc/enumeration.rb +24 -24
- data/lib/cauterize/builders/doc/fixed_array.rb +26 -26
- data/lib/cauterize/builders/doc/group.rb +29 -29
- data/lib/cauterize/builders/doc/scalar.rb +21 -21
- data/lib/cauterize/builders/doc/variable_array.rb +26 -26
- data/lib/cauterize/builders/ruby/buildable.rb +11 -11
- data/lib/cauterize/builders/ruby/builtin.rb +25 -25
- data/lib/cauterize/builders/ruby/composite.rb +26 -26
- data/lib/cauterize/builders/ruby/enumeration.rb +27 -27
- data/lib/cauterize/builders/ruby/fixed_array.rb +20 -20
- data/lib/cauterize/builders/ruby/group.rb +35 -35
- data/lib/cauterize/builders/ruby/scalar.rb +19 -19
- data/lib/cauterize/builders/ruby/variable_array.rb +22 -22
- data/lib/cauterize/builtin.rb +62 -62
- data/lib/cauterize/c_builder.rb +103 -103
- data/lib/cauterize/cauterize.rb +76 -76
- data/lib/cauterize/composite.rb +64 -64
- data/lib/cauterize/cs_builder.rb +58 -58
- data/lib/cauterize/doc_builder.rb +34 -34
- data/lib/cauterize/enumeration.rb +98 -98
- data/lib/cauterize/fixed_array.rb +50 -50
- data/lib/cauterize/formatter.rb +67 -67
- data/lib/cauterize/group.rb +81 -81
- data/lib/cauterize/representation.rb +32 -32
- data/lib/cauterize/ruby_builder.rb +44 -44
- data/lib/cauterize/scalar.rb +53 -53
- data/lib/cauterize/snake_case.rb +21 -21
- data/lib/cauterize/variable_array.rb +55 -55
- data/lib/cauterize/version.rb +3 -3
- data/spec/base_type_spec.rb +251 -251
- data/spec/builders/c/buildable_spec.rb +25 -25
- data/spec/builders/c/builtin_spec.rb +22 -22
- data/spec/builders/c/composite_spec.rb +50 -50
- data/spec/builders/c/enumeration_spec.rb +95 -95
- data/spec/builders/c/fixed_array_spec.rb +36 -36
- data/spec/builders/c/group_spec.rb +140 -140
- data/spec/builders/c/scalar_spec.rb +26 -26
- data/spec/builders/c/variable_array_spec.rb +48 -48
- data/spec/builders/cs/buildable_spec.rb +8 -8
- data/spec/builders/cs/composite_spec.rb +32 -32
- data/spec/builders/cs/enumeration_spec.rb +33 -33
- data/spec/builders/cs/fixed_array_spec.rb +41 -41
- data/spec/builders/cs/group_spec.rb +56 -56
- data/spec/builders/cs/scalar_spec.rb +7 -7
- data/spec/builders/cs/variable_array_spec.rb +49 -45
- data/spec/builders/doc/buildable_spec.rb +25 -25
- data/spec/builders_spec.rb +57 -57
- data/spec/builtin_spec.rb +43 -43
- data/spec/c_builder_spec.rb +176 -176
- data/spec/cauterize_spec.rb +15 -15
- data/spec/composite_spec.rb +77 -77
- data/spec/cs_builder_spec.rb +115 -115
- data/spec/doc_builder_spec.rb +260 -260
- data/spec/enumeration_spec.rb +145 -145
- data/spec/fixed_array_spec.rb +61 -61
- data/spec/group_spec.rb +111 -111
- data/spec/ruby_builder_spec.rb +83 -83
- data/spec/ruby_generated_spec.rb +735 -735
- data/spec/scalar_spec.rb +44 -44
- data/spec/spec_helper.rb +122 -122
- data/spec/support/shared_examples_for_array_buildables.rb +22 -22
- data/spec/support/shared_examples_for_c_buildables.rb +103 -103
- data/spec/support/shared_examples_for_sane_c_buildables.rb +22 -22
- data/spec/support/shared_examples_for_stubbed_functions.rb +18 -18
- data/spec/support/spec_sample_model.rb +74 -74
- data/spec/test_main.c +13 -13
- data/spec/variable_array_spec.rb +73 -73
- data/support/c/src/cauterize.c +75 -75
- data/support/c/src/cauterize.h +60 -60
- data/support/c/src/cauterize_debug.h +29 -29
- data/support/c/src/cauterize_util.h +8 -8
- data/support/c/test/greatest.h +536 -536
- data/support/c/test/test.c +166 -166
- data/support/cs/src/CauterizeCompositeFormatter.cs +0 -0
- data/support/cs/src/CauterizeContainerFormatter.cs +0 -0
- data/support/cs/src/CauterizeEnumFormatter.cs +0 -0
- data/support/cs/src/CauterizeException.cs +15 -15
- data/support/cs/src/CauterizeFixedArrayFormatter.cs +2 -2
- data/support/cs/src/CauterizeFormatter.cs +0 -0
- data/support/cs/src/CauterizeGroupFormatter.cs +0 -0
- data/support/cs/src/CauterizeTypeFormatterFactory.cs +0 -0
- data/support/cs/src/CauterizeTypes.cs +46 -12
- data/support/cs/src/CauterizeVariableArrayFormatter.cs +1 -1
- data/support/cs/src/ICauterizeTypeFormatter.cs +0 -0
- data/support/cs/src/OrderAttribute.cs +0 -0
- data/support/cs/src/PrimitiveSupport.cs +12 -0
- data/support/cs/test/CauterizeCompositeFormatterTest.cs +0 -0
- data/support/cs/test/CauterizeEnumFormatterTest.cs +0 -0
- data/support/cs/test/CauterizeFixedArrayFormatterTest.cs +0 -0
- data/support/cs/test/CauterizeFormatterTest.cs +0 -0
- data/support/cs/test/CauterizeGroupFormatterTest.cs +0 -0
- data/support/cs/test/CauterizeIntegrationTest.cs +0 -0
- data/support/cs/test/CauterizePrimitiveFormatterTest.cs +0 -0
- data/support/cs/test/CauterizeTypeFormatterFactoryTest.cs +0 -0
- data/support/cs/test/CauterizeVariableArrayFormatterTest.cs +0 -0
- data/support/cs/test/OrderAttributeTest.cs +0 -0
- data/support/ruby/src/cauterize_ruby_baseclasses.rb +367 -367
- data/support/ruby/src/cauterize_ruby_builtins.rb +148 -148
- metadata +20 -20
@@ -1,33 +1,33 @@
|
|
1
|
-
module Cauterize
|
2
|
-
describe Cauterize::Builders::CS::Enumeration do
|
3
|
-
describe ".enum_defn" do
|
4
|
-
let(:en) do
|
5
|
-
_e = Cauterize.enumeration(:foo) do |e|
|
6
|
-
e.value :aaa
|
7
|
-
e.value :bbb
|
8
|
-
e.value "quick_brown_fox".to_sym
|
9
|
-
end
|
10
|
-
|
11
|
-
f = default_formatter
|
12
|
-
Builders.get(:cs, _e).enum_defn(f)
|
13
|
-
f.to_s
|
14
|
-
end
|
15
|
-
|
16
|
-
it "contains the serialized representation annotation" do
|
17
|
-
en.should match /\[SerializedRepresentation\(typeof\(SByte\)\)\]/
|
18
|
-
end
|
19
|
-
|
20
|
-
it "contains the enum name" do
|
21
|
-
en.should match /public enum Foo/
|
22
|
-
end
|
23
|
-
|
24
|
-
it "contains an entry for each value" do
|
25
|
-
en.should match /Aaa = 0,/
|
26
|
-
en.should match /Bbb = 1,/
|
27
|
-
en.should match /QuickBrownFox = 2,/
|
28
|
-
en.should match /};/
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
1
|
+
module Cauterize
|
2
|
+
describe Cauterize::Builders::CS::Enumeration do
|
3
|
+
describe ".enum_defn" do
|
4
|
+
let(:en) do
|
5
|
+
_e = Cauterize.enumeration(:foo) do |e|
|
6
|
+
e.value :aaa
|
7
|
+
e.value :bbb
|
8
|
+
e.value "quick_brown_fox".to_sym
|
9
|
+
end
|
10
|
+
|
11
|
+
f = default_formatter
|
12
|
+
Builders.get(:cs, _e).enum_defn(f)
|
13
|
+
f.to_s
|
14
|
+
end
|
15
|
+
|
16
|
+
it "contains the serialized representation annotation" do
|
17
|
+
en.should match /\[SerializedRepresentation\(typeof\(SByte\)\)\]/
|
18
|
+
end
|
19
|
+
|
20
|
+
it "contains the enum name" do
|
21
|
+
en.should match /public enum Foo/
|
22
|
+
end
|
23
|
+
|
24
|
+
it "contains an entry for each value" do
|
25
|
+
en.should match /Aaa = 0,/
|
26
|
+
en.should match /Bbb = 1,/
|
27
|
+
en.should match /QuickBrownFox = 2,/
|
28
|
+
en.should match /};/
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
@@ -1,41 +1,41 @@
|
|
1
|
-
describe Cauterize::Builders::CS::FixedArray do
|
2
|
-
|
3
|
-
context "array class definition" do
|
4
|
-
let(:fixed_arr) do
|
5
|
-
Cauterize.scalar(:uint32_t) {|t| t.type_name(:uint32)}
|
6
|
-
_fa = Cauterize.fixed_array(:myriad_data) do |a|
|
7
|
-
a.array_type :uint32_t
|
8
|
-
a.array_size 16
|
9
|
-
end
|
10
|
-
|
11
|
-
Cauterize::Builders.get(:cs, _fa)
|
12
|
-
end
|
13
|
-
|
14
|
-
describe ".class_defn" do
|
15
|
-
let(:text) do
|
16
|
-
f = four_space_formatter
|
17
|
-
fixed_arr.class_defn(f)
|
18
|
-
text = f.to_s
|
19
|
-
end
|
20
|
-
it "defines a class for the array" do
|
21
|
-
text.should match /public class MyriadData : CauterizeFixedArrayTyped<UInt32>/
|
22
|
-
end
|
23
|
-
|
24
|
-
it "sets the size of the array from configuration" do
|
25
|
-
text.should match /public MyriadData\(\)/ # no args
|
26
|
-
text.should match /Allocate\(16\);/
|
27
|
-
end
|
28
|
-
|
29
|
-
it "allows defaulting an array" do
|
30
|
-
text.should match /public MyriadData\(UInt32\[\] data\)/
|
31
|
-
text.should match /Allocate\(data\);/
|
32
|
-
end
|
33
|
-
|
34
|
-
it "defines a size" do
|
35
|
-
text.should match /public static
|
36
|
-
text.should match /protected override
|
37
|
-
text.should match /get { return MySize; }/
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
1
|
+
describe Cauterize::Builders::CS::FixedArray do
|
2
|
+
|
3
|
+
context "array class definition" do
|
4
|
+
let(:fixed_arr) do
|
5
|
+
Cauterize.scalar(:uint32_t) {|t| t.type_name(:uint32)}
|
6
|
+
_fa = Cauterize.fixed_array(:myriad_data) do |a|
|
7
|
+
a.array_type :uint32_t
|
8
|
+
a.array_size 16
|
9
|
+
end
|
10
|
+
|
11
|
+
Cauterize::Builders.get(:cs, _fa)
|
12
|
+
end
|
13
|
+
|
14
|
+
describe ".class_defn" do
|
15
|
+
let(:text) do
|
16
|
+
f = four_space_formatter
|
17
|
+
fixed_arr.class_defn(f)
|
18
|
+
text = f.to_s
|
19
|
+
end
|
20
|
+
it "defines a class for the array" do
|
21
|
+
text.should match /public class MyriadData : CauterizeFixedArrayTyped<UInt32>/
|
22
|
+
end
|
23
|
+
|
24
|
+
it "sets the size of the array from configuration" do
|
25
|
+
text.should match /public MyriadData\(\)/ # no args
|
26
|
+
text.should match /Allocate\(16\);/
|
27
|
+
end
|
28
|
+
|
29
|
+
it "allows defaulting an array" do
|
30
|
+
text.should match /public MyriadData\(UInt32\[\] data\)/
|
31
|
+
text.should match /Allocate\(data\);/
|
32
|
+
end
|
33
|
+
|
34
|
+
it "defines a size" do
|
35
|
+
text.should match /public static ulong MySize = 16;/
|
36
|
+
text.should match /protected override ulong Size/
|
37
|
+
text.should match /get { return MySize; }/
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -1,56 +1,56 @@
|
|
1
|
-
module Cauterize
|
2
|
-
describe Cauterize::Builders::CS::Group do
|
3
|
-
context "enumeration for type tag" do
|
4
|
-
before do
|
5
|
-
Cauterize.scalar(:uint8_t) {|t| t.type_name(:uint8)}
|
6
|
-
@g = Cauterize.group!(:some_name) do |_g|
|
7
|
-
_g.field(:a, :uint8_t)
|
8
|
-
_g.field(:b, :uint8_t)
|
9
|
-
_g.dataless(:c)
|
10
|
-
_g.field(:d, :uint8_t)
|
11
|
-
end
|
12
|
-
@b = Cauterize::Builders::CS::Group.new(@g)
|
13
|
-
end
|
14
|
-
|
15
|
-
describe ".initialize" do
|
16
|
-
it "creates the enumeration tag" do
|
17
|
-
@b.instance_variable_get(:@tag_enum).class.name.should == "Cauterize::Enumeration"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe "@tag_enum" do
|
22
|
-
it "contains a entry for each field in the group" do
|
23
|
-
e = @b.instance_variable_get(:@tag_enum)
|
24
|
-
e.values.keys.should =~ [ :GROUP_SOME_NAME_TYPE_A,
|
25
|
-
:GROUP_SOME_NAME_TYPE_B,
|
26
|
-
:GROUP_SOME_NAME_TYPE_C,
|
27
|
-
:GROUP_SOME_NAME_TYPE_D ]
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe ".class_defn" do
|
32
|
-
it "defines an enum and class" do
|
33
|
-
f = four_space_formatter
|
34
|
-
@b.class_defn(f)
|
35
|
-
fs = f.to_s
|
36
|
-
|
37
|
-
fs.should == <<EOS
|
38
|
-
public class SomeName : CauterizeGroup
|
39
|
-
{
|
40
|
-
[Order(0)]
|
41
|
-
public GroupSomeNameType Type { get; set; }
|
42
|
-
|
43
|
-
[Order(1)]
|
44
|
-
public Byte A { get; set; }
|
45
|
-
[Order(2)]
|
46
|
-
public Byte B { get; set; }
|
47
|
-
/* No data associated with 'c'. */
|
48
|
-
[Order(4)]
|
49
|
-
public Byte D { get; set; }
|
50
|
-
}
|
51
|
-
EOS
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
1
|
+
module Cauterize
|
2
|
+
describe Cauterize::Builders::CS::Group do
|
3
|
+
context "enumeration for type tag" do
|
4
|
+
before do
|
5
|
+
Cauterize.scalar(:uint8_t) {|t| t.type_name(:uint8)}
|
6
|
+
@g = Cauterize.group!(:some_name) do |_g|
|
7
|
+
_g.field(:a, :uint8_t)
|
8
|
+
_g.field(:b, :uint8_t)
|
9
|
+
_g.dataless(:c)
|
10
|
+
_g.field(:d, :uint8_t)
|
11
|
+
end
|
12
|
+
@b = Cauterize::Builders::CS::Group.new(@g)
|
13
|
+
end
|
14
|
+
|
15
|
+
describe ".initialize" do
|
16
|
+
it "creates the enumeration tag" do
|
17
|
+
@b.instance_variable_get(:@tag_enum).class.name.should == "Cauterize::Enumeration"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "@tag_enum" do
|
22
|
+
it "contains a entry for each field in the group" do
|
23
|
+
e = @b.instance_variable_get(:@tag_enum)
|
24
|
+
e.values.keys.should =~ [ :GROUP_SOME_NAME_TYPE_A,
|
25
|
+
:GROUP_SOME_NAME_TYPE_B,
|
26
|
+
:GROUP_SOME_NAME_TYPE_C,
|
27
|
+
:GROUP_SOME_NAME_TYPE_D ]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe ".class_defn" do
|
32
|
+
it "defines an enum and class" do
|
33
|
+
f = four_space_formatter
|
34
|
+
@b.class_defn(f)
|
35
|
+
fs = f.to_s
|
36
|
+
|
37
|
+
fs.should == <<EOS
|
38
|
+
public class SomeName : CauterizeGroup
|
39
|
+
{
|
40
|
+
[Order(0)]
|
41
|
+
public GroupSomeNameType Type { get; set; }
|
42
|
+
|
43
|
+
[Order(1)]
|
44
|
+
public Byte A { get; set; }
|
45
|
+
[Order(2)]
|
46
|
+
public Byte B { get; set; }
|
47
|
+
/* No data associated with 'c'. */
|
48
|
+
[Order(4)]
|
49
|
+
public Byte D { get; set; }
|
50
|
+
}
|
51
|
+
EOS
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
|
-
module Cauterize
|
2
|
-
describe Cauterize::Builders::CS::Scalar do
|
3
|
-
let(:type_constructor) { lambda {|name| Cauterize.scalar(name)}}
|
4
|
-
|
5
|
-
pending "base buildable tests for csharp"
|
6
|
-
end
|
7
|
-
end
|
1
|
+
module Cauterize
|
2
|
+
describe Cauterize::Builders::CS::Scalar do
|
3
|
+
let(:type_constructor) { lambda {|name| Cauterize.scalar(name)}}
|
4
|
+
|
5
|
+
pending "base buildable tests for csharp"
|
6
|
+
end
|
7
|
+
end
|
@@ -1,45 +1,49 @@
|
|
1
|
-
describe Cauterize::Builders::CS::VariableArray do
|
2
|
-
|
3
|
-
context "array class definition" do
|
4
|
-
let(:var_arr) do
|
5
|
-
Cauterize.scalar(:uint32_t) {|t| t.type_name(:uint32)}
|
6
|
-
Cauterize.scalar(:uint8_t) {|t| t.type_name(:uint8)}
|
7
|
-
_va = Cauterize.variable_array(:myriad_data) do |a|
|
8
|
-
a.array_type :uint32_t
|
9
|
-
a.array_size 16
|
10
|
-
end
|
11
|
-
|
12
|
-
Cauterize::Builders.get(:cs, _va)
|
13
|
-
end
|
14
|
-
|
15
|
-
describe ".class_defn" do
|
16
|
-
let(:text) do
|
17
|
-
f = four_space_formatter
|
18
|
-
var_arr.class_defn(f)
|
19
|
-
text = f.to_s
|
20
|
-
end
|
21
|
-
it "defines a class for the array" do
|
22
|
-
text.should match /public class MyriadData : CauterizeVariableArrayTyped<UInt32>/
|
23
|
-
end
|
24
|
-
|
25
|
-
it "defines the size type" do
|
26
|
-
text.should match /public static Type SizeType = typeof\(Byte\);/
|
27
|
-
end
|
28
|
-
|
29
|
-
it "
|
30
|
-
text.should match /public
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
text.should match /
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
text.should match /
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
1
|
+
describe Cauterize::Builders::CS::VariableArray do
|
2
|
+
|
3
|
+
context "array class definition" do
|
4
|
+
let(:var_arr) do
|
5
|
+
Cauterize.scalar(:uint32_t) {|t| t.type_name(:uint32)}
|
6
|
+
Cauterize.scalar(:uint8_t) {|t| t.type_name(:uint8)}
|
7
|
+
_va = Cauterize.variable_array(:myriad_data) do |a|
|
8
|
+
a.array_type :uint32_t
|
9
|
+
a.array_size 16
|
10
|
+
end
|
11
|
+
|
12
|
+
Cauterize::Builders.get(:cs, _va)
|
13
|
+
end
|
14
|
+
|
15
|
+
describe ".class_defn" do
|
16
|
+
let(:text) do
|
17
|
+
f = four_space_formatter
|
18
|
+
var_arr.class_defn(f)
|
19
|
+
text = f.to_s
|
20
|
+
end
|
21
|
+
it "defines a class for the array" do
|
22
|
+
text.should match /public class MyriadData : CauterizeVariableArrayTyped<UInt32>/
|
23
|
+
end
|
24
|
+
|
25
|
+
it "defines the size type" do
|
26
|
+
text.should match /public static Type SizeType = typeof\(Byte\);/
|
27
|
+
end
|
28
|
+
|
29
|
+
it "defines the max size" do
|
30
|
+
text.should match /public static ulong MyMaxSize = 16;/
|
31
|
+
end
|
32
|
+
|
33
|
+
it "sets the size of the array from configuration" do
|
34
|
+
text.should match /public MyriadData\(ulong size\)/ # no args
|
35
|
+
text.should match /Allocate\(size\);/
|
36
|
+
end
|
37
|
+
|
38
|
+
it "allows defaulting an array" do
|
39
|
+
text.should match /public MyriadData\(UInt32\[\] data\)/
|
40
|
+
text.should match /Allocate\(data\);/
|
41
|
+
end
|
42
|
+
|
43
|
+
it "defines a max size" do
|
44
|
+
text.should match /protected override ulong MaxSize/
|
45
|
+
text.should match /get { return MyMaxSize; }/
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -1,25 +1,25 @@
|
|
1
|
-
module Cauterize::Builders::Doc
|
2
|
-
describe Cauterize::Builders::Doc do
|
3
|
-
describe Buildable do
|
4
|
-
subject { Buildable.new(:some_blueprint) }
|
5
|
-
|
6
|
-
describe "required methods" do
|
7
|
-
it "raises errorson required interfaces" do
|
8
|
-
lambda {
|
9
|
-
REQUIRED_METHODS.each do |m|
|
10
|
-
subject.send(m)
|
11
|
-
end
|
12
|
-
}.should raise_error /must implement/
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe :method_missing do
|
17
|
-
it "calls the original if method not required" do
|
18
|
-
lambda {
|
19
|
-
subject.is_not_defined
|
20
|
-
}.should raise_error NoMethodError
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
1
|
+
module Cauterize::Builders::Doc
|
2
|
+
describe Cauterize::Builders::Doc do
|
3
|
+
describe Buildable do
|
4
|
+
subject { Buildable.new(:some_blueprint) }
|
5
|
+
|
6
|
+
describe "required methods" do
|
7
|
+
it "raises errorson required interfaces" do
|
8
|
+
lambda {
|
9
|
+
REQUIRED_METHODS.each do |m|
|
10
|
+
subject.send(m)
|
11
|
+
end
|
12
|
+
}.should raise_error /must implement/
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe :method_missing do
|
17
|
+
it "calls the original if method not required" do
|
18
|
+
lambda {
|
19
|
+
subject.is_not_defined
|
20
|
+
}.should raise_error NoMethodError
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/spec/builders_spec.rb
CHANGED
@@ -1,57 +1,57 @@
|
|
1
|
-
module Cauterize
|
2
|
-
describe Cauterize::Builders do
|
3
|
-
describe "#register and #get" do
|
4
|
-
let(:s) { Cauterize.scalar(:uint8_t) }
|
5
|
-
before do
|
6
|
-
class X; def initialize(i); end; end
|
7
|
-
class Y; def initialize(i); end; end
|
8
|
-
class Z; def initialize(i); end; end
|
9
|
-
|
10
|
-
# save the old list so that we can restore it later.
|
11
|
-
old_builders = nil
|
12
|
-
Cauterize::Builders.module_exec do
|
13
|
-
old_builders = @builders
|
14
|
-
@builders = nil
|
15
|
-
end
|
16
|
-
@old_builders = old_builders
|
17
|
-
end
|
18
|
-
|
19
|
-
after do
|
20
|
-
# restore the builders so as not to break any other tests
|
21
|
-
old_builders = @old_builders
|
22
|
-
Cauterize::Builders.module_exec do
|
23
|
-
@builders = old_builders
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
it "saves and retrieves classes" do
|
28
|
-
Cauterize::Builders.register(:c, Cauterize::Scalar, X)
|
29
|
-
Cauterize::Builders.get(:c, s).class.should be X
|
30
|
-
end
|
31
|
-
|
32
|
-
it "handles multiple languages" do
|
33
|
-
Cauterize::Builders.register(:c, Cauterize::Scalar, X)
|
34
|
-
Cauterize::Builders.get(:c, s).class.should be X
|
35
|
-
|
36
|
-
Cauterize::Builders.register(:cs, Cauterize::Scalar, Y)
|
37
|
-
Cauterize::Builders.get(:cs, s).class.should be Y
|
38
|
-
|
39
|
-
Cauterize::Builders.register(:ruby, Cauterize::Scalar, Z)
|
40
|
-
Cauterize::Builders.get(:ruby, s).class.should be Z
|
41
|
-
end
|
42
|
-
|
43
|
-
it "raises an error on duplicate registrations" do
|
44
|
-
Cauterize::Builders.register(:c, Cauterize::Scalar, X)
|
45
|
-
lambda {
|
46
|
-
Cauterize::Builders.register(:c, Cauterize::Scalar, X)
|
47
|
-
}.should raise_error /already registered/
|
48
|
-
end
|
49
|
-
|
50
|
-
it "raises exception no builder is registered" do
|
51
|
-
lambda {
|
52
|
-
Cauterize::Builders.get(:c, s)
|
53
|
-
}.should raise_error Cauterize::Builders::UnregisteredException
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
1
|
+
module Cauterize
|
2
|
+
describe Cauterize::Builders do
|
3
|
+
describe "#register and #get" do
|
4
|
+
let(:s) { Cauterize.scalar(:uint8_t) }
|
5
|
+
before do
|
6
|
+
class X; def initialize(i); end; end
|
7
|
+
class Y; def initialize(i); end; end
|
8
|
+
class Z; def initialize(i); end; end
|
9
|
+
|
10
|
+
# save the old list so that we can restore it later.
|
11
|
+
old_builders = nil
|
12
|
+
Cauterize::Builders.module_exec do
|
13
|
+
old_builders = @builders
|
14
|
+
@builders = nil
|
15
|
+
end
|
16
|
+
@old_builders = old_builders
|
17
|
+
end
|
18
|
+
|
19
|
+
after do
|
20
|
+
# restore the builders so as not to break any other tests
|
21
|
+
old_builders = @old_builders
|
22
|
+
Cauterize::Builders.module_exec do
|
23
|
+
@builders = old_builders
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
it "saves and retrieves classes" do
|
28
|
+
Cauterize::Builders.register(:c, Cauterize::Scalar, X)
|
29
|
+
Cauterize::Builders.get(:c, s).class.should be X
|
30
|
+
end
|
31
|
+
|
32
|
+
it "handles multiple languages" do
|
33
|
+
Cauterize::Builders.register(:c, Cauterize::Scalar, X)
|
34
|
+
Cauterize::Builders.get(:c, s).class.should be X
|
35
|
+
|
36
|
+
Cauterize::Builders.register(:cs, Cauterize::Scalar, Y)
|
37
|
+
Cauterize::Builders.get(:cs, s).class.should be Y
|
38
|
+
|
39
|
+
Cauterize::Builders.register(:ruby, Cauterize::Scalar, Z)
|
40
|
+
Cauterize::Builders.get(:ruby, s).class.should be Z
|
41
|
+
end
|
42
|
+
|
43
|
+
it "raises an error on duplicate registrations" do
|
44
|
+
Cauterize::Builders.register(:c, Cauterize::Scalar, X)
|
45
|
+
lambda {
|
46
|
+
Cauterize::Builders.register(:c, Cauterize::Scalar, X)
|
47
|
+
}.should raise_error /already registered/
|
48
|
+
end
|
49
|
+
|
50
|
+
it "raises exception no builder is registered" do
|
51
|
+
lambda {
|
52
|
+
Cauterize::Builders.get(:c, s)
|
53
|
+
}.should raise_error Cauterize::Builders::UnregisteredException
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|