stark 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +10 -0
- data/History.txt +19 -0
- data/Manifest.txt +17 -3
- data/README.md +164 -0
- data/Rakefile +4 -1
- data/bin/stark +11 -3
- data/examples/README.md +114 -0
- data/examples/client.rb +13 -0
- data/examples/health.thrift +9 -0
- data/examples/server.rb +18 -0
- data/lib/stark.rb +16 -2
- data/lib/stark/ast.rb +5 -0
- data/lib/stark/client.rb +3 -67
- data/lib/stark/exception.rb +9 -9
- data/lib/stark/processor.rb +13 -52
- data/lib/stark/protocol_helpers.rb +161 -0
- data/lib/stark/raw_parser.rb +75 -14
- data/lib/stark/ruby.rb +267 -248
- data/lib/stark/struct.rb +37 -26
- data/lib/stark/thrift.kpeg +6 -4
- data/stark.gemspec +15 -15
- data/test/ThriftSpec.thrift +4 -0
- data/test/comments.thrift +15 -0
- data/test/leg.rb +0 -2
- data/test/parsing_error.thrift +5 -0
- data/test/properties.thrift +9 -0
- data/test/test_client.rb +116 -241
- data/test/test_coerce_strings.rb +187 -0
- data/test/test_helper.rb +113 -0
- data/test/test_marshal.rb +131 -0
- data/test/test_parser.rb +61 -0
- data/test/test_ruby.rb +148 -9
- data/test/test_server.rb +96 -212
- data/test/test_stark.rb +67 -0
- data/test/types.thrift +49 -0
- data/test/users.thrift +16 -0
- metadata +33 -15
- data/README.txt +0 -67
- data/lib/stark/converters.rb +0 -188
- data/lib/stark/field.rb +0 -27
data/lib/stark/struct.rb
CHANGED
|
@@ -1,42 +1,53 @@
|
|
|
1
1
|
module Stark
|
|
2
2
|
class Struct
|
|
3
3
|
def initialize(fields={})
|
|
4
|
-
|
|
4
|
+
fields.each do |k,v|
|
|
5
|
+
send(:"#{k}=", v) if respond_to?(:"#{k}=")
|
|
6
|
+
end
|
|
5
7
|
end
|
|
6
8
|
|
|
7
|
-
def
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
def [](*args)
|
|
10
|
+
values = []
|
|
11
|
+
args.each do |a|
|
|
12
|
+
case a
|
|
13
|
+
when Fixnum
|
|
14
|
+
n = self.class.fields[a]
|
|
15
|
+
values << (n ? send(n) : nil)
|
|
16
|
+
when Range
|
|
17
|
+
values += self[*a.to_a]
|
|
18
|
+
when String, Symbol
|
|
19
|
+
values << send(a)
|
|
20
|
+
end
|
|
15
21
|
end
|
|
22
|
+
values = values.first if values.size == 1
|
|
23
|
+
values
|
|
16
24
|
end
|
|
17
25
|
|
|
18
|
-
def
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
set_from_index ftype, fid, ip
|
|
26
|
-
|
|
27
|
-
ip.read_field_end
|
|
26
|
+
def to_hash
|
|
27
|
+
{}.tap do |hash|
|
|
28
|
+
self.class.fields.each do |idx,name|
|
|
29
|
+
v = send name
|
|
30
|
+
hash[name] = v if v
|
|
31
|
+
end
|
|
28
32
|
end
|
|
33
|
+
end
|
|
29
34
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
self
|
|
35
|
+
def self.fields
|
|
36
|
+
@fields ||= {}
|
|
33
37
|
end
|
|
34
38
|
|
|
35
|
-
def
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
def self.attr_accessor(*attrs)
|
|
40
|
+
attrs.each do |a|
|
|
41
|
+
n = field_number
|
|
42
|
+
fields[n] = a
|
|
43
|
+
self.field_number n + 1
|
|
39
44
|
end
|
|
45
|
+
super
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def self.field_number(n = nil)
|
|
49
|
+
@field_number = n if n
|
|
50
|
+
@field_number ||= 1
|
|
40
51
|
end
|
|
41
52
|
end
|
|
42
53
|
end
|
data/lib/stark/thrift.kpeg
CHANGED
|
@@ -122,7 +122,7 @@ reserved =
|
|
|
122
122
|
"synchronized" |
|
|
123
123
|
"then" |
|
|
124
124
|
"this" |
|
|
125
|
-
"
|
|
125
|
+
"throws" |
|
|
126
126
|
"transient" |
|
|
127
127
|
"try" |
|
|
128
128
|
"undef" |
|
|
@@ -172,11 +172,13 @@ root = Program !.
|
|
|
172
172
|
|
|
173
173
|
Program = Element*:a { a }
|
|
174
174
|
|
|
175
|
-
|
|
175
|
+
CMLComment = "/*" < (!"*/" .)* > "*/" obsp ~comment(text)
|
|
176
|
+
|
|
177
|
+
CSLComment = "//" < (!"\n" .)* > bsp ~comment(text)
|
|
176
178
|
|
|
177
179
|
HComment = "#" < (!"\n" .)* > bsp ~comment(text)
|
|
178
180
|
|
|
179
|
-
Comment =
|
|
181
|
+
Comment = CMLComment | CSLComment | HComment
|
|
180
182
|
|
|
181
183
|
CaptureDocText = {}
|
|
182
184
|
DestroyDocText = {}
|
|
@@ -277,7 +279,7 @@ Function = CaptureDocText OneWay?:o FunctionType:rt - tok_identifier:name
|
|
|
277
279
|
|
|
278
280
|
OneWay = ("oneway" | "async") - { :oneway }
|
|
279
281
|
|
|
280
|
-
Throws =
|
|
282
|
+
Throws = osp "throws" osp "(" FieldList ")"
|
|
281
283
|
|
|
282
284
|
FieldList = FieldList:l Field:f { l + [f] }
|
|
283
285
|
| Field:f { [f] }
|
data/stark.gemspec
CHANGED
|
@@ -2,39 +2,39 @@
|
|
|
2
2
|
|
|
3
3
|
Gem::Specification.new do |s|
|
|
4
4
|
s.name = "stark"
|
|
5
|
-
s.version = "0.
|
|
5
|
+
s.version = "0.8.0"
|
|
6
6
|
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
8
8
|
s.authors = ["Evan Phoenix"]
|
|
9
|
-
s.date = "2013-
|
|
10
|
-
s.description = "Optimized thrift bindings for ruby"
|
|
9
|
+
s.date = "2013-05-22"
|
|
10
|
+
s.description = "Optimized thrift bindings for ruby."
|
|
11
11
|
s.email = ["evan@phx.io"]
|
|
12
12
|
s.executables = ["stark"]
|
|
13
|
-
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.
|
|
14
|
-
s.files = [".autotest", "History.txt", "Manifest.txt", "README.
|
|
13
|
+
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.md", "examples/README.md"]
|
|
14
|
+
s.files = [".autotest", ".gemtest", ".travis.yml", "History.txt", "Manifest.txt", "README.md", "Rakefile", "bin/stark", "examples/README.md", "examples/client.rb", "examples/health.thrift", "examples/server.rb", "lib/stark.rb", "lib/stark/ast.rb", "lib/stark/client.rb", "lib/stark/exception.rb", "lib/stark/log_transport.rb", "lib/stark/parser.rb", "lib/stark/processor.rb", "lib/stark/protocol_helpers.rb", "lib/stark/raw_parser.rb", "lib/stark/ruby.rb", "lib/stark/struct.rb", "lib/stark/thrift.kpeg", "stark.gemspec", "test/ThriftSpec.thrift", "test/blah.thrift", "test/comments.thrift", "test/gen-rb/profile_constants.rb", "test/gen-rb/profile_types.rb", "test/gen-rb/user_storage.rb", "test/include_blah.thrift", "test/leg.rb", "test/legacy_profile/profile_constants.rb", "test/legacy_profile/profile_types.rb", "test/legacy_profile/user_storage.rb", "test/parsing_error.thrift", "test/profile.thrift", "test/properties.thrift", "test/test_client.rb", "test/test_coerce_strings.rb", "test/test_helper.rb", "test/test_marshal.rb", "test/test_parser.rb", "test/test_ruby.rb", "test/test_server.rb", "test/test_stark.rb", "test/types.thrift", "test/users.thrift"]
|
|
15
15
|
s.homepage = "http://github.com/evanphx/stark"
|
|
16
|
-
s.rdoc_options = ["--main", "README.
|
|
16
|
+
s.rdoc_options = ["--main", "README.md"]
|
|
17
17
|
s.require_paths = ["lib"]
|
|
18
18
|
s.rubyforge_project = "stark"
|
|
19
|
-
s.rubygems_version = "1.8.
|
|
20
|
-
s.summary = "Optimized thrift bindings for ruby"
|
|
21
|
-
s.test_files = ["test/test_client.rb", "test/test_parser.rb", "test/test_server.rb"]
|
|
19
|
+
s.rubygems_version = "1.8.23"
|
|
20
|
+
s.summary = "Optimized thrift bindings for ruby."
|
|
21
|
+
s.test_files = ["test/test_client.rb", "test/test_coerce_strings.rb", "test/test_helper.rb", "test/test_marshal.rb", "test/test_parser.rb", "test/test_ruby.rb", "test/test_server.rb", "test/test_stark.rb"]
|
|
22
22
|
|
|
23
23
|
if s.respond_to? :specification_version then
|
|
24
24
|
s.specification_version = 3
|
|
25
25
|
|
|
26
26
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
|
27
27
|
s.add_runtime_dependency(%q<thrift>, ["~> 0.9.0"])
|
|
28
|
-
s.add_development_dependency(%q<rdoc>, ["~>
|
|
29
|
-
s.add_development_dependency(%q<hoe>, ["~> 3.
|
|
28
|
+
s.add_development_dependency(%q<rdoc>, ["~> 4.0"])
|
|
29
|
+
s.add_development_dependency(%q<hoe>, ["~> 3.6"])
|
|
30
30
|
else
|
|
31
31
|
s.add_dependency(%q<thrift>, ["~> 0.9.0"])
|
|
32
|
-
s.add_dependency(%q<rdoc>, ["~>
|
|
33
|
-
s.add_dependency(%q<hoe>, ["~> 3.
|
|
32
|
+
s.add_dependency(%q<rdoc>, ["~> 4.0"])
|
|
33
|
+
s.add_dependency(%q<hoe>, ["~> 3.6"])
|
|
34
34
|
end
|
|
35
35
|
else
|
|
36
36
|
s.add_dependency(%q<thrift>, ["~> 0.9.0"])
|
|
37
|
-
s.add_dependency(%q<rdoc>, ["~>
|
|
38
|
-
s.add_dependency(%q<hoe>, ["~> 3.
|
|
37
|
+
s.add_dependency(%q<rdoc>, ["~> 4.0"])
|
|
38
|
+
s.add_dependency(%q<hoe>, ["~> 3.6"])
|
|
39
39
|
end
|
|
40
40
|
end
|
data/test/ThriftSpec.thrift
CHANGED
data/test/leg.rb
CHANGED
data/test/test_client.rb
CHANGED
|
@@ -9,361 +9,236 @@ $: << "test/legacy_profile"
|
|
|
9
9
|
|
|
10
10
|
require 'user_storage'
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
def setup
|
|
14
|
-
@client_t, @server_t = Stark.pipe_transport
|
|
15
|
-
@client_p = Thrift::BinaryProtocol.new @client_t
|
|
16
|
-
@server_p = Thrift::BinaryProtocol.new @server_t
|
|
17
|
-
|
|
18
|
-
@n = Module.new
|
|
19
|
-
Stark.materialize "test/profile.thrift", @n
|
|
12
|
+
require 'test/test_helper'
|
|
20
13
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
14
|
+
class TestClient < Test::Unit::TestCase
|
|
15
|
+
IDL = "test/profile.thrift"
|
|
16
|
+
SERVICE = "UserStorage"
|
|
17
|
+
include TestHelper
|
|
25
18
|
|
|
26
|
-
def
|
|
27
|
-
|
|
28
|
-
@server_t.close
|
|
19
|
+
def setup
|
|
20
|
+
setup_client
|
|
29
21
|
end
|
|
30
22
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
@last_map = nil
|
|
35
|
-
@last_list = nil
|
|
36
|
-
@last_status = nil
|
|
37
|
-
@n = n
|
|
38
|
-
@user_status = nil
|
|
39
|
-
@user_relationship = nil
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
attr_accessor :last_map, :last_list, :last_status, :user_status
|
|
43
|
-
|
|
44
|
-
def store(obj)
|
|
45
|
-
@users[obj.uid] = obj
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def retrieve(id)
|
|
49
|
-
@users[id]
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def set_map(m)
|
|
53
|
-
@last_map = m
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
def set_list(l)
|
|
57
|
-
@last_list = l
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def set_status(s)
|
|
61
|
-
@last_status = s
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
def volume_up
|
|
65
|
-
raise RockTooHard.new(:volume => 11)
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
def make_bitcoins
|
|
69
|
-
sleep 2
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
def add(a,b)
|
|
73
|
-
a + b
|
|
74
|
-
end
|
|
23
|
+
def test_store_and_retrieve
|
|
24
|
+
send_to_server do
|
|
25
|
+
xuser = @n::UserProfile.new 'uid' => 0, 'name' => 'root', 'blurb' => 'god'
|
|
75
26
|
|
|
76
|
-
|
|
77
|
-
@user_status = s
|
|
27
|
+
@client.store xuser
|
|
78
28
|
end
|
|
79
29
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
@user_relationship = rel
|
|
30
|
+
obj = send_to_server do
|
|
31
|
+
@client.retrieve 0
|
|
83
32
|
end
|
|
84
33
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
end
|
|
34
|
+
assert_equal 0, obj.uid
|
|
35
|
+
assert_equal "root", obj.name
|
|
36
|
+
assert_equal "god", obj.blurb
|
|
89
37
|
end
|
|
90
38
|
|
|
91
|
-
def
|
|
92
|
-
|
|
93
|
-
@
|
|
39
|
+
def test_store_and_retrieve_with_some_missing_values
|
|
40
|
+
send_to_server do
|
|
41
|
+
xuser = @n::UserProfile.new 'uid' => 0, 'name' => 'root'
|
|
42
|
+
@client.store xuser
|
|
94
43
|
end
|
|
95
44
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
@client.store xuser
|
|
99
|
-
|
|
100
|
-
st.join
|
|
101
|
-
|
|
102
|
-
st = Thread.new do
|
|
103
|
-
@server.process @server_p, @server_p
|
|
45
|
+
obj = send_to_server do
|
|
46
|
+
@client.retrieve 0
|
|
104
47
|
end
|
|
105
48
|
|
|
106
|
-
obj = @client.retrieve 0
|
|
107
|
-
|
|
108
|
-
st.join
|
|
109
|
-
|
|
110
49
|
assert_equal 0, obj.uid
|
|
111
50
|
assert_equal "root", obj.name
|
|
112
|
-
|
|
51
|
+
assert obj.blurb.nil?
|
|
113
52
|
end
|
|
114
53
|
|
|
115
54
|
def test_set_map
|
|
116
|
-
|
|
117
|
-
@server.process @server_p, @server_p
|
|
118
|
-
end
|
|
55
|
+
send_to_server do
|
|
119
56
|
|
|
120
|
-
|
|
57
|
+
m = { "blah" => "foo", "a" => "b" }
|
|
121
58
|
|
|
122
|
-
|
|
59
|
+
@client.set_map m
|
|
123
60
|
|
|
124
|
-
|
|
61
|
+
end
|
|
125
62
|
|
|
126
63
|
assert_equal "foo", @handler.last_map["blah"]
|
|
127
64
|
assert_equal "b", @handler.last_map["a"]
|
|
128
65
|
end
|
|
129
66
|
|
|
130
67
|
def test_last_map
|
|
131
|
-
|
|
132
|
-
@
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
@handler.last_map = { "blah" => "foo", "a" => "b" }
|
|
68
|
+
m = send_to_server do
|
|
69
|
+
@handler.last_map = { "blah" => "foo", "a" => "b" }
|
|
136
70
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
st.join
|
|
71
|
+
@client.last_map
|
|
72
|
+
end
|
|
140
73
|
|
|
141
74
|
assert_equal "foo", m["blah"]
|
|
142
75
|
assert_equal "b", m["a"]
|
|
143
76
|
end
|
|
144
77
|
|
|
145
78
|
def test_set_list
|
|
146
|
-
st = Thread.new do
|
|
147
|
-
@server.process @server_p, @server_p
|
|
148
|
-
end
|
|
149
|
-
|
|
150
79
|
m = [ "blah", "foo", "a", "b" ]
|
|
151
80
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
81
|
+
send_to_server do
|
|
82
|
+
@client.set_list m
|
|
83
|
+
end
|
|
155
84
|
|
|
156
85
|
assert_equal m, @handler.last_list
|
|
157
86
|
end
|
|
158
87
|
|
|
159
88
|
def test_last_list
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
l = [ "blah", "foo", "a", "b" ]
|
|
165
|
-
@handler.last_list = l
|
|
89
|
+
send_to_server do
|
|
90
|
+
l = [ "blah", "foo", "a", "b" ]
|
|
91
|
+
@handler.last_list = l
|
|
166
92
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
93
|
+
begin
|
|
94
|
+
assert_equal l, @client.last_list
|
|
95
|
+
rescue Interrupt => e
|
|
96
|
+
puts e.backtrace
|
|
97
|
+
end
|
|
171
98
|
end
|
|
172
|
-
|
|
173
|
-
st.join
|
|
174
99
|
end
|
|
175
100
|
|
|
176
101
|
def test_last_list_is_nil
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
rescue Interrupt => e
|
|
184
|
-
puts e.backtrace
|
|
102
|
+
send_to_server do
|
|
103
|
+
begin
|
|
104
|
+
assert_equal nil, @client.last_list
|
|
105
|
+
rescue Interrupt => e
|
|
106
|
+
puts e.backtrace
|
|
107
|
+
end
|
|
185
108
|
end
|
|
186
|
-
|
|
187
|
-
st.join
|
|
188
109
|
end
|
|
189
110
|
|
|
190
111
|
def test_enum
|
|
191
|
-
|
|
192
|
-
@
|
|
112
|
+
send_to_server do
|
|
113
|
+
@client.set_status :ON
|
|
193
114
|
end
|
|
194
115
|
|
|
195
|
-
@client.set_status :ON
|
|
196
|
-
|
|
197
|
-
st.join
|
|
198
|
-
|
|
199
116
|
assert_equal 0, @handler.last_status
|
|
200
117
|
end
|
|
201
118
|
|
|
202
119
|
def test_enum_recv
|
|
203
|
-
|
|
204
|
-
@
|
|
205
|
-
end
|
|
206
|
-
|
|
207
|
-
@handler.last_status = 0
|
|
120
|
+
send_to_server do
|
|
121
|
+
@handler.last_status = 0
|
|
208
122
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
st.join
|
|
123
|
+
assert_equal :ON, @client.last_status
|
|
124
|
+
end
|
|
212
125
|
end
|
|
213
126
|
|
|
214
127
|
def test_throw
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
e = assert_raises @n::RockTooHard do
|
|
220
|
-
@client.volume_up
|
|
128
|
+
e = send_to_server do
|
|
129
|
+
assert_raises @n::RockTooHard do
|
|
130
|
+
@client.volume_up
|
|
131
|
+
end
|
|
221
132
|
end
|
|
222
133
|
|
|
223
|
-
st.join
|
|
224
|
-
|
|
225
134
|
assert_equal 11, e.volume
|
|
226
135
|
end
|
|
227
136
|
|
|
228
|
-
# Thread.abort_on_exception = true
|
|
229
|
-
|
|
230
137
|
def test_oneway
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
end
|
|
138
|
+
send_to_server do
|
|
139
|
+
t = Time.now
|
|
234
140
|
|
|
235
|
-
|
|
141
|
+
Timeout.timeout 3 do
|
|
142
|
+
assert_equal nil, @client.make_bitcoins
|
|
143
|
+
end
|
|
236
144
|
|
|
237
|
-
|
|
238
|
-
assert_equal nil, @client.make_bitcoins
|
|
145
|
+
assert Time.now - t < 0.1
|
|
239
146
|
end
|
|
240
|
-
|
|
241
|
-
assert Time.now - t < 0.1
|
|
242
|
-
|
|
243
|
-
st.join
|
|
244
147
|
end
|
|
245
148
|
|
|
246
149
|
def test_2args
|
|
247
|
-
|
|
248
|
-
@
|
|
150
|
+
send_to_server do
|
|
151
|
+
assert_equal 7, @client.add(3, 4)
|
|
249
152
|
end
|
|
250
|
-
|
|
251
|
-
assert_equal 7, @client.add(3, 4)
|
|
252
|
-
|
|
253
|
-
st.join
|
|
254
153
|
end
|
|
255
154
|
|
|
256
155
|
def test_read_struct_in_a_struct
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
prof = UserProfile.new 'uid' => 0, 'name' => 'root', 'blurb' => 'god'
|
|
262
|
-
stat = UserStatus.new 'profile' => prof, 'active' => true
|
|
156
|
+
send_to_server do
|
|
157
|
+
prof = UserProfile.new 'uid' => 0, 'name' => 'root', 'blurb' => 'god'
|
|
158
|
+
stat = UserStatus.new 'profile' => prof, 'active' => true
|
|
263
159
|
|
|
264
|
-
|
|
160
|
+
@handler.user_status = stat
|
|
265
161
|
|
|
266
|
-
|
|
162
|
+
status = @client.user_status
|
|
267
163
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
prof = status.profile
|
|
164
|
+
assert_equal true, status.active
|
|
271
165
|
|
|
272
|
-
|
|
273
|
-
assert_equal "root", prof.name
|
|
274
|
-
assert_equal "god", prof.blurb
|
|
166
|
+
prof = status.profile
|
|
275
167
|
|
|
276
|
-
|
|
168
|
+
assert_equal 0, prof.uid
|
|
169
|
+
assert_equal "root", prof.name
|
|
170
|
+
assert_equal "god", prof.blurb
|
|
171
|
+
end
|
|
277
172
|
end
|
|
278
173
|
|
|
279
174
|
def test_write_struct_in_a_struct
|
|
280
|
-
|
|
281
|
-
@
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
prof = @n::UserProfile.new 'uid' => 0, 'name' => 'root', 'blurb' => 'god'
|
|
285
|
-
stat = @n::UserStatus.new 'profile' => prof, 'active' => true
|
|
175
|
+
send_to_server do
|
|
176
|
+
prof = @n::UserProfile.new 'uid' => 0, 'name' => 'root', 'blurb' => 'god'
|
|
177
|
+
stat = @n::UserStatus.new 'profile' => prof, 'active' => true
|
|
286
178
|
|
|
287
|
-
|
|
179
|
+
@client.set_user_status stat
|
|
288
180
|
|
|
289
|
-
|
|
181
|
+
status = @handler.user_status
|
|
290
182
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
prof = status.profile
|
|
183
|
+
assert_equal true, status.active
|
|
294
184
|
|
|
295
|
-
|
|
296
|
-
assert_equal "root", prof.name
|
|
297
|
-
assert_equal "god", prof.blurb
|
|
185
|
+
prof = status.profile
|
|
298
186
|
|
|
299
|
-
|
|
187
|
+
assert_equal 0, prof.uid
|
|
188
|
+
assert_equal "root", prof.name
|
|
189
|
+
assert_equal "god", prof.blurb
|
|
190
|
+
end
|
|
300
191
|
end
|
|
301
192
|
|
|
302
193
|
def test_read_enum_in_struct
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
end
|
|
306
|
-
|
|
307
|
-
stat = UserRelationship.new 'user' => 0, 'status' => 4
|
|
308
|
-
|
|
309
|
-
@handler.user_relationship = stat
|
|
194
|
+
send_to_server do
|
|
195
|
+
stat = UserRelationship.new 'user' => 0, 'status' => 4
|
|
310
196
|
|
|
311
|
-
|
|
197
|
+
@handler.user_relationship = stat
|
|
312
198
|
|
|
313
|
-
|
|
314
|
-
assert_equal :ITS_COMPLICATED, rel.status
|
|
199
|
+
rel = @client.user_relationship
|
|
315
200
|
|
|
316
|
-
|
|
201
|
+
assert_equal 0, rel.user
|
|
202
|
+
assert_equal :ITS_COMPLICATED, rel.status
|
|
203
|
+
end
|
|
317
204
|
end
|
|
318
205
|
|
|
319
206
|
def test_write_enum_in_struct
|
|
320
|
-
|
|
321
|
-
@
|
|
322
|
-
end
|
|
207
|
+
send_to_server do
|
|
208
|
+
stat = @n::UserRelationship.new 'user' => 0, 'status' => :ITS_COMPLICATED
|
|
323
209
|
|
|
324
|
-
|
|
210
|
+
@client.set_user_relationship stat
|
|
325
211
|
|
|
326
|
-
|
|
212
|
+
rel = @handler.user_relationship
|
|
327
213
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
assert_equal 4, rel.status
|
|
332
|
-
|
|
333
|
-
st.join
|
|
214
|
+
assert_equal 0, rel.user
|
|
215
|
+
assert_equal 4, rel.status
|
|
216
|
+
end
|
|
334
217
|
end
|
|
335
218
|
|
|
336
219
|
def test_read_list_in_struct
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
end
|
|
340
|
-
|
|
341
|
-
stat = UserFriends.new 'user' => 0, 'friends' => [4,8,47]
|
|
342
|
-
|
|
343
|
-
@handler.user_friends = stat
|
|
220
|
+
send_to_server do
|
|
221
|
+
stat = UserFriends.new 'user' => 0, 'friends' => [4,8,47]
|
|
344
222
|
|
|
345
|
-
|
|
223
|
+
@handler.user_friends = stat
|
|
346
224
|
|
|
347
|
-
|
|
348
|
-
assert_equal [4,8,47], rel.friends
|
|
225
|
+
rel = @client.user_friends
|
|
349
226
|
|
|
350
|
-
|
|
227
|
+
assert_equal 0, rel.user
|
|
228
|
+
assert_equal [4,8,47], rel.friends
|
|
229
|
+
end
|
|
351
230
|
end
|
|
352
231
|
|
|
353
232
|
def test_write_list_in_struct
|
|
354
|
-
|
|
355
|
-
@
|
|
356
|
-
end
|
|
357
|
-
|
|
358
|
-
stat = @n::UserFriends.new 'user' => 0, 'friends' => [4,8,47]
|
|
233
|
+
send_to_server do
|
|
234
|
+
stat = @n::UserFriends.new 'user' => 0, 'friends' => [4,8,47]
|
|
359
235
|
|
|
360
|
-
|
|
236
|
+
@client.set_user_friends stat
|
|
361
237
|
|
|
362
|
-
|
|
238
|
+
rel = @handler.user_friends
|
|
363
239
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
st.join
|
|
240
|
+
assert_equal 0, rel.user
|
|
241
|
+
assert_equal [4,8,47], rel.friends
|
|
242
|
+
end
|
|
368
243
|
end
|
|
369
244
|
end
|