mbt-gen 0.0.11 → 0.0.13

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 +88 -19
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b4c7dc3614c0f3345b728127808e7bd517487298968c8edab06f6436b84d60c1
4
- data.tar.gz: 780f4e406e9b84d112074106bb905e48a8eab8fac3e02936ab36f85087381c07
3
+ metadata.gz: 112610c6e247d3de6fc7c69afc0a668659dbcffc9ee1786967bf4a69d9586520
4
+ data.tar.gz: d0eea35ebf9689ca1bead1e9efe8e8f2a96b75d45b644484875e383927dd2b91
5
5
  SHA512:
6
- metadata.gz: 05d34d034b0aa1438c15f47969d8c9bd3d61545d2c9ade72efc0edfcee081e562c9fb3cc6f421e846319bbc43c0fe426b10bf81b8030b5ff560f97942405f5b7
7
- data.tar.gz: 9f7b485dc1034d0529c3b8033633a862adb30c938899cfa8ceaaab95e130a10385c7d77c9e5859d31d8f5aeedf271e742e242e8699785ba8936b67df8f8f6b17
6
+ metadata.gz: 137856eff73bfde902b67a9bdc97426253b036a79be6d1b6e912ceaa6012a27bb27715d3de26fb75210602985b8e8bdbe6e43cf15db8edb4f931db69f9b16c5d
7
+ data.tar.gz: 37e9195a691a211aca006aef7ba57cfc5a91d46f61327acd0297385911f8d29fe4b60dcd77a3514a3b5565aff7d5517d92413e3a80005eff1b24c204bd83c87e
data/lib/mbt-gen.rb CHANGED
@@ -596,6 +596,19 @@ def translate_validation_rules_to_SMTLIB(progress, solver, struct, prefix, confi
596
596
  new_prefix = key.to_s
597
597
  end
598
598
  translate_validation_rules_to_SMTLIB(progress, solver, value[:ref], new_prefix, config, options)
599
+ elsif value[:type] == :objlist then
600
+ maxLength = value[:model_maxLength]
601
+ unless maxLength then
602
+ raise RuntimeError.new("encountered objList without :model_maxLength property!")
603
+ end
604
+ maxLength.times do |i|
605
+ if prefix then
606
+ new_prefix = "#{prefix.to_s}/#{key}/#{i}"
607
+ else
608
+ new_prefix = "#{key.to_s}/#{i}"
609
+ end
610
+ translate_validation_rules_to_SMTLIB(progress, solver, value[:ref], new_prefix, config, options)
611
+ end
599
612
  end
600
613
  end
601
614
  end
@@ -1029,6 +1042,10 @@ def xpath_to_filename(xpath)
1029
1042
  xpath.gsub("/", "-").gsub(/\[\d*\]/) {|s| if s =~ /\[(\d*)\]/ then "-#{$1}-" else s end }
1030
1043
  end
1031
1044
 
1045
+ def xpath_to_methodname(xpath)
1046
+ xpath.gsub("/", "_").gsub(/\[\d*\]/) {|s| if s =~ /\[(\d*)\]/ then "_#{$1}_" else s end }
1047
+ end
1048
+
1032
1049
  def generate_equality_test_data(progress, message, output_dir, config, options)
1033
1050
  unless Dir.exist?(output_dir)
1034
1051
  FileUtils.mkdir_p(output_dir)
@@ -1125,18 +1142,40 @@ def generate_equality_test(message, output_filename)
1125
1142
 
1126
1143
  base_filename = BASE_FILENAME
1127
1144
  positive_tests = []
1128
- positive_tests << "assert(equality('#{base_filename}', '#{base_filename}'), 'Equality implementation is not reflexive on file #{base_filename}')"
1145
+ positive_tests << <<EOF
1146
+ def test_equality_positive_base()
1147
+ assert(equality('#{base_filename}', '#{base_filename}'), 'Equality implementation is not reflexive on file #{base_filename}')
1148
+ end
1149
+ EOF
1129
1150
  each_structure_and_field_in(message) do |desc, xpath|
1130
1151
  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')"
1152
+ positive_tests << <<EOF
1153
+ def test_equality_positive_mutated_#{xpath_to_methodname(xpath)}()
1154
+ 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')
1155
+ end
1156
+ EOF
1157
+
1132
1158
  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')"
1159
+ positive_tests << <<EOF
1160
+ def test_equality_positive_removed_#{xpath_to_methodname(xpath)}()
1161
+ 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')
1162
+ end
1163
+ EOF
1134
1164
  end
1135
1165
  elsif desc[:type] == :list then
1136
1166
  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')"
1167
+ positive_tests << <<EOF
1168
+ def test_equality_positive_mutated_#{xpath_to_methodname(xpath)}()
1169
+ 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')
1170
+ end
1171
+ EOF
1172
+
1138
1173
  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')"
1174
+ positive_tests << <<EOF
1175
+ def test_equality_positive_removed_#{xpath_to_methodname(xpath)}()
1176
+ 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')
1177
+ end
1178
+ EOF
1140
1179
  end
1141
1180
  elsif desc[:type] == :objlist then
1142
1181
  if desc[:element] then
@@ -1144,11 +1183,19 @@ def generate_equality_test(message, output_filename)
1144
1183
  # no additional test data neccessary as the element objects will contain fields that are modified already
1145
1184
  else
1146
1185
  # 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')"
1186
+ positive_tests << <<EOF
1187
+ def test_equality_positive_removed_#{xpath_to_methodname(xpath)}()
1188
+ 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')
1189
+ end
1190
+ EOF
1148
1191
  end
1149
1192
  elsif desc[:type] == :structure then
1150
1193
  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')"
1194
+ positive_tests << <<EOF
1195
+ def test_equality_positive_removed_#{xpath_to_methodname(xpath)}()
1196
+ 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')
1197
+ end
1198
+ EOF
1152
1199
  end
1153
1200
  else
1154
1201
  raise RuntimeError.new("encountered unknown :type #{desc[:type].inspect}")
@@ -1158,15 +1205,33 @@ def generate_equality_test(message, output_filename)
1158
1205
  negative_tests = []
1159
1206
  each_structure_and_field_in(message) do |desc, xpath|
1160
1207
  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.')"
1208
+ negative_tests << <<EOF
1209
+ def test_equality_negative_mutated_#{xpath_to_methodname(xpath)}()
1210
+ 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.')
1211
+ end
1212
+ EOF
1213
+
1162
1214
  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.')"
1215
+ negative_tests << <<EOF
1216
+ def test_equality_negative_removed_#{xpath_to_methodname(xpath)}()
1217
+ 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.')
1218
+ end
1219
+ EOF
1164
1220
  end
1165
1221
  elsif desc[:type] == :list then
1166
1222
  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.')"
1223
+ negative_tests << <<EOF
1224
+ def test_equality_negative_mutated_#{xpath_to_methodname(xpath)}()
1225
+ 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.')
1226
+ end
1227
+ EOF
1228
+
1168
1229
  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.')"
1230
+ negative_tests << <<EOF
1231
+ def test_equality_negative_removed_#{xpath_to_methodname(xpath)}()
1232
+ 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.')
1233
+ end
1234
+ EOF
1170
1235
  end
1171
1236
  elsif desc[:type] == :objlist then
1172
1237
  if desc[:element] then
@@ -1174,11 +1239,19 @@ def generate_equality_test(message, output_filename)
1174
1239
  # no additional test data neccessary as the element objects will contain fields that are modified already
1175
1240
  else
1176
1241
  # 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.')"
1242
+ negative_tests << <<EOF
1243
+ def test_equality_negative_removed_#{xpath_to_methodname(xpath)}()
1244
+ 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.')
1245
+ end
1246
+ EOF
1178
1247
  end
1179
1248
  elsif desc[:type] == :structure then
1180
1249
  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.')"
1250
+ negative_tests << <<EOF
1251
+ def test_equality_negative_removed_#{xpath_to_methodname(xpath)}()
1252
+ 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.')
1253
+ end
1254
+ EOF
1182
1255
  end
1183
1256
  else
1184
1257
  raise RuntimeError.new("encountered unknown :type #{desc[:type].inspect}")
@@ -1199,13 +1272,9 @@ class EqualityTest < Test::Unit::TestCase
1199
1272
  system("diff", filename1, filename2)
1200
1273
  end
1201
1274
 
1202
- def test_equality_positive
1203
- #{positive_tests.join("\n ")}
1204
- end
1275
+ #{positive_tests.join("\n\n")}
1205
1276
 
1206
- def test_equality_negative
1207
- #{negative_tests.join("\n ")}
1208
- end
1277
+ #{negative_tests.join("\n\n")}
1209
1278
  end
1210
1279
  EOF
1211
1280
 
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.11
4
+ version: 0.0.13
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-03 00:00:00.000000000 Z
11
+ date: 2026-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri