flok 0.0.41 → 0.0.42
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.
- checksums.yaml +4 -4
- data/app/kern/pagers/pg_dummy.js +18 -0
- data/app/kern/services/vm.rb +361 -34
- data/docs/services/vm.md +69 -40
- data/docs/services/vm/diff.md +156 -0
- data/docs/services/vm/pagers.md +3 -2
- data/lib/flok/user_compiler.rb +3 -0
- data/lib/flok/version.rb +1 -1
- data/spec/env/kern.rb +19 -0
- data/spec/etc/user_compiler/controller0bg.rb +13 -0
- data/spec/etc/user_compiler_spec.rb +19 -12
- data/spec/kern/assets/global_on_entry5.rb +28 -0
- data/spec/kern/assets/vm/controller0_diff.rb +47 -0
- data/spec/kern/assets/vm/pg_dummy/config.rb +10 -0
- data/spec/kern/assets/vm/pg_mem/write.rb +1 -1
- data/spec/kern/assets/vm/pg_mem/write2.rb +1 -1
- data/spec/kern/assets/vm/vm_commit_pages.js +108 -0
- data/spec/kern/assets/vm/vm_diff_pages.js +140 -0
- data/spec/kern/assets/vm/vm_transaction_diff_pages.js +150 -0
- data/spec/kern/controller_spec.rb +19 -0
- data/spec/kern/vm_service_functional_spec.rb +1111 -0
- data/spec/kern/vm_service_spec.rb +84 -185
- data/spec/kern/vm_transaction_spec.rb +375 -0
- metadata +22 -4
- data/spec/kern/vm_service_spec2.rb +0 -39
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
#The vm service
|
2
2
|
|
3
3
|
Dir.chdir File.join File.dirname(__FILE__), '../../'
|
4
4
|
require './spec/env/kern.rb'
|
@@ -34,132 +34,6 @@ RSpec.describe "kern:vm_service" do
|
|
34
34
|
expect(vm_notify_map).to eq(res)
|
35
35
|
end
|
36
36
|
|
37
|
-
it "vm_rehash_page can calculate the hash correctly for arrays" do
|
38
|
-
ctx = flok_new_user File.read('./spec/kern/assets/vm/controller0.rb'), File.read("./spec/kern/assets/vm/config3.rb")
|
39
|
-
|
40
|
-
#Run the check
|
41
|
-
res = ctx.eval %{
|
42
|
-
//Manually construct a page
|
43
|
-
var page = {
|
44
|
-
_head: null,
|
45
|
-
_type: "array",
|
46
|
-
_next: null,
|
47
|
-
_id: "hello",
|
48
|
-
entries: [
|
49
|
-
{_id: "hello2", _sig: "nohteunth"},
|
50
|
-
]
|
51
|
-
}
|
52
|
-
|
53
|
-
vm_rehash_page(page);
|
54
|
-
}
|
55
|
-
|
56
|
-
#Calculate hash ourselves
|
57
|
-
hash = crc32("hello")
|
58
|
-
hash = crc32("nohteunth", hash)
|
59
|
-
page = JSON.parse(ctx.eval("JSON.stringify(page)"))
|
60
|
-
page = JSON.parse(ctx.eval("JSON.stringify(page)"))
|
61
|
-
|
62
|
-
#Expect the same hash
|
63
|
-
expect(page).to eq({
|
64
|
-
"_head" => nil,
|
65
|
-
"_type" => "array",
|
66
|
-
"_next" => nil,
|
67
|
-
"_id" => "hello",
|
68
|
-
"entries" => [
|
69
|
-
{"_id" => "hello2", "_sig" => "nohteunth"}
|
70
|
-
],
|
71
|
-
"_hash" => hash.to_s
|
72
|
-
})
|
73
|
-
end
|
74
|
-
|
75
|
-
it "vm_rehash_page can calculate the hash correctly for hashes" do
|
76
|
-
ctx = flok_new_user File.read('./spec/kern/assets/vm/controller0.rb'), File.read("./spec/kern/assets/vm/config3.rb")
|
77
|
-
|
78
|
-
#Run the check
|
79
|
-
res = ctx.eval %{
|
80
|
-
//Manually construct a page
|
81
|
-
var page = {
|
82
|
-
_head: null,
|
83
|
-
"_type": "hash",
|
84
|
-
_next: null,
|
85
|
-
_id: "hello",
|
86
|
-
entries: {
|
87
|
-
"my_key": {_sig: "a"},
|
88
|
-
"my_key2": {_sig: "b"},
|
89
|
-
"my_key3": {_sig: "c"},
|
90
|
-
}
|
91
|
-
}
|
92
|
-
|
93
|
-
vm_rehash_page(page);
|
94
|
-
}
|
95
|
-
|
96
|
-
#Calculate hash ourselves
|
97
|
-
hash = crc32("hello")
|
98
|
-
|
99
|
-
#XOR the _sigs for the hash calculations
|
100
|
-
a = crc32("a", 0)
|
101
|
-
b = crc32("b", 0)
|
102
|
-
c = crc32("c", 0)
|
103
|
-
hash = crc32((a + b + c).to_s, hash)
|
104
|
-
|
105
|
-
page = JSON.parse(ctx.eval("JSON.stringify(page)"))
|
106
|
-
page = JSON.parse(ctx.eval("JSON.stringify(page)"))
|
107
|
-
|
108
|
-
#Expect the same hash
|
109
|
-
expect(page).to eq({
|
110
|
-
"_head" => nil,
|
111
|
-
"_next" => nil,
|
112
|
-
"_type" => "hash",
|
113
|
-
"_id" => "hello",
|
114
|
-
"entries" => {
|
115
|
-
"my_key" => {"_sig" => "a"},
|
116
|
-
"my_key2" => {"_sig" => "b"},
|
117
|
-
"my_key3" => {"_sig" => "c"},
|
118
|
-
},
|
119
|
-
"_hash" => hash.to_s
|
120
|
-
})
|
121
|
-
end
|
122
|
-
|
123
|
-
|
124
|
-
it "vm_rehash_page can calculate the hash correctly with head and next for an array" do
|
125
|
-
ctx = flok_new_user File.read('./spec/kern/assets/vm/controller0.rb'), File.read("./spec/kern/assets/vm/config3.rb")
|
126
|
-
|
127
|
-
#Run the check
|
128
|
-
res = ctx.eval %{
|
129
|
-
//Manually construct a page
|
130
|
-
var page = {
|
131
|
-
_type: "array",
|
132
|
-
_head: "a",
|
133
|
-
_next: "b",
|
134
|
-
_id: "hello",
|
135
|
-
entries: [
|
136
|
-
{_id: "hello2", _sig: "nohteunth"},
|
137
|
-
]
|
138
|
-
}
|
139
|
-
|
140
|
-
vm_rehash_page(page);
|
141
|
-
}
|
142
|
-
|
143
|
-
#Calculate hash ourselves
|
144
|
-
hash = crc32("a")
|
145
|
-
hash = crc32("b", hash)
|
146
|
-
hash = crc32("hello", hash)
|
147
|
-
hash = crc32("nohteunth", hash)
|
148
|
-
page = JSON.parse(ctx.eval("JSON.stringify(page)"))
|
149
|
-
|
150
|
-
#Expect the same hash
|
151
|
-
expect(page).to eq({
|
152
|
-
"_head" => "a",
|
153
|
-
"_type" => "array",
|
154
|
-
"_next" => "b",
|
155
|
-
"_id" => "hello",
|
156
|
-
"entries" => [
|
157
|
-
{"_id" => "hello2", "_sig" => "nohteunth"}
|
158
|
-
],
|
159
|
-
"_hash" => hash.to_s
|
160
|
-
})
|
161
|
-
end
|
162
|
-
|
163
37
|
it "Can call vm_cache_write and save it to vm_cache[ns][id]" do
|
164
38
|
ctx = flok_new_user File.read('./spec/kern/assets/vm/controller0.rb'), File.read("./spec/kern/assets/vm/config3.rb")
|
165
39
|
|
@@ -928,62 +802,62 @@ RSpec.describe "kern:vm_service" do
|
|
928
802
|
end
|
929
803
|
|
930
804
|
#it "Responds twice to watch with a missing cache but where the disk has a copy and then the pager responds" do
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
805
|
+
#ctx = flok_new_user File.read('./spec/kern/assets/vm/controller20.rb'), File.read("./spec/kern/assets/vm/config4.rb")
|
806
|
+
|
807
|
+
#ctx.eval %{
|
808
|
+
#base = _embed("my_controller", 1, {}, null);
|
809
|
+
|
810
|
+
#//Manually construct a page
|
811
|
+
#page = {
|
812
|
+
#_head: null,
|
813
|
+
#_next: null,
|
814
|
+
#_id: "hello",
|
815
|
+
#entries: [
|
816
|
+
#{_id: "hello2", _sig: "nohteunth"},
|
817
|
+
#]
|
818
|
+
#}
|
819
|
+
|
820
|
+
#//Manually construct another page that would normally be written
|
821
|
+
#//by a 'pager' to the cache
|
822
|
+
#page2 = {
|
823
|
+
#_head: null,
|
824
|
+
#_next: null,
|
825
|
+
#_id: "hello",
|
826
|
+
#entries: [
|
827
|
+
#{_id: "hello2", _sig: "nohteunth"},
|
828
|
+
#{_id: "hello3", _sig: "athoeuntz"}
|
829
|
+
#]
|
830
|
+
#}
|
831
|
+
|
832
|
+
#//Recalculate hashes
|
833
|
+
#vm_rehash_page(page);
|
834
|
+
#vm_rehash_page(page2);
|
835
|
+
|
836
|
+
#//Drain queue
|
837
|
+
#int_dispatch([]);
|
838
|
+
#}
|
839
|
+
|
840
|
+
##Copies of JS pages in ruby dictionary format
|
841
|
+
#page = JSON.parse(ctx.eval("JSON.stringify(page)"))
|
842
|
+
#page2 = JSON.parse(ctx.eval("JSON.stringify(page2)"))
|
843
|
+
|
844
|
+
##At this point, flok should have attempted to grab a page to fill
|
845
|
+
##the *now* blank cache. We are going to send it the first page.
|
846
|
+
#@driver.ignore_up_to "if_per_get", 2
|
847
|
+
#@driver.get "if_per_get", 2
|
848
|
+
#@driver.int "int_per_get_res", ["vm", "spec", page]
|
849
|
+
|
850
|
+
##Now, we pretend that a pager has written to the cache because it has
|
851
|
+
##received data back
|
852
|
+
#ctx.eval(%{vm_cache_write("spec", page2)})
|
853
|
+
|
854
|
+
#res = JSON.parse(ctx.eval("JSON.stringify(read_res)"))
|
855
|
+
#expect(res).to eq([
|
856
|
+
#page, page2
|
857
|
+
#])
|
858
|
+
#end
|
859
|
+
|
860
|
+
it "Responds once to watch with a missing cache but where the pager responds before the disk for array" do
|
987
861
|
ctx = flok_new_user File.read('./spec/kern/assets/vm/controller20.rb'), File.read("./spec/kern/assets/vm/config4.rb")
|
988
862
|
|
989
863
|
ctx.eval %{
|
@@ -1044,7 +918,7 @@ RSpec.describe "kern:vm_service" do
|
|
1044
918
|
])
|
1045
919
|
end
|
1046
920
|
|
1047
|
-
|
921
|
+
it "Responds once to watch with a missing cache but where the pager responds before the disk for hash" do
|
1048
922
|
ctx = flok_new_user File.read('./spec/kern/assets/vm/controller20.rb'), File.read("./spec/kern/assets/vm/config4.rb")
|
1049
923
|
|
1050
924
|
ctx.eval %{
|
@@ -1179,5 +1053,30 @@ RSpec.describe "kern:vm_service" do
|
|
1179
1053
|
|
1180
1054
|
@driver.ignore_up_to "if_per_set", 2
|
1181
1055
|
@driver.mexpect("if_per_set", ["spec", page2["_id"], page2], 2)
|
1182
|
-
|
1056
|
+
end
|
1057
|
+
|
1058
|
+
it "Can create a copy of pg_spec0 and pg_spec1 and receive the correct things in it's initialization" do
|
1059
|
+
ctx = flok_new_user File.read('./spec/kern/assets/vm/controller22.rb'), File.read("./spec/kern/assets/vm/config5.rb")
|
1060
|
+
ctx.eval %{
|
1061
|
+
base = _embed("my_controller", 0, {}, null);
|
1062
|
+
|
1063
|
+
//Drain queue
|
1064
|
+
int_dispatch([]);
|
1065
|
+
}
|
1066
|
+
|
1067
|
+
pg_spec0_init_params = JSON.parse(ctx.eval("JSON.stringify(pg_spec0_init_params)"))
|
1068
|
+
pg_spec1_init_params = JSON.parse(ctx.eval("JSON.stringify(pg_spec1_init_params)"))
|
1069
|
+
|
1070
|
+
#Expect options and ns to match in config5
|
1071
|
+
expect(pg_spec0_init_params).to eq({
|
1072
|
+
"ns" => "spec0",
|
1073
|
+
"options" => {"hello" => "world"}
|
1074
|
+
})
|
1075
|
+
|
1076
|
+
#Expect options and ns to match in config5
|
1077
|
+
expect(pg_spec1_init_params).to eq({
|
1078
|
+
"ns" => "spec1",
|
1079
|
+
"options" => {"foo" => "bar"}
|
1080
|
+
})
|
1081
|
+
end
|
1183
1082
|
end
|
@@ -0,0 +1,375 @@
|
|
1
|
+
#Spec for the transactional & diff of the vm service
|
2
|
+
Dir.chdir File.join File.dirname(__FILE__), '../../'
|
3
|
+
require './spec/env/kern.rb'
|
4
|
+
require './spec/lib/helpers.rb'
|
5
|
+
require './spec/lib/io_extensions.rb'
|
6
|
+
require './spec/lib/rspec_extensions.rb'
|
7
|
+
require 'zlib'
|
8
|
+
|
9
|
+
RSpec.describe "kern:vm_transaction" do
|
10
|
+
include Zlib
|
11
|
+
include_context "kern"
|
12
|
+
|
13
|
+
#pg_dummy pager
|
14
|
+
######################################################################
|
15
|
+
it "Can initialize the pg_dummy0 pager" do
|
16
|
+
ctx = flok_new_user File.read('./spec/kern/assets/vm/controller0.rb'), File.read("./spec/kern/assets/vm/pg_dummy/config.rb")
|
17
|
+
ctx.eval %{
|
18
|
+
//Call embed on main root view
|
19
|
+
base = _embed("my_controller", 0, {}, null);
|
20
|
+
|
21
|
+
//Drain queue
|
22
|
+
int_dispatch([]);
|
23
|
+
}
|
24
|
+
|
25
|
+
res = ctx.eval("pg_dummy0_spec_did_init")
|
26
|
+
expect(res).to eq(true)
|
27
|
+
end
|
28
|
+
######################################################################
|
29
|
+
|
30
|
+
#vm_transaction functions
|
31
|
+
######################################################################
|
32
|
+
it "does throw exception when vm_cache_write is called before vm_transaction_begin" do
|
33
|
+
ctx = flok_new_user File.read('./spec/kern/assets/vm/controller0.rb'), File.read("./spec/kern/assets/vm/pg_dummy/config.rb")
|
34
|
+
expect {
|
35
|
+
ctx.eval %{
|
36
|
+
//Call embed on main root view
|
37
|
+
base = _embed("my_controller", 0, {}, null);
|
38
|
+
|
39
|
+
//Drain queue
|
40
|
+
int_dispatch([]);
|
41
|
+
|
42
|
+
vm_cache_write("dummy", {});
|
43
|
+
vm_transaction_begin();
|
44
|
+
}
|
45
|
+
}.to raise_exception
|
46
|
+
end
|
47
|
+
|
48
|
+
it "does throw exception when vm_transaction_begin is called twice in a row without a vm_transaction_end" do
|
49
|
+
ctx = flok_new_user File.read('./spec/kern/assets/vm/controller0.rb'), File.read("./spec/kern/assets/vm/pg_dummy/config.rb")
|
50
|
+
expect {
|
51
|
+
ctx.eval %{
|
52
|
+
//Call embed on main root view
|
53
|
+
base = _embed("my_controller", 0, {}, null);
|
54
|
+
|
55
|
+
//Drain queue
|
56
|
+
int_dispatch([]);
|
57
|
+
|
58
|
+
vm_transaction_begin();
|
59
|
+
vm_transaction_begin();
|
60
|
+
}
|
61
|
+
}.to raise_exception
|
62
|
+
end
|
63
|
+
|
64
|
+
it "does throw exception when vm_transaction_end is called without a vm_transaction_begin" do
|
65
|
+
ctx = flok_new_user File.read('./spec/kern/assets/vm/controller0.rb'), File.read("./spec/kern/assets/vm/pg_dummy/config.rb")
|
66
|
+
expect {
|
67
|
+
ctx.eval %{
|
68
|
+
//Call embed on main root view
|
69
|
+
base = _embed("my_controller", 0, {}, null);
|
70
|
+
|
71
|
+
//Drain queue
|
72
|
+
int_dispatch([]);
|
73
|
+
|
74
|
+
vm_transaction_end();
|
75
|
+
}
|
76
|
+
}.to raise_exception
|
77
|
+
end
|
78
|
+
|
79
|
+
|
80
|
+
it "does not throw exception when vm_transaction_begin is called twice in a row with a vm_transaction_end in-between" do
|
81
|
+
ctx = flok_new_user File.read('./spec/kern/assets/vm/controller0.rb'), File.read("./spec/kern/assets/vm/pg_dummy/config.rb")
|
82
|
+
ctx.eval %{
|
83
|
+
//Call embed on main root view
|
84
|
+
base = _embed("my_controller", 0, {}, null);
|
85
|
+
|
86
|
+
//Drain queue
|
87
|
+
int_dispatch([]);
|
88
|
+
|
89
|
+
vm_transaction_begin();
|
90
|
+
vm_transaction_end();
|
91
|
+
vm_transaction_begin();
|
92
|
+
}
|
93
|
+
end
|
94
|
+
######################################################################
|
95
|
+
|
96
|
+
#vm_diff events to controller at the end of transactions
|
97
|
+
######################################################################
|
98
|
+
def reload_vm_transaction_diff_pages(ctx)
|
99
|
+
pages_src = File.read("./spec/kern/assets/vm/vm_transaction_diff_pages.js")
|
100
|
+
ctx.eval pages_src
|
101
|
+
end
|
102
|
+
|
103
|
+
it "does send the controller the entry_modify when an entry is modified in the page" do
|
104
|
+
ctx = flok_new_user File.read('./spec/kern/assets/vm/controller0_diff.rb'), File.read("./spec/kern/assets/vm/pg_dummy/config.rb")
|
105
|
+
reload_vm_transaction_diff_pages(ctx)
|
106
|
+
dump = ctx.evald %{
|
107
|
+
//Call embed on main root view
|
108
|
+
base = _embed("my_controller", 0, {}, null);
|
109
|
+
|
110
|
+
//Drain queue
|
111
|
+
int_dispatch([]);
|
112
|
+
|
113
|
+
//Write
|
114
|
+
vm_transaction_begin();
|
115
|
+
vm_cache_write("dummy", triangle_square_z_null);
|
116
|
+
vm_cache_write("dummy", p_circle_null_q);
|
117
|
+
vm_transaction_end();
|
118
|
+
|
119
|
+
for (var i = 0; i < 100; ++i) {
|
120
|
+
int_dispatch([]);
|
121
|
+
}
|
122
|
+
|
123
|
+
dump.entry_modify_params = entry_modify_params;
|
124
|
+
dump.entry_move_params = entry_move_params;
|
125
|
+
dump.entry_del_params = entry_del_params;
|
126
|
+
dump.entry_ins_params = entry_ins_params;
|
127
|
+
}
|
128
|
+
|
129
|
+
expect(dump["entry_modify_params"]).to eq([
|
130
|
+
{
|
131
|
+
"page_id" => "default",
|
132
|
+
"entry" => {"_id" => "id0", "_sig" => "P", "value" => "P"}
|
133
|
+
},
|
134
|
+
{
|
135
|
+
"page_id" => "default",
|
136
|
+
"entry" => {"_id" => "id1", "_sig" => "Circle", "value" => "Circle"}
|
137
|
+
}
|
138
|
+
])
|
139
|
+
end
|
140
|
+
|
141
|
+
it "does send the controller the entry_del when an entry is deleted in the page" do
|
142
|
+
ctx = flok_new_user File.read('./spec/kern/assets/vm/controller0_diff.rb'), File.read("./spec/kern/assets/vm/pg_dummy/config.rb")
|
143
|
+
reload_vm_transaction_diff_pages(ctx)
|
144
|
+
dump = ctx.evald %{
|
145
|
+
//Call embed on main root view
|
146
|
+
base = _embed("my_controller", 0, {}, null);
|
147
|
+
|
148
|
+
//Drain queue
|
149
|
+
int_dispatch([]);
|
150
|
+
|
151
|
+
//Write
|
152
|
+
vm_transaction_begin();
|
153
|
+
vm_cache_write("dummy", triangle_null_a_m);
|
154
|
+
vm_cache_write("dummy", triangle_square_null_null);
|
155
|
+
vm_transaction_end();
|
156
|
+
|
157
|
+
for (var i = 0; i < 100; ++i) {
|
158
|
+
int_dispatch([]);
|
159
|
+
}
|
160
|
+
|
161
|
+
dump.entry_modify_params = entry_modify_params;
|
162
|
+
dump.entry_move_params = entry_move_params;
|
163
|
+
dump.entry_del_params = entry_del_params;
|
164
|
+
dump.entry_ins_params = entry_ins_params;
|
165
|
+
}
|
166
|
+
|
167
|
+
expect(dump["entry_del_params"]).to eq([
|
168
|
+
{
|
169
|
+
"page_id" => "default",
|
170
|
+
"entry_id" => "id2"
|
171
|
+
},
|
172
|
+
{
|
173
|
+
"page_id" => "default",
|
174
|
+
"entry_id" => "id3"
|
175
|
+
},
|
176
|
+
])
|
177
|
+
end
|
178
|
+
|
179
|
+
it "does send the controller the entry_move when an entry is moved within the same page" do
|
180
|
+
ctx = flok_new_user File.read('./spec/kern/assets/vm/controller0_diff.rb'), File.read("./spec/kern/assets/vm/pg_dummy/config.rb")
|
181
|
+
reload_vm_transaction_diff_pages(ctx)
|
182
|
+
dump = ctx.evald %{
|
183
|
+
//Call embed on main root view
|
184
|
+
base = _embed("my_controller", 0, {}, null);
|
185
|
+
|
186
|
+
//Drain queue
|
187
|
+
int_dispatch([]);
|
188
|
+
|
189
|
+
//Write
|
190
|
+
vm_transaction_begin();
|
191
|
+
vm_cache_write("dummy", triangle_square_z_null);
|
192
|
+
vm_cache_write("dummy", triangle_square_z_null_moved_z_square_triangle);
|
193
|
+
vm_transaction_end();
|
194
|
+
|
195
|
+
for (var i = 0; i < 100; ++i) {
|
196
|
+
int_dispatch([]);
|
197
|
+
}
|
198
|
+
|
199
|
+
dump.entry_modify_params = entry_modify_params;
|
200
|
+
dump.entry_move_params = entry_move_params;
|
201
|
+
dump.entry_del_params = entry_del_params;
|
202
|
+
dump.entry_ins_params = entry_ins_params;
|
203
|
+
}
|
204
|
+
|
205
|
+
expect(dump["entry_move_params"]).to eq([
|
206
|
+
{
|
207
|
+
"entry_id" => "id0",
|
208
|
+
"from_page_id" => "default",
|
209
|
+
"to_page_id" => "default",
|
210
|
+
"to_page_index" => 2,
|
211
|
+
},
|
212
|
+
{
|
213
|
+
"entry_id" => "id1",
|
214
|
+
"from_page_id" => "default",
|
215
|
+
"to_page_id" => "default",
|
216
|
+
"to_page_index" => 1,
|
217
|
+
},
|
218
|
+
])
|
219
|
+
end
|
220
|
+
|
221
|
+
it "does send the controller the entry_ins when an entry is inserted in the page" do
|
222
|
+
ctx = flok_new_user File.read('./spec/kern/assets/vm/controller0_diff.rb'), File.read("./spec/kern/assets/vm/pg_dummy/config.rb")
|
223
|
+
reload_vm_transaction_diff_pages(ctx)
|
224
|
+
dump = ctx.evald %{
|
225
|
+
//Call embed on main root view
|
226
|
+
base = _embed("my_controller", 0, {}, null);
|
227
|
+
|
228
|
+
//Drain queue
|
229
|
+
int_dispatch([]);
|
230
|
+
|
231
|
+
//Write
|
232
|
+
vm_transaction_begin();
|
233
|
+
vm_cache_write("dummy", p_null_null_q);
|
234
|
+
vm_cache_write("dummy", triangle_square_z_null);
|
235
|
+
vm_transaction_end();
|
236
|
+
|
237
|
+
for (var i = 0; i < 100; ++i) {
|
238
|
+
int_dispatch([]);
|
239
|
+
}
|
240
|
+
|
241
|
+
dump.entry_modify_params = entry_modify_params;
|
242
|
+
dump.entry_move_params = entry_move_params;
|
243
|
+
dump.entry_del_params = entry_del_params;
|
244
|
+
dump.entry_ins_params = entry_ins_params;
|
245
|
+
}
|
246
|
+
|
247
|
+
expect(dump["entry_ins_params"]).to eq([
|
248
|
+
{
|
249
|
+
"page_id" => "default",
|
250
|
+
"index" => 1,
|
251
|
+
"entry" => {"_id" => "id1", "_sig" => "Square", "value" => "Square"}
|
252
|
+
},
|
253
|
+
{
|
254
|
+
"page_id" => "default",
|
255
|
+
"index" => 2,
|
256
|
+
"entry" => {"_id" => "id2", "_sig" => "Z", "value" => "Z"}
|
257
|
+
},
|
258
|
+
])
|
259
|
+
end
|
260
|
+
|
261
|
+
it "does send the controller the next_changed when the page next changes" do
|
262
|
+
ctx = flok_new_user File.read('./spec/kern/assets/vm/controller0_diff.rb'), File.read("./spec/kern/assets/vm/pg_dummy/config.rb")
|
263
|
+
reload_vm_transaction_diff_pages(ctx)
|
264
|
+
dump = ctx.evald %{
|
265
|
+
//Call embed on main root view
|
266
|
+
base = _embed("my_controller", 0, {}, null);
|
267
|
+
|
268
|
+
//Drain queue
|
269
|
+
int_dispatch([]);
|
270
|
+
|
271
|
+
//Write
|
272
|
+
vm_transaction_begin();
|
273
|
+
vm_cache_write("dummy", next_null);
|
274
|
+
vm_cache_write("dummy", next_world);
|
275
|
+
vm_transaction_end();
|
276
|
+
|
277
|
+
for (var i = 0; i < 100; ++i) {
|
278
|
+
int_dispatch([]);
|
279
|
+
}
|
280
|
+
|
281
|
+
dump.head_changed_params = head_changed_params;
|
282
|
+
dump.next_changed_params = next_changed_params;
|
283
|
+
}
|
284
|
+
|
285
|
+
expect(dump["next_changed_params"]).to eq([
|
286
|
+
{
|
287
|
+
"page_id" => "default",
|
288
|
+
"value" => "world"
|
289
|
+
},
|
290
|
+
])
|
291
|
+
end
|
292
|
+
|
293
|
+
|
294
|
+
it "does send the controller the next_changed when the page head changes" do
|
295
|
+
ctx = flok_new_user File.read('./spec/kern/assets/vm/controller0_diff.rb'), File.read("./spec/kern/assets/vm/pg_dummy/config.rb")
|
296
|
+
reload_vm_transaction_diff_pages(ctx)
|
297
|
+
dump = ctx.evald %{
|
298
|
+
//Call embed on main root view
|
299
|
+
base = _embed("my_controller", 0, {}, null);
|
300
|
+
|
301
|
+
//Drain queue
|
302
|
+
int_dispatch([]);
|
303
|
+
|
304
|
+
//Write
|
305
|
+
vm_transaction_begin();
|
306
|
+
vm_cache_write("dummy", head_null);
|
307
|
+
vm_cache_write("dummy", head_world);
|
308
|
+
vm_transaction_end();
|
309
|
+
|
310
|
+
for (var i = 0; i < 100; ++i) {
|
311
|
+
int_dispatch([]);
|
312
|
+
}
|
313
|
+
|
314
|
+
dump.head_changed_params = head_changed_params;
|
315
|
+
dump.next_changed_params = next_changed_params;
|
316
|
+
}
|
317
|
+
|
318
|
+
expect(dump["head_changed_params"]).to eq([
|
319
|
+
{
|
320
|
+
"page_id" => "default",
|
321
|
+
"value" => "world"
|
322
|
+
},
|
323
|
+
])
|
324
|
+
end
|
325
|
+
|
326
|
+
it "does send the controller the correct events when a page is modified twice" do
|
327
|
+
ctx = flok_new_user File.read('./spec/kern/assets/vm/controller0_diff.rb'), File.read("./spec/kern/assets/vm/pg_dummy/config.rb")
|
328
|
+
reload_vm_transaction_diff_pages(ctx)
|
329
|
+
dump = ctx.evald %{
|
330
|
+
//Call embed on main root view
|
331
|
+
base = _embed("my_controller", 0, {}, null);
|
332
|
+
|
333
|
+
//Drain queue
|
334
|
+
int_dispatch([]);
|
335
|
+
|
336
|
+
//Write
|
337
|
+
vm_transaction_begin();
|
338
|
+
vm_cache_write("dummy", triangle_square_z_null);
|
339
|
+
vm_transaction_end();
|
340
|
+
|
341
|
+
vm_transaction_begin();
|
342
|
+
vm_cache_write("dummy", p_circle_null_q);
|
343
|
+
vm_transaction_end();
|
344
|
+
|
345
|
+
vm_transaction_begin();
|
346
|
+
vm_cache_write("dummy", triangle_circle_null_q);
|
347
|
+
vm_transaction_end();
|
348
|
+
|
349
|
+
for (var i = 0; i < 100; ++i) {
|
350
|
+
int_dispatch([]);
|
351
|
+
}
|
352
|
+
|
353
|
+
dump.entry_modify_params = entry_modify_params;
|
354
|
+
dump.entry_move_params = entry_move_params;
|
355
|
+
dump.entry_del_params = entry_del_params;
|
356
|
+
dump.entry_ins_params = entry_ins_params;
|
357
|
+
}
|
358
|
+
|
359
|
+
expect(dump["entry_modify_params"]).to eq([
|
360
|
+
{
|
361
|
+
"page_id" => "default",
|
362
|
+
"entry" => {"_id" => "id0", "_sig" => "P", "value" => "P"}
|
363
|
+
},
|
364
|
+
{
|
365
|
+
"page_id" => "default",
|
366
|
+
"entry" => {"_id" => "id1", "_sig" => "Circle", "value" => "Circle"}
|
367
|
+
},
|
368
|
+
{
|
369
|
+
"page_id" => "default",
|
370
|
+
"entry" => {"_id" => "id0", "_sig" => "Triangle", "value" => "Triangle"}
|
371
|
+
},
|
372
|
+
])
|
373
|
+
end
|
374
|
+
######################################################################
|
375
|
+
end
|