tla-trace-filter 0.0.3

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.
@@ -0,0 +1,102 @@
1
+ (export TLATOOLS=~/java/tla/tla2tools.jar; cd ~/work/tla-sbuilder; cd tmp/aruba; cd gen/example/tla/; java -cp $TLATOOLS pcal.trans model; java -cp $TLATOOLS tlc2.TLC setup -dump state | tee err.dump )
2
+ pcal.trans Version 1.8 of 2 Apr 2013
3
+ Parsing completed.
4
+ Warning: symbols were renamed.
5
+ Translation completed.
6
+ New file model.tla written.
7
+ New file model.cfg written.
8
+ TLC2 Version 2.07 of 1 June 2015
9
+ Running in Model-Checking mode.
10
+ Parsing file setup.tla
11
+ Parsing file model.tla
12
+ Parsing file /tmp/TLC.tla
13
+ Parsing file /tmp/FiniteSets.tla
14
+ Parsing file /tmp/Sequences.tla
15
+ Parsing file /tmp/Integers.tla
16
+ Parsing file /tmp/Naturals.tla
17
+ Semantic processing of module Naturals
18
+ Semantic processing of module Sequences
19
+ Semantic processing of module TLC
20
+ Semantic processing of module FiniteSets
21
+ Semantic processing of module Integers
22
+ Semantic processing of module model
23
+ Semantic processing of module setup
24
+ Starting... (2017-10-02 10:29:22)
25
+ Computing initial states...
26
+ Finished computing initial states: 1 distinct state generated.
27
+ <<"Default process p__customer_post_ for operation '/customer(post)',tick=", 0>>
28
+ <<"/customer(post) called!!!">>
29
+ <<"Default process p__customer_post_ for operation '/customer(post)',tick=", 0>>
30
+ <<"/customer(post) called!!!">>
31
+ <<"Default process p__customer_post_ for operation '/customer(post)',tick=", 0>>
32
+ <<"/customer(post) called!!!">>
33
+ <<"Default process p__customer_post_ for operation '/customer(post)',tick=", 0>>
34
+ <<"/customer(post) called!!!">>
35
+ <<"Default process p__customer_post_ for operation '/customer(post)',tick=", 0>>
36
+ <<"/customer(post) called!!!">>
37
+ <<"Default process p__customer_post_ for operation '/customer(post)',tick=", 0>>
38
+ <<"/customer(post) called!!!">>
39
+ <<"Default process p__customer_post_ for operation '/customer(post)',tick=", 0>>
40
+ <<"/customer(post) called!!!">>
41
+ <<"Default process p__customer_post_ for operation '/customer(post)',tick=", 0>>
42
+ <<"/customer(post) called!!!">>
43
+ Error: Invariant Customers_ValidDomain is violated.
44
+ Error: The behavior up to this point is:
45
+ State 1: <Initial predicate>
46
+ /\ tx_running = FALSE
47
+ /\ steps = << { [ process |-> "p__customer_post_",
48
+ bindRule |-> WildCard,
49
+ bindSet |-> Nil,
50
+ ctx |-> Nil ] } >>
51
+ /\ resume_context = Nil
52
+ /\ dummy_input = ("Tail" :> Nil @@ "/customer(post)" :> Nil)
53
+ /\ now = 0
54
+ /\ pc = ("Tail" :> "tail_wait" @@ "/customer(post)" :> "p__customer_post__enter")
55
+ /\ step_parameter = {}
56
+ /\ input = ("Tail" :> Nil @@ "/customer(post)" :> Nil)
57
+ /\ step = Nil
58
+ /\ responses = Nil
59
+ /\ customers = {}
60
+ /\ stack = ("Tail" :> <<>> @@ "/customer(post)" :> <<>>)
61
+
62
+ <<"Default process p__customer_post_ for operation '/customer(post)',tick=", 0>>
63
+ <<"/customer(post) called!!!">>
64
+ <<"Default process p__customer_post_ for operation '/customer(post)',tick=", 0>>
65
+ <<"/customer(post) called!!!">>
66
+ <<"Default process p__customer_post_ for operation '/customer(post)',tick=", 0>>
67
+ <<"/customer(post) called!!!">>
68
+ <<"Default process p__customer_post_ for operation '/customer(post)',tick=", 0>>
69
+ <<"/customer(post) called!!!">>
70
+ <<"Default process p__customer_post_ for operation '/customer(post)',tick=", 0>>
71
+ <<"/customer(post) called!!!">>
72
+ <<"Default process p__customer_post_ for operation '/customer(post)',tick=", 0>>
73
+ <<"/customer(post) called!!!">>
74
+ <<"Default process p__customer_post_ for operation '/customer(post)',tick=", 0>>
75
+ <<"/customer(post) called!!!">>
76
+ <<"Default process p__customer_post_ for operation '/customer(post)',tick=", 0>>
77
+ <<"/customer(post) called!!!">>
78
+ State 2: <Action line 638, col 28 to line 653, col 78 of module model>
79
+ /\ tx_running = TRUE
80
+ /\ steps = << { [ process |-> "p__customer_post_",
81
+ bindRule |-> WildCard,
82
+ bindSet |-> Nil,
83
+ ctx |-> Nil ] } >>
84
+ /\ resume_context = Nil
85
+ /\ dummy_input = ("Tail" :> Nil @@ "/customer(post)" :> Nil)
86
+ /\ now = 1
87
+ /\ pc = ("Tail" :> "tail_wait" @@ "/customer(post)" :> "p__customer_post__exit")
88
+ /\ step_parameter = [ process |-> "p__customer_post_",
89
+ bindRule |-> WildCard,
90
+ bindSet |-> Nil,
91
+ ctx |-> Nil ]
92
+ /\ input = ("Tail" :> Nil @@ "/customer(post)" :> Nil)
93
+ /\ step = "p__customer_post_"
94
+ /\ responses = Nil
95
+ /\ customers = {[customer |-> [id |-> Nil, type |-> Nil, name |-> Nil]]}
96
+ /\ stack = ("Tail" :> <<>> @@ "/customer(post)" :> <<>>)
97
+
98
+ 9 states generated, 2 distinct states found, 1 states left on queue.
99
+ The depth of the complete state graph search is 2.
100
+ Finished. (2017-10-02 10:29:22)
101
+
102
+ Compilation finished at Mon Oct 2 10:29:22
@@ -0,0 +1,9 @@
1
+ require_relative "../spec_helper.rb"
2
+
3
+ describe TlaTraceFilter::Parser::Grammar do
4
+
5
+ # Framework ok?
6
+ it { expect( 1 ).to eql 1 }
7
+
8
+
9
+ end
@@ -0,0 +1,392 @@
1
+ require_relative ("../spec_helper.rb")
2
+
3
+ describe TlaTraceFilter::Parser::Parser do
4
+
5
+ it { expect( described_class ).to be_a Class }
6
+
7
+ let( :parser ) { described_class.new }
8
+ let( :grammar_module ) { TlaTraceFilter::Parser::Grammar }
9
+
10
+ # ------------------------------------------------------------------
11
+ # Interface
12
+ describe "module interface" do
13
+ describe "class-methods" do
14
+ subject { described_class }
15
+ %i[ parser_instance ].each do |op|
16
+ specify { is_expected.to respond_to(op) }
17
+ end
18
+ end
19
+
20
+ describe "instance-methods" do
21
+ subject { described_class.new }
22
+ %i[ parse ].each do |op|
23
+ specify { is_expected.to respond_to(op) }
24
+ end
25
+ end
26
+ end
27
+
28
+
29
+ describe ".parser_instance" do
30
+ let( :parser_instance ) { described_class.parser_instance }
31
+ it { expect( parser_instance ).to be_a TlaTraceFilter::Parser::GrammarParser }
32
+ end
33
+
34
+ # ------------------------------------------------------------------
35
+ # parse rules
36
+
37
+ describe "#parse" do
38
+ let( :parse ) { parser.parse( data, start) }
39
+ context "start==nil" do
40
+ let( :start ) { nil }
41
+ end
42
+
43
+ context "start:string" do
44
+ let( :start ) { :string }
45
+ context "data:string" do
46
+ let( :data ) { '"string"' }
47
+ it { expect( parse ).to be_a grammar_module::SyntaxNode }
48
+ it { expect( parse.text_value ).to eql data }
49
+ end
50
+ end # start:string
51
+
52
+ context "start:integer" do
53
+ let( :start ) { :integer }
54
+ context "data:123" do
55
+ let( :data ) { '123' }
56
+ it { expect( parse ).to be_a grammar_module::SyntaxNode }
57
+ it { expect( parse.text_value ).to eql data }
58
+ end
59
+ end # start:string
60
+
61
+ context "start:name" do
62
+ let( :start ) { :name }
63
+ context "data:name" do
64
+ let( :data ) { 'name_123asAA' }
65
+ it { expect( parse ).to be_a grammar_module::SyntaxNode }
66
+ it { expect( parse.text_value ).to eql data }
67
+ end
68
+ context "data:_name" do
69
+ let( :data ) { '_name_123asAA' }
70
+ it { expect( parse ).to be_a grammar_module::SyntaxNode }
71
+ it { expect( parse.text_value ).to eql data }
72
+ end
73
+ end # start:string
74
+
75
+ context "start:resered_word" do
76
+ let( :start ) { :reserved_word }
77
+ %w[ Nil FALSE TRUE ].each do |word|
78
+ context "word=#{word}" do
79
+ let( :data ) { word }
80
+ it { expect( parse.text_value ).to eql data }
81
+ end
82
+ end
83
+ end
84
+
85
+ context "start:whitespace" do
86
+ let( :start ) { :whitespace }
87
+ context "one space character" do
88
+ let( :data ) { " " }
89
+ it { expect( parse ).to be_a grammar_module::SyntaxNode }
90
+ it { expect( parse.text_value ).to eql data }
91
+ end
92
+ context "data:string" do
93
+ let( :data ) { '"string"' }
94
+ it { expect{ parse }.to raise_error TlaTraceFilter::Parser::ParseException, /Expected/ }
95
+ end
96
+ end # start:whipeace
97
+
98
+ context "start:sequence_value" do
99
+ let( :start ) { :sequence_value }
100
+ context "{}" do
101
+ let( :data ) { "<< >>" }
102
+ it { expect( parse.text_value ).to eql data }
103
+ end
104
+ context "{Nil}" do
105
+ let( :data ) { "<< >>" }
106
+ it { expect( parse.text_value ).to eql data }
107
+ end
108
+ end # sequence
109
+
110
+ context "start:record_value" do
111
+ let( :start ) { :record_value }
112
+ context "[]" do
113
+ let( :data ) { "[]" }
114
+ it { expect( parse.text_value ).to eql data }
115
+ end
116
+ context '[ process |-> "p__customer_post_" ]' do
117
+ let( :data ) { '[ process |-> "p__customer_post_" ]' }
118
+ it { expect( parse.text_value ).to eql data }
119
+ # it { puts parse.inspect }
120
+ it { expect( parse ).to be_a grammar_module::RecordValue}
121
+ it { expect( parse.record_elements.length ).to eql 1 }
122
+ it { expect( parse.record_elements ).to be_a Array }
123
+ describe "expectRecor" do
124
+ let( :expectRecord ) { { "process" => "p__customer_post_"} }
125
+ it { expect( parse.value ).to eql expectRecord }
126
+ it { expect( parse.record_elements.map{ |e| { e.element_name.value =>e.element_value.value } } ).to eql [ expectRecord ] }
127
+ it { expect( parse.record_elements.map{ |e| e.value } ).to eql [ expectRecord ] }
128
+ end
129
+ end
130
+ context '[ process |-> "p__customer_post_", key |-> 2 ]' do
131
+ let( :data ) { '[ process |-> "p__customer_post_", key |-> 2 ]' }
132
+ it { expect( parse.text_value ).to eql data }
133
+ end
134
+ end # sequence
135
+
136
+ context "start:function_value" do
137
+ let( :start ) { :function_value }
138
+ context "()" do
139
+ let( :data ) { "()" }
140
+ it { expect( parse.text_value ).to eql data }
141
+ end
142
+ context "()" do
143
+ let( :data ) { "( )" }
144
+ it { expect( parse.text_value ).to eql data }
145
+ end
146
+ end # function_value
147
+
148
+ context "start:state_variable" do
149
+ let( :start ) { :state_variable }
150
+ let( :state_variable ) { parse.state_variable }
151
+ let( :name ) { parse.name }
152
+ context "responses = Nil" do
153
+ let( :data ) { 'responses = Nil' }
154
+ it { expect( parse.text_value ).to eql data }
155
+ it { expect( parse ).to be_a grammar_module::StateVariable }
156
+ # it { puts parse.inspect }
157
+ # it { puts parse.to_s }
158
+ it { expect( state_variable.text_value ).to eql "responses" }
159
+ it { expect( name ).to eql "responses" }
160
+ end
161
+ context 'dummy_input = ("Tail" :> Nil @@ "/customer(post)" :> Nil)' do
162
+ let( :data ) { 'dummy_input = ("Tail" :> Nil @@ "/customer(post)" :> Nil)' }
163
+ it { expect( parse.text_value ).to eql data }
164
+ end
165
+ context 'multi line record' do
166
+ let( :data ) { 'steps = << { [ process |-> "p__customer_post_",
167
+ bindRule |-> WildCard,
168
+ bindSet |-> Nil,
169
+ ctx |-> Nil ] } >>' }
170
+ it { expect( parse.text_value ).to eql data }
171
+ end
172
+ end # function_value
173
+
174
+
175
+ context "start:composite_value" do
176
+ let( :start ) { :composite_value }
177
+ context "{ << >> }" do
178
+ let( :data ) { "{ << >> }" }
179
+ it { expect( parse.text_value ).to eql data }
180
+ end
181
+ context '("Tail" :> <<>> @@ "/customer(post)" :> <<>>)' do
182
+ let( :data ) { '("Tail" :> <<>> @@ "/customer(post)" :> <<>>)' }
183
+ it { expect( parse.text_value ).to eql data }
184
+ end
185
+ end # composite value
186
+
187
+ context "start:set_value" do
188
+ let( :start ) { :set_value }
189
+ context "{}" do
190
+ let( :data ) { "{}" }
191
+ it { expect( parse.text_value ).to eql data }
192
+ end
193
+ context "{ <space>}" do
194
+ let( :data ) { "{ }" }
195
+ it { expect( parse.text_value ).to eql data }
196
+ end
197
+ context "{ 1 }" do
198
+ let( :data ) { "{ 1 }" }
199
+ it { expect( parse.text_value ).to eql data }
200
+ end
201
+ context "{ 1,2 }" do
202
+ let( :data ) { "{ 1,2 }" }
203
+ it { expect( parse.text_value ).to eql data }
204
+ end
205
+ context "{ 1,'aa' }" do
206
+ let( :data ) { '{ 1,"aa"}' }
207
+ it { expect( parse.text_value ).to eql data }
208
+ end
209
+ end # context "start:set_value" do
210
+
211
+ context "start:stace_space" do
212
+ let( :start ) { :state_space }
213
+ context "trace.rb" do
214
+ let( :data ) {
215
+ <<~EOS
216
+ /\\ tx_running = TRUE
217
+ /\\ steps = << { [ process |-> "p__customer_post_",
218
+ bindRule |-> WildCard,
219
+ bindSet |-> Nil,
220
+ ctx |-> Nil ] } >>
221
+ /\\ resume_context = Nil
222
+ /\\ dummy_input = ("Tail" :> Nil @@ "/customer(post)" :> Nil)
223
+ /\\ now = 1
224
+ /\\ pc = ("Tail" :> "tail_wait" @@ "/customer(post)" :> "p__customer_post__exit")
225
+ /\\ step_parameter = [ process |-> "p__customer_post_",
226
+ bindRule |-> WildCard,
227
+ bindSet |-> Nil,
228
+ ctx |-> Nil ]
229
+ /\\ input = ("Tail" :> Nil @@ "/customer(post)" :> Nil)
230
+ /\\ step = "p__customer_post_"
231
+ /\\ responses = Nil
232
+ /\\ customers = {[customer |-> [id |-> Nil, type |-> Nil, name |-> Nil]]}
233
+ /\\ stack = ("Tail" :> <<>> @@ "/customer(post)" :> <<>>)
234
+ EOS
235
+ }
236
+ # it { puts parse.inspect}
237
+ it { expect( parse.text_value ).to eql data }
238
+
239
+ end # context "trace" do
240
+
241
+ end # context "start:stace_space" do
242
+
243
+ end # parse
244
+
245
+ # ------------------------------------------------------------------
246
+ # Value
247
+
248
+ describe ":state_space#value" do
249
+ let( :parse ) { parser.parse( data, start) }
250
+ let( :start ) { nil }
251
+ context "trace" do
252
+ let( :data ) {
253
+ <<~EOS
254
+ /\\ tx_running = TRUE
255
+ /\\ steps = << { [ process |-> "p__customer_post_",
256
+ bindRule |-> WildCard,
257
+ bindSet |-> Nil,
258
+ ctx |-> Nil ] } >>
259
+ /\\ resume_context = Nil
260
+ /\\ dummy_input = ("Tail" :> Nil @@ "/customer(post)" :> Nil)
261
+ /\\ now = 1
262
+ /\\ pc = ("Tail" :> "tail_wait" @@ "/customer(post)" :> "p__customer_post__exit")
263
+ /\\ step_parameter = [ process |-> "p__customer_post_",
264
+ bindRule |-> WildCard,
265
+ bindSet |-> Nil,
266
+ ctx |-> Nil ]
267
+ /\\ input = ("Tail" :> Nil @@ "/customer(post)" :> Nil)
268
+ /\\ empty_seq = << >>
269
+ /\\ empty_rec = [ ]
270
+ /\\ nil_rec = [ test |-> Nil ]
271
+ /\\ one_seq = << 1 >>
272
+ /\\ one_seq_seq = << 1, << >> >>
273
+ /\\ dummy_set = {}
274
+ /\\ empty_function = ()
275
+ /\\ simple_function = ( "Tail" :> TRUE )
276
+ /\\ single_set = { 1 }
277
+ /\\ step = "p__customer_post_"
278
+ /\\ responses = Nil
279
+ /\\ customers = {[customer |-> [id |-> Nil, type |-> Nil, name |-> Nil]]}
280
+ /\\ stack = ("Tail" :> <<>> @@ "/customer(post)" :> <<1, FALSE >>)
281
+ EOS
282
+ }
283
+ it { expect( parse ).to be_a TlaTraceFilter::Parser::Grammar::StateSpace }
284
+ describe "#state_space" do
285
+ let ( :state_space ) { parse.state_space }
286
+ it { expect( state_space ).to be_a Hash }
287
+ # it { puts "parse =#{parse.inspect}" }
288
+ it { expect( state_space.keys ).to include( :now, :pc, :step ) }
289
+
290
+ describe "simple values" do
291
+ describe ":now" do
292
+ let ( :now ) { state_space[:now] }
293
+ # it { puts "now =#{now.inspect}" }
294
+ # it { puts "now.value =#{now.variable_value.inspect}" }
295
+ it { expect( now.variable_value.value ).to eql 1 }
296
+ end
297
+ describe ":tx_running" do
298
+ let ( :tx_running ) { state_space[:tx_running] }
299
+ # it { puts "now =#{now.inspect}" }
300
+ # it { puts "tx_running.value =#{tx_running.variable_value.inspect}" }
301
+ it { expect( tx_running.variable_value.value ).to eql true }
302
+ end
303
+ describe ":step" do
304
+ let ( :step ) { state_space[:step] }
305
+ # it { puts "now =#{now.inspect}" }
306
+ # it { puts "step.variable_value =#{step.variable_value.inspect}" }
307
+ # it { puts "step.variable_value.value. =#{step.variable_value.value.class}" }
308
+ it { expect( step.variable_value.value ).to eql "p__customer_post_" }
309
+ end
310
+
311
+ end # smple values
312
+ describe "records" do
313
+ describe ":empty_rec" do
314
+ let ( :empty_rec ) { state_space[:empty_rec] }
315
+ # it { puts "empty_rec =#{empty_rec.inspect}" }
316
+ it { expect( empty_rec.variable_value.value ).to eql( {} ) }
317
+ end
318
+ describe ":nil_rec" do
319
+ let ( :nil_rec ) { state_space[:nil_rec] }
320
+ # it { puts "nil_rec =#{nil_rec.inspect}" }
321
+ it { expect( nil_rec.variable_value.value ).to eql( { "test" => nil } ) }
322
+ end
323
+ end # recrods
324
+
325
+ describe "sequence" do
326
+ describe ":empty_seq" do
327
+ let ( :empty_seq ) { state_space[:empty_seq] }
328
+ # it { puts "empty_seq =#{empty_seq.inspect}" }
329
+ it { expect( empty_seq.variable_value.value ).to eql( [] ) }
330
+ end
331
+
332
+ describe ":one_seq" do
333
+ let ( :one_seq ) { state_space[:one_seq] }
334
+ # it { puts "empty_seq =#{one_seq.inspect}" }
335
+ it { expect( one_seq.variable_value.value ).to eql( [ 1 ] ) }
336
+ end
337
+ describe ":one_seq_seq" do
338
+ let ( :one_seq_seq ) { state_space[:one_seq_seq] }
339
+ # it { puts "empty_seq =#{one_seq_seq.inspect}" }
340
+ it { expect( one_seq_seq.variable_value.value ).to eql( [ 1, [] ] ) }
341
+ end
342
+
343
+ describe ":steps" do
344
+ let ( :steps ) { state_space[:steps] }
345
+ # it { puts "stepsc =#{steps.inspect}" }
346
+ it { expect( steps.variable_value.value ).to eql( [ Set.new([{"process"=>"p__customer_post_", "bindRule"=>"*", "bindSet"=>nil, "ctx"=>nil}])] ) }
347
+ end
348
+
349
+ end # sequence
350
+
351
+ describe "function" do
352
+ describe ":empty_function" do
353
+ let( :function ) { state_space[:empty_function] }
354
+ # it { puts "function =#{function.inspect}" }
355
+ it { expect( function.variable_value.value ).to eql({}) }
356
+ end
357
+ describe ":simple_function" do
358
+ let( :function ) { state_space[:simple_function] }
359
+ # it { puts "function =#{function.inspect}" }
360
+ it { expect( function.variable_value.value ).to eql({ "Tail" => true }) }
361
+ end
362
+ describe ":stack" do
363
+ let( :function ) { state_space[:stack] }
364
+ # it { puts "function =#{function.inspect}" }
365
+ it { expect( function.variable_value.value ).to eql({ "Tail" => [], "/customer(post)" => [1, false] }) }
366
+ end
367
+ end
368
+
369
+
370
+ describe "set" do
371
+ describe ":dummy_set" do
372
+ let ( :dummy_set ) { state_space[:dummy_set] }
373
+ # it { puts "dummy_set =#{dummy_set.inspect}" }
374
+ it { expect( dummy_set.variable_value.value ).to eql( Set.new( [] )) }
375
+ end
376
+
377
+ describe ":single_set" do
378
+ let ( :single_set ) { state_space[:single_set] }
379
+ # it { puts "single_set =#{single_set.inspect}" }
380
+ it { expect( single_set.variable_value.value ).to eql( Set.new [ 1 ] ) }
381
+ end
382
+ end # set
383
+
384
+ describe "state_space" do
385
+ # it { puts "state_space=#{state_space.inspect}" }
386
+ it { expect( parse.value.keys ).to include( :tx_running, :stack, :step, :now ) }
387
+ end
388
+ end
389
+ end
390
+
391
+ end
392
+ end