mbt-gen 0.0.10 → 0.0.11
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 +97 -1
- 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: b4c7dc3614c0f3345b728127808e7bd517487298968c8edab06f6436b84d60c1
|
|
4
|
+
data.tar.gz: 780f4e406e9b84d112074106bb905e48a8eab8fac3e02936ab36f85087381c07
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 05d34d034b0aa1438c15f47969d8c9bd3d61545d2c9ade72efc0edfcee081e562c9fb3cc6f421e846319bbc43c0fe426b10bf81b8030b5ff560f97942405f5b7
|
|
7
|
+
data.tar.gz: 9f7b485dc1034d0529c3b8033633a862adb30c938899cfa8ceaaab95e130a10385c7d77c9e5859d31d8f5aeedf271e742e242e8699785ba8936b67df8f8f6b17
|
data/lib/mbt-gen.rb
CHANGED
|
@@ -1116,7 +1116,103 @@ def generate_equality_test_data(progress, message, output_dir, config, options)
|
|
|
1116
1116
|
else
|
|
1117
1117
|
raise RuntimeError.new("encountered unknown :type #{desc[:type].inspect}")
|
|
1118
1118
|
end
|
|
1119
|
-
end
|
|
1119
|
+
end
|
|
1120
|
+
|
|
1121
|
+
generate_equality_test(message, "#{output_dir}/test-equality.rb")
|
|
1122
|
+
end
|
|
1123
|
+
|
|
1124
|
+
def generate_equality_test(message, output_filename)
|
|
1125
|
+
|
|
1126
|
+
base_filename = BASE_FILENAME
|
|
1127
|
+
positive_tests = []
|
|
1128
|
+
positive_tests << "assert(equality('#{base_filename}', '#{base_filename}'), 'Equality implementation is not reflexive on file #{base_filename}')"
|
|
1129
|
+
each_structure_and_field_in(message) do |desc, xpath|
|
|
1130
|
+
if desc[:type] == :field then
|
|
1131
|
+
positive_tests << "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')"
|
|
1132
|
+
if desc[:optional] == true then
|
|
1133
|
+
positive_tests << "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')"
|
|
1134
|
+
end
|
|
1135
|
+
elsif desc[:type] == :list then
|
|
1136
|
+
if desc[:element] then
|
|
1137
|
+
positive_tests << "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')"
|
|
1138
|
+
else
|
|
1139
|
+
positive_tests << "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')"
|
|
1140
|
+
end
|
|
1141
|
+
elsif desc[:type] == :objlist then
|
|
1142
|
+
if desc[:element] then
|
|
1143
|
+
# list elements
|
|
1144
|
+
# no additional test data neccessary as the element objects will contain fields that are modified already
|
|
1145
|
+
else
|
|
1146
|
+
# the list itself
|
|
1147
|
+
positive_tests << "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')"
|
|
1148
|
+
end
|
|
1149
|
+
elsif desc[:type] == :structure then
|
|
1150
|
+
if desc[:optional] == true then
|
|
1151
|
+
positive_tests << "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')"
|
|
1152
|
+
end
|
|
1153
|
+
else
|
|
1154
|
+
raise RuntimeError.new("encountered unknown :type #{desc[:type].inspect}")
|
|
1155
|
+
end
|
|
1156
|
+
end
|
|
1157
|
+
|
|
1158
|
+
negative_tests = []
|
|
1159
|
+
each_structure_and_field_in(message) do |desc, xpath|
|
|
1160
|
+
if desc[:type] == :field then
|
|
1161
|
+
negative_tests << "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.')"
|
|
1162
|
+
if desc[:optional] == true then
|
|
1163
|
+
negative_tests << "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.')"
|
|
1164
|
+
end
|
|
1165
|
+
elsif desc[:type] == :list then
|
|
1166
|
+
if desc[:element] then
|
|
1167
|
+
negative_tests << "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.')"
|
|
1168
|
+
else
|
|
1169
|
+
negative_tests << "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.')"
|
|
1170
|
+
end
|
|
1171
|
+
elsif desc[:type] == :objlist then
|
|
1172
|
+
if desc[:element] then
|
|
1173
|
+
# list elements
|
|
1174
|
+
# no additional test data neccessary as the element objects will contain fields that are modified already
|
|
1175
|
+
else
|
|
1176
|
+
# the list itself
|
|
1177
|
+
negative_tests << "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.')"
|
|
1178
|
+
end
|
|
1179
|
+
elsif desc[:type] == :structure then
|
|
1180
|
+
if desc[:optional] == true then
|
|
1181
|
+
negative_tests << "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.')"
|
|
1182
|
+
end
|
|
1183
|
+
else
|
|
1184
|
+
raise RuntimeError.new("encountered unknown :type #{desc[:type].inspect}")
|
|
1185
|
+
end
|
|
1186
|
+
end
|
|
1187
|
+
|
|
1188
|
+
|
|
1189
|
+
content = <<EOF
|
|
1190
|
+
#!/bin/ruby
|
|
1191
|
+
|
|
1192
|
+
require 'test/unit'
|
|
1193
|
+
|
|
1194
|
+
class EqualityTest < Test::Unit::TestCase
|
|
1195
|
+
|
|
1196
|
+
def equality(filename1, filename2)
|
|
1197
|
+
# TODO: call your equality implementation here.
|
|
1198
|
+
# This is just an example showing how to call an externally-provided implementation.
|
|
1199
|
+
system("diff", filename1, filename2)
|
|
1200
|
+
end
|
|
1201
|
+
|
|
1202
|
+
def test_equality_positive
|
|
1203
|
+
#{positive_tests.join("\n ")}
|
|
1204
|
+
end
|
|
1205
|
+
|
|
1206
|
+
def test_equality_negative
|
|
1207
|
+
#{negative_tests.join("\n ")}
|
|
1208
|
+
end
|
|
1209
|
+
end
|
|
1210
|
+
EOF
|
|
1211
|
+
|
|
1212
|
+
File.open(output_filename, "w") do |f|
|
|
1213
|
+
f.puts(content)
|
|
1214
|
+
end
|
|
1215
|
+
|
|
1120
1216
|
end
|
|
1121
1217
|
|
|
1122
1218
|
def generate_max_doc(progress, message, output_filename, config, options)
|
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.11
|
|
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-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: nokogiri
|