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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/mbt-gen.rb +97 -1
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 77cbf93998b731d074f62e0b364c20f87f324c8409e0e223193e9d8c0a0ddc52
4
- data.tar.gz: 98985c6b4ace9d25b36fc73d9110f50368bc8badff62918b52a09557c0c52bd3
3
+ metadata.gz: b4c7dc3614c0f3345b728127808e7bd517487298968c8edab06f6436b84d60c1
4
+ data.tar.gz: 780f4e406e9b84d112074106bb905e48a8eab8fac3e02936ab36f85087381c07
5
5
  SHA512:
6
- metadata.gz: aad6c3b1ea3c63b7510cfc214a020fc8cf91e8f2cb97f2da44c39543d350524a62999440c2a97ea9ecfbdc3c036365667d8853150f6eeda485bf07d464b09fa1
7
- data.tar.gz: e8d4adb8a2ea41d6a5200ca4002245afe66ab5779539567d18c206323d1c7c45226ac9273569609e2ed12ccfb3bc434c31ab8c4717bc81d639a4f1c5020cdb0f
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.10
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-01 00:00:00.000000000 Z
11
+ date: 2026-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri