run.sh 4.71 KB
Newer Older
1
#!/usr/bin/env bash
2
3


4
5
6
7
8
9
10
####################
# common script init
if ! test -r ../utils.sh; then
	echo "run executable from its own directory: $0"; exit 1; fi
. ../utils.sh
Z="`detect_zenroom_path` `detect_zenroom_conf`"
####################
11

12
cat <<EOF | zexe array_32_256.zen > arr.json
13
rule output encoding url64
14
15
16
17
18
19
Given nothing
When I create the array of '32' random objects of '256' bits
and I rename the 'array' to 'bonnetjes'
Then print the 'bonnetjes'
EOF

20
cat <<EOF | zexe array_rename_remove.zen -a arr.json
21
22
rule input encoding url64
rule output encoding hex
Jaromil's avatar
Jaromil committed
23
Given I have a 'url64 array' named 'bonnetjes'
Jaromil's avatar
Jaromil committed
24
When I pick the random object in 'bonnetjes'
25
and I rename the 'random object' to 'lucky one'
Jaromil's avatar
Jaromil committed
26
and I remove the 'lucky one' from 'bonnetjes'
27
# redundant check
Jaromil's avatar
Jaromil committed
28
and the 'lucky one' is not found in 'bonnetjes'
29
30
31
Then print the 'lucky one'
EOF

32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# cat <<EOF | zexe array_hashtopoint.zen -a arr.json > ecp.json
# rule input encoding url64
# rule output encoding url64
# Given I have a 'array' named 'bonnetjes'
# When I create the hash to point 'ECP' of each object in 'bonnetjes'
# # When for each x in 'bonnetjes' create the of 'ECP.hashtopoint(x)'
# Then print the 'hashes'
# EOF

# cat <<EOF | zexe array_ecp_check.zen -a arr.json -k ecp.json > hashes.json
# rule input encoding url64
# rule output encoding url64
# Given I have a 'array' named 'bonnetjes'
# and I have a 'ecp array' named 'hashes'
# # When I pick the random object in array 'hashes'
# # and I remove the 'random object' from array 'hashes'
# When for each x in 'hashes' y in 'bonnetjes' is true 'x == ECP.hashtopoint(y)'
# Then print the 'hashes'
# EOF
# # 'x == ECP.hashtopoint(y)'
52
53


54
cat <<EOF | zexe left_array_from_hash.zen -a arr.json > left_arr.json
55
56
rule input encoding url64
rule output encoding url64
Jaromil's avatar
Jaromil committed
57
Given I have a 'url64 array' named 'bonnetjes'
58
59
When I create the hashes of each object in 'bonnetjes'
and rename the 'hashes' to 'left array'
60
Then print the 'left array'
61
EOF
62
63
64
65
66


cat <<EOF | zexe right_array_from_hash.zen -a arr.json > right_arr.json
rule input encoding url64
rule output encoding url64
Jaromil's avatar
Jaromil committed
67
Given I have a 'url64 array' named 'bonnetjes'
68
69
When I create the hashes of each object in 'bonnetjes'
and rename the 'hashes' to 'right array'
70
71
72
73
74
75
76
77
Then print the 'right array'
EOF

# comparison

cat <<EOF | zexe array_comparison.zen -a left_arr.json -k right_arr.json
rule input encoding url64
rule output encoding url64
Jaromil's avatar
Jaromil committed
78
79
Given I have a 'url64 array' named 'left array'
and I have a 'url64 array' named 'right array'
80
81
82
83
When I verify 'left array' is equal to 'right array'
Then print 'OK'
EOF

84
85
86
cat <<EOF | zexe array_remove_object.zen -a arr.json > right_arr.json
rule input encoding url64
rule output encoding url64
Jaromil's avatar
Jaromil committed
87
Given I have a 'url64 array' named 'bonnetjes'
88
When I pick the random object in 'bonnetjes'
89
and I remove 'random object' from 'bonnetjes'
90
91
92
93
94
95
96
97
98
and I create the hashes of each object in 'bonnetjes'
and rename the 'hashes' to 'right array'
Then print the 'right array'
EOF

# verify that arrays are not equal
cat <<EOF | zexe array_not_comparison.zen -a left_arr.json -k right_arr.json
rule input encoding url64
rule output encoding url64
Jaromil's avatar
Jaromil committed
99
100
Given I have a 'url64 array' named 'left array'
and I have a 'url64 array' named 'right array'
101
102
103
When I verify 'left array' is not equal to 'right array'
Then print 'OK'
EOF
104
105


106
107
# 'x == ECP.hashtopoint(y)'

108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
cat <<EOF > nesting.json
{
  "first" : { "inside" : "first.inside" },
  "second" : { "inside" : "second.inside" },
  "third" : "three"
}
EOF

cat <<EOF | zexe pick_nested.zen -a nesting.json
rule check version 1.0.0
rule input encoding string
Given I have a 'string' named 'inside' inside 'first'
and I have a 'string' named 'third'
When I write string 'first.inside' in 'test'
and I write string 'three' in 'tertiur'
and I verify 'third' is equal to 'tertiur'
Then print the 'test' as 'string'
EOF

cat <<EOF | zexe random_from_array.zen
rule check version 1.0.0
Given nothing
When I create the array of '32' random objects of '256' bits
and I pick the random object in 'array'
132
and I remove 'random object' from 'array'
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
and the 'random object' is not found in 'array'
Then print the 'random object'
EOF

cat <<EOF | zexe leftmost_split.zen
rule check version 1.0.0
Given nothing
When I set 'whole' to 'Zenroom works great' as 'string'
and I split the leftmost '3' bytes of 'whole'
Then print the 'leftmost' as 'string'
and print the 'whole' as 'string'
EOF

cat <<EOF | zexe random_numbers.zen | tee array_random_nums.json
Given nothing
When I create the array of '64' random numbers
Then print the 'array' as 'number'
EOF

152

153
154
155
156
157
158
159
cat <<EOF | zexe random_numbers.zen | tee array_random_nums.json
Given nothing
When I create the array of '64' random numbers modulo '100'
and I create the aggregation of array 'array'
Then print the 'array' as 'number'
and print the 'aggregation' as 'number'
EOF
Jaromil's avatar
Jaromil committed
160
161
162

success