ffi 1.9.5-x86-mingw32 → 1.9.6-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of ffi might be problematic. Click here for more details.
- checksums.yaml +15 -7
- data/Rakefile +13 -6
- data/ext/ffi_c/extconf.rb +2 -2
- data/lib/1.8/ffi_c.so +0 -0
- data/lib/1.9/ffi_c.so +0 -0
- data/lib/2.0/ffi_c.so +0 -0
- data/lib/2.1/ffi_c.so +0 -0
- data/lib/ffi.rb +2 -0
- data/lib/ffi/version.rb +1 -1
- data/spec/ffi/async_callback_spec.rb +4 -5
- data/spec/ffi/bool_spec.rb +9 -8
- data/spec/ffi/buffer_spec.rb +64 -37
- data/spec/ffi/callback_spec.rb +195 -116
- data/spec/ffi/custom_param_type.rb +1 -1
- data/spec/ffi/custom_type_spec.rb +5 -6
- data/spec/ffi/dup_spec.rb +6 -8
- data/spec/ffi/enum_spec.rb +135 -129
- data/spec/ffi/errno_spec.rb +2 -2
- data/spec/ffi/ffi.log +5833 -0
- data/spec/ffi/ffi_spec.rb +4 -6
- data/spec/ffi/function_spec.rb +22 -11
- data/spec/ffi/io_spec.rb +0 -1
- data/spec/ffi/library_spec.rb +71 -36
- data/spec/ffi/long_double.rb +3 -4
- data/spec/ffi/managed_struct_spec.rb +14 -4
- data/spec/ffi/memorypointer_spec.rb +7 -1
- data/spec/ffi/number_spec.rb +43 -34
- data/spec/ffi/platform_spec.rb +76 -59
- data/spec/ffi/pointer_spec.rb +35 -31
- data/spec/ffi/rbx/attach_function_spec.rb +3 -4
- data/spec/ffi/rbx/memory_pointer_spec.rb +24 -22
- data/spec/ffi/rbx/spec_helper.rb +0 -1
- data/spec/ffi/rbx/struct_spec.rb +1 -2
- data/spec/ffi/spec_helper.rb +5 -2
- data/spec/ffi/string_spec.rb +22 -14
- data/spec/ffi/strptr_spec.rb +6 -7
- data/spec/ffi/struct_by_ref_spec.rb +4 -5
- data/spec/ffi/struct_by_ref_spec.rb.orig +43 -0
- data/spec/ffi/struct_callback_spec.rb +6 -7
- data/spec/ffi/struct_initialize_spec.rb +2 -3
- data/spec/ffi/struct_packed_spec.rb +12 -14
- data/spec/ffi/struct_spec.rb +203 -129
- data/spec/ffi/typedef_spec.rb +11 -10
- data/spec/ffi/union_spec.rb +8 -7
- data/spec/ffi/variadic_spec.rb +13 -10
- metadata +150 -139
@@ -4,7 +4,6 @@
|
|
4
4
|
#
|
5
5
|
|
6
6
|
require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
|
7
|
-
require 'ffi'
|
8
7
|
|
9
8
|
describe "functions with custom parameter types" do
|
10
9
|
before :each do
|
@@ -33,5 +32,6 @@ describe "functions with custom parameter types" do
|
|
33
32
|
def self.to_native_called?; @to_native_called; end
|
34
33
|
end
|
35
34
|
|
35
|
+
# FIXME add tests
|
36
36
|
end
|
37
37
|
end
|
@@ -4,7 +4,6 @@
|
|
4
4
|
#
|
5
5
|
|
6
6
|
require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
|
7
|
-
require 'ffi'
|
8
7
|
|
9
8
|
describe "functions with custom types" do
|
10
9
|
class Custom_enum
|
@@ -32,13 +31,13 @@ describe "functions with custom types" do
|
|
32
31
|
end
|
33
32
|
|
34
33
|
it "can attach with custom return type" do
|
35
|
-
|
34
|
+
expect do
|
36
35
|
Module.new do
|
37
36
|
extend FFI::Library
|
38
37
|
ffi_lib TestLibrary::PATH
|
39
38
|
attach_function :ret_s32, [ :int ], Custom_enum
|
40
39
|
end
|
41
|
-
end.
|
40
|
+
end.not_to raise_error
|
42
41
|
end
|
43
42
|
|
44
43
|
it "should return object of correct type" do
|
@@ -50,7 +49,7 @@ describe "functions with custom types" do
|
|
50
49
|
attach_function :ret_s32, [ :int ], Custom_enum
|
51
50
|
end
|
52
51
|
|
53
|
-
m.ret_s32(1).is_a?(Symbol).
|
52
|
+
expect(m.ret_s32(1).is_a?(Symbol)).to be true
|
54
53
|
end
|
55
54
|
|
56
55
|
it "from_native should be called for result" do
|
@@ -60,7 +59,7 @@ describe "functions with custom types" do
|
|
60
59
|
attach_function :ret_s32, [ :int ], Custom_enum
|
61
60
|
end
|
62
61
|
m.ret_s32(1)
|
63
|
-
Custom_enum.from_native_called
|
62
|
+
expect(Custom_enum.from_native_called?).to be true
|
64
63
|
end
|
65
64
|
|
66
65
|
it "to_native should be called for parameter" do
|
@@ -70,6 +69,6 @@ describe "functions with custom types" do
|
|
70
69
|
attach_function :ret_s32, [ Custom_enum ], :int
|
71
70
|
end
|
72
71
|
m.ret_s32(:a)
|
73
|
-
Custom_enum.to_native_called
|
72
|
+
expect(Custom_enum.to_native_called?).to be true
|
74
73
|
end
|
75
74
|
end
|
data/spec/ffi/dup_spec.rb
CHANGED
@@ -4,7 +4,6 @@
|
|
4
4
|
#
|
5
5
|
|
6
6
|
require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
|
7
|
-
require 'ffi'
|
8
7
|
|
9
8
|
describe "Pointer#dup" do
|
10
9
|
it "clone should be independent" do
|
@@ -13,7 +12,7 @@ describe "Pointer#dup" do
|
|
13
12
|
p2 = p1.dup
|
14
13
|
p1.put_string(0, "deadbeef")
|
15
14
|
|
16
|
-
p2.get_string(0).
|
15
|
+
expect(p2.get_string(0)).to eq("test123")
|
17
16
|
end
|
18
17
|
|
19
18
|
it "sliced pointer can be cloned" do
|
@@ -22,8 +21,8 @@ describe "Pointer#dup" do
|
|
22
21
|
p2 = p1[1].dup
|
23
22
|
|
24
23
|
# first char will be excised
|
25
|
-
p2.get_string(0).
|
26
|
-
p1.get_string(0).
|
24
|
+
expect(p2.get_string(0)).to eq("est123")
|
25
|
+
expect(p1.get_string(0)).to eq("test123")
|
27
26
|
end
|
28
27
|
|
29
28
|
it "sliced pointer when cloned is independent" do
|
@@ -33,7 +32,7 @@ describe "Pointer#dup" do
|
|
33
32
|
|
34
33
|
p1.put_string(0, "deadbeef")
|
35
34
|
# first char will be excised
|
36
|
-
p2.get_string(0).
|
35
|
+
expect(p2.get_string(0)).to eq("est123")
|
37
36
|
end
|
38
37
|
end
|
39
38
|
|
@@ -47,8 +46,7 @@ describe "Struct#dup" do
|
|
47
46
|
s1[:i] = 0x12345
|
48
47
|
s2 = s1.dup
|
49
48
|
s1[:i] = 0x98765
|
50
|
-
s2[:i].
|
51
|
-
s1[:i].
|
49
|
+
expect(s2[:i]).to eq(0x12345)
|
50
|
+
expect(s1[:i]).to eq(0x98765)
|
52
51
|
end
|
53
|
-
|
54
52
|
end
|
data/spec/ffi/enum_spec.rb
CHANGED
@@ -4,7 +4,6 @@
|
|
4
4
|
#
|
5
5
|
|
6
6
|
require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
|
7
|
-
require 'ffi'
|
8
7
|
|
9
8
|
module TestEnum0
|
10
9
|
extend FFI::Library
|
@@ -39,183 +38,190 @@ end
|
|
39
38
|
|
40
39
|
describe "A library with no enum defined" do
|
41
40
|
it "returns nil when asked for an enum" do
|
42
|
-
TestEnum0.enum_type(:foo).
|
41
|
+
expect(TestEnum0.enum_type(:foo)).to be_nil
|
43
42
|
end
|
44
43
|
end
|
45
44
|
|
46
45
|
describe "An untagged enum" do
|
47
46
|
it "constants can be used as function parameters and return value" do
|
48
|
-
TestEnum1.test_untagged_enum(:c1).
|
49
|
-
TestEnum1.test_untagged_enum(:c2).
|
50
|
-
TestEnum1.test_untagged_enum(:c3).
|
51
|
-
TestEnum1.test_untagged_enum(:c4).
|
52
|
-
TestEnum1.test_untagged_enum(:c5).
|
53
|
-
TestEnum1.test_untagged_enum(:c6).
|
54
|
-
TestEnum1.test_untagged_enum(:c7).
|
55
|
-
TestEnum1.test_untagged_enum(:c8).
|
56
|
-
TestEnum1.test_untagged_enum(:c9).
|
57
|
-
TestEnum1.test_untagged_enum(:c10).
|
58
|
-
TestEnum1.test_untagged_enum(:c11).
|
59
|
-
TestEnum1.test_untagged_enum(:c12).
|
60
|
-
TestEnum1.test_untagged_enum(:c13).
|
61
|
-
TestEnum1.test_untagged_enum(:c14).
|
62
|
-
TestEnum1.test_untagged_enum(:c15).
|
63
|
-
TestEnum1.test_untagged_enum(:c16).
|
47
|
+
expect(TestEnum1.test_untagged_enum(:c1)).to eq(0)
|
48
|
+
expect(TestEnum1.test_untagged_enum(:c2)).to eq(1)
|
49
|
+
expect(TestEnum1.test_untagged_enum(:c3)).to eq(2)
|
50
|
+
expect(TestEnum1.test_untagged_enum(:c4)).to eq(3)
|
51
|
+
expect(TestEnum1.test_untagged_enum(:c5)).to eq(42)
|
52
|
+
expect(TestEnum1.test_untagged_enum(:c6)).to eq(43)
|
53
|
+
expect(TestEnum1.test_untagged_enum(:c7)).to eq(44)
|
54
|
+
expect(TestEnum1.test_untagged_enum(:c8)).to eq(45)
|
55
|
+
expect(TestEnum1.test_untagged_enum(:c9)).to eq(42)
|
56
|
+
expect(TestEnum1.test_untagged_enum(:c10)).to eq(43)
|
57
|
+
expect(TestEnum1.test_untagged_enum(:c11)).to eq(4242)
|
58
|
+
expect(TestEnum1.test_untagged_enum(:c12)).to eq(4243)
|
59
|
+
expect(TestEnum1.test_untagged_enum(:c13)).to eq(42)
|
60
|
+
expect(TestEnum1.test_untagged_enum(:c14)).to eq(4242)
|
61
|
+
expect(TestEnum1.test_untagged_enum(:c15)).to eq(424242)
|
62
|
+
expect(TestEnum1.test_untagged_enum(:c16)).to eq(42424242)
|
64
63
|
end
|
65
64
|
end
|
66
65
|
|
67
66
|
describe "A tagged typedef enum" do
|
68
67
|
it "is accessible through its tag" do
|
69
|
-
TestEnum3.enum_type(:enum_type1).
|
70
|
-
TestEnum3.enum_type(:enum_type2).
|
71
|
-
TestEnum3.enum_type(:enum_type3).
|
72
|
-
TestEnum3.enum_type(:enum_type4).
|
68
|
+
expect(TestEnum3.enum_type(:enum_type1)).not_to be_nil
|
69
|
+
expect(TestEnum3.enum_type(:enum_type2)).not_to be_nil
|
70
|
+
expect(TestEnum3.enum_type(:enum_type3)).not_to be_nil
|
71
|
+
expect(TestEnum3.enum_type(:enum_type4)).not_to be_nil
|
73
72
|
end
|
73
|
+
|
74
74
|
it "contains enum constants" do
|
75
|
-
TestEnum3.enum_type(:enum_type1).symbols.length.
|
76
|
-
TestEnum3.enum_type(:enum_type2).symbols.length.
|
77
|
-
TestEnum3.enum_type(:enum_type3).symbols.length.
|
78
|
-
TestEnum3.enum_type(:enum_type4).symbols.length.
|
75
|
+
expect(TestEnum3.enum_type(:enum_type1).symbols.length).to eq(4)
|
76
|
+
expect(TestEnum3.enum_type(:enum_type2).symbols.length).to eq(4)
|
77
|
+
expect(TestEnum3.enum_type(:enum_type3).symbols.length).to eq(4)
|
78
|
+
expect(TestEnum3.enum_type(:enum_type4).symbols.length).to eq(4)
|
79
79
|
end
|
80
|
+
|
80
81
|
it "constants can be used as function parameters and return value" do
|
81
|
-
TestEnum3.test_tagged_typedef_enum1(:c1).
|
82
|
-
TestEnum3.test_tagged_typedef_enum1(:c2).
|
83
|
-
TestEnum3.test_tagged_typedef_enum1(:c3).
|
84
|
-
TestEnum3.test_tagged_typedef_enum1(:c4).
|
85
|
-
TestEnum3.test_tagged_typedef_enum2(:c5).
|
86
|
-
TestEnum3.test_tagged_typedef_enum2(:c6).
|
87
|
-
TestEnum3.test_tagged_typedef_enum2(:c7).
|
88
|
-
TestEnum3.test_tagged_typedef_enum2(:c8).
|
89
|
-
TestEnum3.test_tagged_typedef_enum3(:c9).
|
90
|
-
TestEnum3.test_tagged_typedef_enum3(:c10).
|
91
|
-
TestEnum3.test_tagged_typedef_enum3(:c11).
|
92
|
-
TestEnum3.test_tagged_typedef_enum3(:c12).
|
93
|
-
TestEnum3.test_tagged_typedef_enum4(:c13).
|
94
|
-
TestEnum3.test_tagged_typedef_enum4(:c14).
|
95
|
-
TestEnum3.test_tagged_typedef_enum4(:c15).
|
96
|
-
TestEnum3.test_tagged_typedef_enum4(:c16).
|
82
|
+
expect(TestEnum3.test_tagged_typedef_enum1(:c1)).to be :c1
|
83
|
+
expect(TestEnum3.test_tagged_typedef_enum1(:c2)).to be :c2
|
84
|
+
expect(TestEnum3.test_tagged_typedef_enum1(:c3)).to be :c3
|
85
|
+
expect(TestEnum3.test_tagged_typedef_enum1(:c4)).to be :c4
|
86
|
+
expect(TestEnum3.test_tagged_typedef_enum2(:c5)).to be :c5
|
87
|
+
expect(TestEnum3.test_tagged_typedef_enum2(:c6)).to be :c6
|
88
|
+
expect(TestEnum3.test_tagged_typedef_enum2(:c7)).to be :c7
|
89
|
+
expect(TestEnum3.test_tagged_typedef_enum2(:c8)).to be :c8
|
90
|
+
expect(TestEnum3.test_tagged_typedef_enum3(:c9)).to be :c9
|
91
|
+
expect(TestEnum3.test_tagged_typedef_enum3(:c10)).to be :c10
|
92
|
+
expect(TestEnum3.test_tagged_typedef_enum3(:c11)).to be :c11
|
93
|
+
expect(TestEnum3.test_tagged_typedef_enum3(:c12)).to be :c12
|
94
|
+
expect(TestEnum3.test_tagged_typedef_enum4(:c13)).to be :c13
|
95
|
+
expect(TestEnum3.test_tagged_typedef_enum4(:c14)).to be :c14
|
96
|
+
expect(TestEnum3.test_tagged_typedef_enum4(:c15)).to be :c15
|
97
|
+
expect(TestEnum3.test_tagged_typedef_enum4(:c16)).to be :c16
|
97
98
|
end
|
98
99
|
|
99
100
|
it "integers can be used instead of constants" do
|
100
|
-
TestEnum3.test_tagged_typedef_enum1(0).
|
101
|
-
TestEnum3.test_tagged_typedef_enum1(1).
|
102
|
-
TestEnum3.test_tagged_typedef_enum1(2).
|
103
|
-
TestEnum3.test_tagged_typedef_enum1(3).
|
104
|
-
TestEnum3.test_tagged_typedef_enum2(42).
|
105
|
-
TestEnum3.test_tagged_typedef_enum2(43).
|
106
|
-
TestEnum3.test_tagged_typedef_enum2(44).
|
107
|
-
TestEnum3.test_tagged_typedef_enum2(45).
|
108
|
-
TestEnum3.test_tagged_typedef_enum3(42).
|
109
|
-
TestEnum3.test_tagged_typedef_enum3(43).
|
110
|
-
TestEnum3.test_tagged_typedef_enum3(4242).
|
111
|
-
TestEnum3.test_tagged_typedef_enum3(4243).
|
112
|
-
TestEnum3.test_tagged_typedef_enum4(42).
|
113
|
-
TestEnum3.test_tagged_typedef_enum4(4242).
|
114
|
-
TestEnum3.test_tagged_typedef_enum4(424242).
|
115
|
-
TestEnum3.test_tagged_typedef_enum4(42424242).
|
101
|
+
expect(TestEnum3.test_tagged_typedef_enum1(0)).to be :c1
|
102
|
+
expect(TestEnum3.test_tagged_typedef_enum1(1)).to be :c2
|
103
|
+
expect(TestEnum3.test_tagged_typedef_enum1(2)).to be :c3
|
104
|
+
expect(TestEnum3.test_tagged_typedef_enum1(3)).to be :c4
|
105
|
+
expect(TestEnum3.test_tagged_typedef_enum2(42)).to be :c5
|
106
|
+
expect(TestEnum3.test_tagged_typedef_enum2(43)).to be :c6
|
107
|
+
expect(TestEnum3.test_tagged_typedef_enum2(44)).to be :c7
|
108
|
+
expect(TestEnum3.test_tagged_typedef_enum2(45)).to be :c8
|
109
|
+
expect(TestEnum3.test_tagged_typedef_enum3(42)).to be :c9
|
110
|
+
expect(TestEnum3.test_tagged_typedef_enum3(43)).to be :c10
|
111
|
+
expect(TestEnum3.test_tagged_typedef_enum3(4242)).to be :c11
|
112
|
+
expect(TestEnum3.test_tagged_typedef_enum3(4243)).to be :c12
|
113
|
+
expect(TestEnum3.test_tagged_typedef_enum4(42)).to be :c13
|
114
|
+
expect(TestEnum3.test_tagged_typedef_enum4(4242)).to be :c14
|
115
|
+
expect(TestEnum3.test_tagged_typedef_enum4(424242)).to be :c15
|
116
|
+
expect(TestEnum3.test_tagged_typedef_enum4(42424242)).to be :c16
|
116
117
|
end
|
117
118
|
end
|
118
119
|
|
119
120
|
describe "All enums" do
|
120
121
|
it "have autonumbered constants when defined with names only" do
|
121
|
-
TestEnum1.enum_value(:c1).
|
122
|
-
TestEnum1.enum_value(:c2).
|
123
|
-
TestEnum1.enum_value(:c3).
|
124
|
-
TestEnum1.enum_value(:c4).
|
125
|
-
|
126
|
-
TestEnum3.enum_value(:c1).
|
127
|
-
TestEnum3.enum_value(:c2).
|
128
|
-
TestEnum3.enum_value(:c3).
|
129
|
-
TestEnum3.enum_value(:c4).
|
122
|
+
expect(TestEnum1.enum_value(:c1)).to eq(0)
|
123
|
+
expect(TestEnum1.enum_value(:c2)).to eq(1)
|
124
|
+
expect(TestEnum1.enum_value(:c3)).to eq(2)
|
125
|
+
expect(TestEnum1.enum_value(:c4)).to eq(3)
|
126
|
+
|
127
|
+
expect(TestEnum3.enum_value(:c1)).to eq(0)
|
128
|
+
expect(TestEnum3.enum_value(:c2)).to eq(1)
|
129
|
+
expect(TestEnum3.enum_value(:c3)).to eq(2)
|
130
|
+
expect(TestEnum3.enum_value(:c4)).to eq(3)
|
130
131
|
end
|
132
|
+
|
131
133
|
it "can have an explicit first constant and autonumbered subsequent constants" do
|
132
|
-
TestEnum1.enum_value(:c5).
|
133
|
-
TestEnum1.enum_value(:c6).
|
134
|
-
TestEnum1.enum_value(:c7).
|
135
|
-
TestEnum1.enum_value(:c8).
|
136
|
-
|
137
|
-
TestEnum3.enum_value(:c5).
|
138
|
-
TestEnum3.enum_value(:c6).
|
139
|
-
TestEnum3.enum_value(:c7).
|
140
|
-
TestEnum3.enum_value(:c8).
|
134
|
+
expect(TestEnum1.enum_value(:c5)).to eq(42)
|
135
|
+
expect(TestEnum1.enum_value(:c6)).to eq(43)
|
136
|
+
expect(TestEnum1.enum_value(:c7)).to eq(44)
|
137
|
+
expect(TestEnum1.enum_value(:c8)).to eq(45)
|
138
|
+
|
139
|
+
expect(TestEnum3.enum_value(:c5)).to eq(42)
|
140
|
+
expect(TestEnum3.enum_value(:c6)).to eq(43)
|
141
|
+
expect(TestEnum3.enum_value(:c7)).to eq(44)
|
142
|
+
expect(TestEnum3.enum_value(:c8)).to eq(45)
|
141
143
|
end
|
144
|
+
|
142
145
|
it "can have a mix of explicit and autonumbered constants" do
|
143
|
-
TestEnum1.enum_value(:c9).
|
144
|
-
TestEnum1.enum_value(:c10).
|
145
|
-
TestEnum1.enum_value(:c11).
|
146
|
-
TestEnum1.enum_value(:c12).
|
147
|
-
|
148
|
-
TestEnum3.enum_value(:c9).
|
149
|
-
TestEnum3.enum_value(:c10).
|
150
|
-
TestEnum3.enum_value(:c11).
|
151
|
-
TestEnum3.enum_value(:c12).
|
146
|
+
expect(TestEnum1.enum_value(:c9)).to eq(42)
|
147
|
+
expect(TestEnum1.enum_value(:c10)).to eq(43)
|
148
|
+
expect(TestEnum1.enum_value(:c11)).to eq(4242)
|
149
|
+
expect(TestEnum1.enum_value(:c12)).to eq(4243)
|
150
|
+
|
151
|
+
expect(TestEnum3.enum_value(:c9)).to eq(42)
|
152
|
+
expect(TestEnum3.enum_value(:c10)).to eq(43)
|
153
|
+
expect(TestEnum3.enum_value(:c11)).to eq(4242)
|
154
|
+
expect(TestEnum3.enum_value(:c12)).to eq(4243)
|
152
155
|
end
|
156
|
+
|
153
157
|
it "can have all its constants explicitely valued" do
|
154
|
-
TestEnum1.enum_value(:c13).
|
155
|
-
TestEnum1.enum_value(:c14).
|
156
|
-
TestEnum1.enum_value(:c15).
|
157
|
-
TestEnum1.enum_value(:c16).
|
158
|
+
expect(TestEnum1.enum_value(:c13)).to eq(42)
|
159
|
+
expect(TestEnum1.enum_value(:c14)).to eq(4242)
|
160
|
+
expect(TestEnum1.enum_value(:c15)).to eq(424242)
|
161
|
+
expect(TestEnum1.enum_value(:c16)).to eq(42424242)
|
158
162
|
|
159
|
-
TestEnum3.enum_value(:c13).
|
160
|
-
TestEnum3.enum_value(:c14).
|
161
|
-
TestEnum3.enum_value(:c15).
|
162
|
-
TestEnum3.enum_value(:c16).
|
163
|
+
expect(TestEnum3.enum_value(:c13)).to eq(42)
|
164
|
+
expect(TestEnum3.enum_value(:c14)).to eq(4242)
|
165
|
+
expect(TestEnum3.enum_value(:c15)).to eq(424242)
|
166
|
+
expect(TestEnum3.enum_value(:c16)).to eq(42424242)
|
163
167
|
end
|
168
|
+
|
164
169
|
it "return the constant corresponding to a specific value" do
|
165
170
|
enum = TestEnum3.enum_type(:enum_type1)
|
166
|
-
enum[0].
|
167
|
-
enum[1].
|
168
|
-
enum[2].
|
169
|
-
enum[3].
|
171
|
+
expect(enum[0]).to be :c1
|
172
|
+
expect(enum[1]).to be :c2
|
173
|
+
expect(enum[2]).to be :c3
|
174
|
+
expect(enum[3]).to be :c4
|
170
175
|
|
171
176
|
enum = TestEnum3.enum_type(:enum_type2)
|
172
|
-
enum[42].
|
173
|
-
enum[43].
|
174
|
-
enum[44].
|
175
|
-
enum[45].
|
177
|
+
expect(enum[42]).to be :c5
|
178
|
+
expect(enum[43]).to be :c6
|
179
|
+
expect(enum[44]).to be :c7
|
180
|
+
expect(enum[45]).to be :c8
|
176
181
|
|
177
182
|
enum = TestEnum3.enum_type(:enum_type3)
|
178
|
-
enum[42].
|
179
|
-
enum[43].
|
180
|
-
enum[4242].
|
181
|
-
enum[4243].
|
183
|
+
expect(enum[42]).to be :c9
|
184
|
+
expect(enum[43]).to be :c10
|
185
|
+
expect(enum[4242]).to be :c11
|
186
|
+
expect(enum[4243]).to be :c12
|
182
187
|
|
183
188
|
enum = TestEnum3.enum_type(:enum_type4)
|
184
|
-
enum[42].
|
185
|
-
enum[4242].
|
186
|
-
enum[424242].
|
187
|
-
enum[42424242].
|
189
|
+
expect(enum[42]).to be :c13
|
190
|
+
expect(enum[4242]).to be :c14
|
191
|
+
expect(enum[424242]).to be :c15
|
192
|
+
expect(enum[42424242]).to be :c16
|
188
193
|
end
|
194
|
+
|
189
195
|
it "return nil for values that don't have a symbol" do
|
190
196
|
enum = TestEnum3.enum_type(:enum_type1)
|
191
|
-
enum[-1].
|
192
|
-
enum[4].
|
197
|
+
expect(enum[-1]).to be_nil
|
198
|
+
expect(enum[4]).to be_nil
|
193
199
|
|
194
200
|
enum = TestEnum3.enum_type(:enum_type2)
|
195
|
-
enum[0].
|
196
|
-
enum[41].
|
197
|
-
enum[46].
|
201
|
+
expect(enum[0]).to be_nil
|
202
|
+
expect(enum[41]).to be_nil
|
203
|
+
expect(enum[46]).to be_nil
|
198
204
|
|
199
205
|
enum = TestEnum3.enum_type(:enum_type3)
|
200
|
-
enum[0].
|
201
|
-
enum[41].
|
202
|
-
enum[44].
|
203
|
-
enum[4241].
|
204
|
-
enum[4244].
|
206
|
+
expect(enum[0]).to be_nil
|
207
|
+
expect(enum[41]).to be_nil
|
208
|
+
expect(enum[44]).to be_nil
|
209
|
+
expect(enum[4241]).to be_nil
|
210
|
+
expect(enum[4244]).to be_nil
|
205
211
|
|
206
212
|
enum = TestEnum3.enum_type(:enum_type4)
|
207
|
-
enum[0].
|
208
|
-
enum[41].
|
209
|
-
enum[43].
|
210
|
-
enum[4241].
|
211
|
-
enum[4243].
|
212
|
-
enum[424241].
|
213
|
-
enum[424243].
|
214
|
-
enum[42424241].
|
215
|
-
enum[42424243].
|
213
|
+
expect(enum[0]).to be_nil
|
214
|
+
expect(enum[41]).to be_nil
|
215
|
+
expect(enum[43]).to be_nil
|
216
|
+
expect(enum[4241]).to be_nil
|
217
|
+
expect(enum[4243]).to be_nil
|
218
|
+
expect(enum[424241]).to be_nil
|
219
|
+
expect(enum[424243]).to be_nil
|
220
|
+
expect(enum[42424241]).to be_nil
|
221
|
+
expect(enum[42424243]).to be_nil
|
216
222
|
end
|
217
223
|
|
218
224
|
it "duplicate enum keys rejected" do
|
219
|
-
|
225
|
+
expect { enum [ :a, 0xfee1dead, :b, 0xdeadbeef, :a, 0 ] }.to raise_error
|
220
226
|
end
|
221
227
|
end
|
data/spec/ffi/errno_spec.rb
CHANGED
@@ -4,7 +4,6 @@
|
|
4
4
|
#
|
5
5
|
|
6
6
|
require File.expand_path(File.join(File.dirname(__FILE__), "spec_helper"))
|
7
|
-
require 'ffi'
|
8
7
|
|
9
8
|
describe "FFI.errno" do
|
10
9
|
module LibTest
|
@@ -12,9 +11,10 @@ describe "FFI.errno" do
|
|
12
11
|
ffi_lib TestLibrary::PATH
|
13
12
|
attach_function :setLastError, [ :int ], :void
|
14
13
|
end
|
14
|
+
|
15
15
|
it "FFI.errno contains errno from last function" do
|
16
16
|
LibTest.setLastError(0)
|
17
17
|
LibTest.setLastError(0x12345678)
|
18
|
-
FFI.errno.
|
18
|
+
expect(FFI.errno).to eq(0x12345678)
|
19
19
|
end
|
20
20
|
end
|