mbt-gen 0.0.11 → 0.0.12
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/lib/mbt-gen.rb +75 -19
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 20bf8b787d83e3b2b6944c56c94054da7f42bd5c587bd4dd78486a2aec1acf12
|
|
4
|
+
data.tar.gz: 055a0a05ac4556b952c6746f2bf987b440b80f111f0714883958193be4254966
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c58c06320fda5aa5944b17ac9e1507f1d65ffe93810bb7c0fcb158e6e1ddb273b98ab3a47afbdbf41b9230fdf0bc2deb8a2b6b04e78bdd413e9a9876e82b40fc
|
|
7
|
+
data.tar.gz: 884f6ef5c8f134cfe401a5a46e28b92599ee86ae46adfc7ad8d30bdc1c5e1d47299ffc177774b03b230c29a63ae605196a0e551c0ad4bcebc9aae4ecee5990dd
|
data/lib/mbt-gen.rb
CHANGED
|
@@ -1029,6 +1029,10 @@ def xpath_to_filename(xpath)
|
|
|
1029
1029
|
xpath.gsub("/", "-").gsub(/\[\d*\]/) {|s| if s =~ /\[(\d*)\]/ then "-#{$1}-" else s end }
|
|
1030
1030
|
end
|
|
1031
1031
|
|
|
1032
|
+
def xpath_to_methodname(xpath)
|
|
1033
|
+
xpath.gsub("/", "_").gsub(/\[\d*\]/) {|s| if s =~ /\[(\d*)\]/ then "_#{$1}_" else s end }
|
|
1034
|
+
end
|
|
1035
|
+
|
|
1032
1036
|
def generate_equality_test_data(progress, message, output_dir, config, options)
|
|
1033
1037
|
unless Dir.exist?(output_dir)
|
|
1034
1038
|
FileUtils.mkdir_p(output_dir)
|
|
@@ -1125,18 +1129,40 @@ def generate_equality_test(message, output_filename)
|
|
|
1125
1129
|
|
|
1126
1130
|
base_filename = BASE_FILENAME
|
|
1127
1131
|
positive_tests = []
|
|
1128
|
-
positive_tests <<
|
|
1132
|
+
positive_tests << <<EOF
|
|
1133
|
+
def test_equality_positive_base()
|
|
1134
|
+
assert(equality('#{base_filename}', '#{base_filename}'), 'Equality implementation is not reflexive on file #{base_filename}')
|
|
1135
|
+
end
|
|
1136
|
+
EOF
|
|
1129
1137
|
each_structure_and_field_in(message) do |desc, xpath|
|
|
1130
1138
|
if desc[:type] == :field then
|
|
1131
|
-
positive_tests <<
|
|
1139
|
+
positive_tests << <<EOF
|
|
1140
|
+
def test_equality_positive_mutated_#{xpath_to_methodname(xpath)}()
|
|
1141
|
+
assert(equality('doc-mutated-#{xpath_to_filename(xpath)}.xml', 'doc-mutated-#{xpath_to_filename(xpath)}.xml'), 'Equality implementation is not reflexive on file doc-mutated-#{xpath_to_filename(xpath)}.xml')
|
|
1142
|
+
end
|
|
1143
|
+
EOF
|
|
1144
|
+
|
|
1132
1145
|
if desc[:optional] == true then
|
|
1133
|
-
positive_tests <<
|
|
1146
|
+
positive_tests << <<EOF
|
|
1147
|
+
def test_equality_positive_removed_#{xpath_to_methodname(xpath)}()
|
|
1148
|
+
assert(equality('doc-removed-#{xpath_to_filename(xpath)}.xml', 'doc-removed-#{xpath_to_filename(xpath)}.xml'), 'Equality implementation is not reflexive on file doc-removed-#{xpath_to_filename(xpath)}.xml')
|
|
1149
|
+
end
|
|
1150
|
+
EOF
|
|
1134
1151
|
end
|
|
1135
1152
|
elsif desc[:type] == :list then
|
|
1136
1153
|
if desc[:element] then
|
|
1137
|
-
positive_tests <<
|
|
1154
|
+
positive_tests << <<EOF
|
|
1155
|
+
def test_equality_positive_mutated_#{xpath_to_methodname(xpath)}()
|
|
1156
|
+
assert(equality('doc-mutated-#{xpath_to_filename(xpath)}.xml', 'doc-mutated-#{xpath_to_filename(xpath)}.xml'), 'Equality implementation is not reflexive on file doc-mutated-#{xpath_to_filename(xpath)}.xml')
|
|
1157
|
+
end
|
|
1158
|
+
EOF
|
|
1159
|
+
|
|
1138
1160
|
else
|
|
1139
|
-
positive_tests <<
|
|
1161
|
+
positive_tests << <<EOF
|
|
1162
|
+
def test_equality_positive_removed_#{xpath_to_methodname(xpath)}()
|
|
1163
|
+
assert(equality('doc-removed-#{xpath_to_filename(xpath)}.xml', 'doc-removed-#{xpath_to_filename(xpath)}.xml'), 'Equality implementation is not reflexive on file doc-removed-#{xpath_to_filename(xpath)}.xml')
|
|
1164
|
+
end
|
|
1165
|
+
EOF
|
|
1140
1166
|
end
|
|
1141
1167
|
elsif desc[:type] == :objlist then
|
|
1142
1168
|
if desc[:element] then
|
|
@@ -1144,11 +1170,19 @@ def generate_equality_test(message, output_filename)
|
|
|
1144
1170
|
# no additional test data neccessary as the element objects will contain fields that are modified already
|
|
1145
1171
|
else
|
|
1146
1172
|
# the list itself
|
|
1147
|
-
positive_tests <<
|
|
1173
|
+
positive_tests << <<EOF
|
|
1174
|
+
def test_equality_positive_removed_#{xpath_to_methodname(xpath)}()
|
|
1175
|
+
assert(equality('doc-removed-#{xpath_to_filename(xpath)}.xml', 'doc-removed-#{xpath_to_filename(xpath)}.xml'), 'Equality implementation is not reflexive on file doc-removed-#{xpath_to_filename(xpath)}.xml')
|
|
1176
|
+
end
|
|
1177
|
+
EOF
|
|
1148
1178
|
end
|
|
1149
1179
|
elsif desc[:type] == :structure then
|
|
1150
1180
|
if desc[:optional] == true then
|
|
1151
|
-
positive_tests <<
|
|
1181
|
+
positive_tests << <<EOF
|
|
1182
|
+
def test_equality_positive_removed_#{xpath_to_methodname(xpath)}()
|
|
1183
|
+
assert(equality('doc-removed-#{xpath_to_filename(xpath)}.xml', 'doc-removed-#{xpath_to_filename(xpath)}.xml'), 'Equality implementation is not reflexive on file doc-removed-#{xpath_to_filename(xpath)}.xml')
|
|
1184
|
+
end
|
|
1185
|
+
EOF
|
|
1152
1186
|
end
|
|
1153
1187
|
else
|
|
1154
1188
|
raise RuntimeError.new("encountered unknown :type #{desc[:type].inspect}")
|
|
@@ -1158,15 +1192,33 @@ def generate_equality_test(message, output_filename)
|
|
|
1158
1192
|
negative_tests = []
|
|
1159
1193
|
each_structure_and_field_in(message) do |desc, xpath|
|
|
1160
1194
|
if desc[:type] == :field then
|
|
1161
|
-
negative_tests <<
|
|
1195
|
+
negative_tests << <<EOF
|
|
1196
|
+
def test_equality_negative_mutated_#{xpath_to_methodname(xpath)}()
|
|
1197
|
+
assert(!equality('#{base_filename}', 'doc-mutated-#{xpath_to_filename(xpath)}.xml'), 'Equality implementation seems not to take the field #{xpath} into account. It regards the files #{base_filename} and doc-mutated-#{xpath_to_filename(xpath)}.xml as equal.')
|
|
1198
|
+
end
|
|
1199
|
+
EOF
|
|
1200
|
+
|
|
1162
1201
|
if desc[:optional] == true then
|
|
1163
|
-
negative_tests <<
|
|
1202
|
+
negative_tests << <<EOF
|
|
1203
|
+
def test_equality_negative_removed_#{xpath_to_methodname(xpath)}()
|
|
1204
|
+
assert(!equality('#{base_filename}', 'doc-removed-#{xpath_to_filename(xpath)}.xml'), 'Equality implementation seems not to take the existence of field #{xpath} into account. It regards the files #{base_filename} and doc-removed-#{xpath_to_filename(xpath)}.xml as equal.')
|
|
1205
|
+
end
|
|
1206
|
+
EOF
|
|
1164
1207
|
end
|
|
1165
1208
|
elsif desc[:type] == :list then
|
|
1166
1209
|
if desc[:element] then
|
|
1167
|
-
negative_tests <<
|
|
1210
|
+
negative_tests << <<EOF
|
|
1211
|
+
def test_equality_negative_mutated_#{xpath_to_methodname(xpath)}()
|
|
1212
|
+
assert(!equality('#{base_filename}', 'doc-mutated-#{xpath_to_filename(xpath)}.xml'), 'Equality implementation seems not to take the list #{xpath} into account. It regards the files #{base_filename} and doc-mutated-#{xpath_to_filename(xpath)}.xml as equal.')
|
|
1213
|
+
end
|
|
1214
|
+
EOF
|
|
1215
|
+
|
|
1168
1216
|
else
|
|
1169
|
-
negative_tests <<
|
|
1217
|
+
negative_tests << <<EOF
|
|
1218
|
+
def test_equality_negative_removed_#{xpath_to_methodname(xpath)}()
|
|
1219
|
+
assert(!equality('#{base_filename}', 'doc-removed-#{xpath_to_filename(xpath)}.xml'), 'Equality implementation seems not to take the existence of the list #{xpath} into account. It regards the files #{base_filename} and doc-removed-#{xpath_to_filename(xpath)}.xml as equal.')
|
|
1220
|
+
end
|
|
1221
|
+
EOF
|
|
1170
1222
|
end
|
|
1171
1223
|
elsif desc[:type] == :objlist then
|
|
1172
1224
|
if desc[:element] then
|
|
@@ -1174,11 +1226,19 @@ def generate_equality_test(message, output_filename)
|
|
|
1174
1226
|
# no additional test data neccessary as the element objects will contain fields that are modified already
|
|
1175
1227
|
else
|
|
1176
1228
|
# the list itself
|
|
1177
|
-
negative_tests <<
|
|
1229
|
+
negative_tests << <<EOF
|
|
1230
|
+
def test_equality_negative_removed_#{xpath_to_methodname(xpath)}()
|
|
1231
|
+
assert(!equality('#{base_filename}', 'doc-removed-#{xpath_to_filename(xpath)}.xml'), 'Equality implementation seems not to take the existence of objlist #{xpath} into account. It regards the files #{base_filename} and doc-removed-#{xpath_to_filename(xpath)}.xml as equal.')
|
|
1232
|
+
end
|
|
1233
|
+
EOF
|
|
1178
1234
|
end
|
|
1179
1235
|
elsif desc[:type] == :structure then
|
|
1180
1236
|
if desc[:optional] == true then
|
|
1181
|
-
negative_tests <<
|
|
1237
|
+
negative_tests << <<EOF
|
|
1238
|
+
def test_equality_negative_removed_#{xpath_to_methodname(xpath)}()
|
|
1239
|
+
assert(!equality('#{base_filename}', 'doc-removed-#{xpath_to_filename(xpath)}.xml'), 'Equality implementation seems not to take the existence of structure #{xpath} into account. It regards the files #{base_filename} and doc-removed-#{xpath_to_filename(xpath)}.xml as equal.')
|
|
1240
|
+
end
|
|
1241
|
+
EOF
|
|
1182
1242
|
end
|
|
1183
1243
|
else
|
|
1184
1244
|
raise RuntimeError.new("encountered unknown :type #{desc[:type].inspect}")
|
|
@@ -1199,13 +1259,9 @@ class EqualityTest < Test::Unit::TestCase
|
|
|
1199
1259
|
system("diff", filename1, filename2)
|
|
1200
1260
|
end
|
|
1201
1261
|
|
|
1202
|
-
|
|
1203
|
-
#{positive_tests.join("\n ")}
|
|
1204
|
-
end
|
|
1262
|
+
#{positive_tests.join("\n\n")}
|
|
1205
1263
|
|
|
1206
|
-
|
|
1207
|
-
#{negative_tests.join("\n ")}
|
|
1208
|
-
end
|
|
1264
|
+
#{negative_tests.join("\n\n")}
|
|
1209
1265
|
end
|
|
1210
1266
|
EOF
|
|
1211
1267
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mbt-gen
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.12
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- FM-enthusiast
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-09-
|
|
11
|
+
date: 2026-09-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: nokogiri
|