nukadoko 0.5.0 → 0.7.0
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/CHANGELOG.md +553 -3
- data/README.ja.md +22 -6
- data/README.md +13 -7
- data/docs/ci.ja.md +542 -0
- data/docs/ci.md +635 -0
- data/docs/commands.ja.md +1524 -0
- data/docs/commands.md +1281 -0
- data/docs/engines.json +19 -0
- data/docs/execution-events.ja.md +336 -0
- data/docs/execution-events.md +423 -0
- data/docs/glossary.json +1348 -0
- data/docs/guide.ja.md +733 -0
- data/docs/guide.md +815 -0
- data/docs/intent.ja.md +133 -0
- data/docs/intent.md +156 -0
- data/docs/layout.ja.md +442 -0
- data/docs/layout.md +399 -0
- data/docs/releasing.ja.md +186 -0
- data/docs/releasing.md +237 -0
- data/docs/ruby/reference.ja.md +302 -0
- data/docs/ruby/reference.md +368 -0
- data/docs/spec.ja.md +8916 -0
- data/docs/spec.md +11250 -0
- data/docs/tutorial.ja.md +451 -0
- data/docs/tutorial.md +458 -0
- data/docs/typescript/adopting.ja.md +231 -0
- data/docs/typescript/adopting.md +251 -0
- data/docs/typescript/doors.ja.md +301 -0
- data/docs/typescript/doors.md +329 -0
- data/docs/typescript/migration-playwright-test.ja.md +189 -0
- data/docs/typescript/migration-playwright-test.md +212 -0
- data/docs/typescript/migration.ja.md +391 -0
- data/docs/typescript/migration.md +505 -0
- data/docs/typescript/reference.ja.md +176 -0
- data/docs/typescript/reference.md +197 -0
- data/docs/typescript/upgrading.ja.md +1774 -0
- data/docs/typescript/upgrading.md +2224 -0
- data/docs/web-app.ja.md +627 -0
- data/docs/web-app.md +659 -0
- data/docs/writing-scenarios.ja.md +544 -0
- data/docs/writing-scenarios.md +563 -0
- data/lib/nukadoko/base.rb +12 -5
- data/lib/nukadoko/changed_files.rb +95 -0
- data/lib/nukadoko/check.rb +459 -51
- data/lib/nukadoko/claim_drops.rb +271 -0
- data/lib/nukadoko/claim_line.rb +24 -4
- data/lib/nukadoko/claim_rules.rb +143 -1
- data/lib/nukadoko/claim_sides.rb +157 -9
- data/lib/nukadoko/cli.rb +403 -50
- data/lib/nukadoko/codes.json +246 -21
- data/lib/nukadoko/codes.rb +21 -4
- data/lib/nukadoko/command.rb +120 -13
- data/lib/nukadoko/command_help.rb +128 -0
- data/lib/nukadoko/compat.rb +469 -0
- data/lib/nukadoko/criteria.rb +1 -1
- data/lib/nukadoko/definition.rb +157 -7
- data/lib/nukadoko/error_frames.rb +6 -3
- data/lib/nukadoko/events/count.rb +146 -0
- data/lib/nukadoko/events/counted.rb +114 -0
- data/lib/nukadoko/events/format.rb +257 -0
- data/lib/nukadoko/events/lists.rb +154 -0
- data/lib/nukadoko/events/path.rb +285 -0
- data/lib/nukadoko/events/read.rb +284 -0
- data/lib/nukadoko/events/reader.rb +490 -0
- data/lib/nukadoko/events/selection.rb +252 -0
- data/lib/nukadoko/events/tally.rb +438 -0
- data/lib/nukadoko/features.rb +2 -2
- data/lib/nukadoko/fixtures.rb +160 -35
- data/lib/nukadoko/http_recording.rb +6 -2
- data/lib/nukadoko/intent.rb +364 -0
- data/lib/nukadoko/intent_file.rb +81 -0
- data/lib/nukadoko/intent_view.rb +190 -0
- data/lib/nukadoko/js_json.rb +2 -1
- data/lib/nukadoko/judge.rb +2 -2
- data/lib/nukadoko/judgment_file.rb +22 -1
- data/lib/nukadoko/judgments.rb +33 -3
- data/lib/nukadoko/measure_mcp.rb +202 -0
- data/lib/nukadoko/parts.rb +8 -2
- data/lib/nukadoko/path_view.rb +252 -0
- data/lib/nukadoko/place_rows.rb +161 -0
- data/lib/nukadoko/program.rb +1265 -51
- data/lib/nukadoko/program_log.rb +122 -0
- data/lib/nukadoko/program_shape.rb +385 -0
- data/lib/nukadoko/project_fixtures.rb +43 -10
- data/lib/nukadoko/project_program.rb +5 -4
- data/lib/nukadoko/repeated_prefix.rb +310 -0
- data/lib/nukadoko/report_run.rb +3 -3
- data/lib/nukadoko/run.rb +1156 -159
- data/lib/nukadoko/run_record.rb +70 -46
- data/lib/nukadoko/scaffold.rb +24 -6
- data/lib/nukadoko/schema.rb +15 -2
- data/lib/nukadoko/secrets.rb +55 -5
- data/lib/nukadoko/states.rb +478 -0
- data/lib/nukadoko/step.rb +71 -2
- data/lib/nukadoko/step_fixtures.rb +52 -3
- data/lib/nukadoko/summary.rb +803 -30
- data/lib/nukadoko/table.rb +4 -2
- data/lib/nukadoko/text_fit.rb +20 -7
- data/lib/nukadoko/trace.rb +152 -45
- data/lib/nukadoko/tree_passes.rb +95 -33
- data/lib/nukadoko/underneath.rb +311 -0
- data/lib/nukadoko/verdict.rb +18 -1
- data/lib/nukadoko/version.rb +1 -1
- data/lib/nukadoko/vocabulary.rb +166 -23
- data/lib/nukadoko/walk.rb +2 -2
- data/lib/nukadoko/walk_step.rb +1 -1
- data/lib/nukadoko.rb +23 -0
- data/llms.txt +42 -35
- data/sig/generated/nukadoko/base.rbs +4 -4
- data/sig/generated/nukadoko/changed_files.rbs +42 -0
- data/sig/generated/nukadoko/check.rbs +147 -10
- data/sig/generated/nukadoko/claim_drops.rbs +135 -0
- data/sig/generated/nukadoko/claim_line.rbs +11 -0
- data/sig/generated/nukadoko/claim_rules.rbs +49 -4
- data/sig/generated/nukadoko/claim_sides.rbs +63 -12
- data/sig/generated/nukadoko/cli.rbs +80 -7
- data/sig/generated/nukadoko/codes.rbs +19 -4
- data/sig/generated/nukadoko/command.rbs +68 -1
- data/sig/generated/nukadoko/command_help.rbs +18 -0
- data/sig/generated/nukadoko/compat.rbs +392 -0
- data/sig/generated/nukadoko/criteria.rbs +1 -1
- data/sig/generated/nukadoko/definition.rbs +50 -0
- data/sig/generated/nukadoko/error_frames.rbs +1 -1
- data/sig/generated/nukadoko/events/count.rbs +69 -0
- data/sig/generated/nukadoko/events/counted.rbs +70 -0
- data/sig/generated/nukadoko/events/format.rbs +163 -0
- data/sig/generated/nukadoko/events/lists.rbs +47 -0
- data/sig/generated/nukadoko/events/path.rbs +161 -0
- data/sig/generated/nukadoko/events/read.rbs +109 -0
- data/sig/generated/nukadoko/events/reader.rbs +226 -0
- data/sig/generated/nukadoko/events/selection.rbs +100 -0
- data/sig/generated/nukadoko/events/tally.rbs +227 -0
- data/sig/generated/nukadoko/features.rbs +6 -4
- data/sig/generated/nukadoko/fixtures.rbs +67 -11
- data/sig/generated/nukadoko/http_recording.rbs +1 -1
- data/sig/generated/nukadoko/intent.rbs +132 -0
- data/sig/generated/nukadoko/intent_file.rbs +46 -0
- data/sig/generated/nukadoko/intent_view.rbs +69 -0
- data/sig/generated/nukadoko/judgment_file.rbs +7 -1
- data/sig/generated/nukadoko/judgments.rbs +10 -0
- data/sig/generated/nukadoko/measure_mcp.rbs +104 -0
- data/sig/generated/nukadoko/parts.rbs +2 -2
- data/sig/generated/nukadoko/path_view.rbs +105 -0
- data/sig/generated/nukadoko/place_rows.rbs +43 -0
- data/sig/generated/nukadoko/program.rbs +627 -23
- data/sig/generated/nukadoko/program_log.rbs +67 -0
- data/sig/generated/nukadoko/program_shape.rbs +147 -0
- data/sig/generated/nukadoko/project_fixtures.rbs +16 -3
- data/sig/generated/nukadoko/project_program.rbs +2 -1
- data/sig/generated/nukadoko/repeated_prefix.rbs +172 -0
- data/sig/generated/nukadoko/report_run.rbs +1 -1
- data/sig/generated/nukadoko/run.rbs +286 -41
- data/sig/generated/nukadoko/run_record.rbs +20 -12
- data/sig/generated/nukadoko/scaffold.rbs +3 -0
- data/sig/generated/nukadoko/schema.rbs +5 -0
- data/sig/generated/nukadoko/secrets.rbs +26 -3
- data/sig/generated/nukadoko/states.rbs +214 -0
- data/sig/generated/nukadoko/step.rbs +58 -1
- data/sig/generated/nukadoko/step_fixtures.rbs +39 -0
- data/sig/generated/nukadoko/summary.rbs +256 -2
- data/sig/generated/nukadoko/table.rbs +3 -2
- data/sig/generated/nukadoko/trace.rbs +108 -33
- data/sig/generated/nukadoko/tree_passes.rbs +36 -8
- data/sig/generated/nukadoko/underneath.rbs +141 -0
- data/sig/generated/nukadoko/verdict.rbs +8 -0
- data/sig/generated/nukadoko/vocabulary.rbs +45 -6
- data/skills/nukadoko/SKILL.md +18 -18
- data/skills/nukadoko/references/checking-steps.md +16 -83
- data/skills/nukadoko/references/diagnosing.md +6 -6
- data/skills/nukadoko/references/done.md +22 -0
- data/skills/nukadoko/references/evidence.md +19 -6
- data/skills/nukadoko/references/exploring.md +22 -7
- data/skills/nukadoko/references/fixtures.md +12 -32
- data/skills/nukadoko/references/judgments.md +18 -0
- data/skills/nukadoko/references/maintenance.md +1 -1
- data/skills/nukadoko/references/merge-risk.md +1 -1
- data/skills/nukadoko/references/parts.md +46 -23
- data/skills/nukadoko/references/{perturbed-worlds.md → perturbed-systems.md} +30 -12
- data/skills/nukadoko/references/program.md +168 -169
- data/skills/nukadoko/references/reviewing.md +20 -20
- data/skills/nukadoko/references/ruby/checking-steps.md +106 -0
- data/skills/nukadoko/references/ruby/examples/cli.md +212 -0
- data/skills/nukadoko/references/ruby/fixtures.md +34 -0
- data/skills/nukadoko/references/ruby/program.md +112 -0
- data/skills/nukadoko/references/ruby/step-files.md +115 -0
- data/skills/nukadoko/references/running.md +34 -34
- data/skills/nukadoko/references/scenario-rules.md +7 -6
- data/skills/nukadoko/references/states.md +7 -1
- data/skills/nukadoko/references/step-files.md +41 -120
- data/skills/nukadoko/references/typescript/checking-steps.md +129 -0
- data/skills/nukadoko/references/{examples → typescript/examples}/cli.md +1 -1
- data/skills/nukadoko/references/{examples → typescript/examples}/http-api.md +6 -6
- data/skills/nukadoko/references/{examples → typescript/examples}/workflow.md +1 -1
- data/skills/nukadoko/references/typescript/fixtures.md +56 -0
- data/skills/nukadoko/references/typescript/program.md +111 -0
- data/skills/nukadoko/references/typescript/step-files.md +104 -0
- data/skills/nukadoko/references/verdicts.md +10 -10
- data/skills/nukadoko/references/writing-steps.md +67 -67
- data/skills/nukadoko/references/writing-the-feature.md +1 -1
- data/skills/nukadoko-verification/SKILL.md +13 -8
- metadata +103 -7
- data/skills/nukadoko/references/ruby.md +0 -80
data/lib/nukadoko/claim_sides.rb
CHANGED
|
@@ -44,13 +44,23 @@ module Nukadoko
|
|
|
44
44
|
# Why a claim cannot compare with an args key, for each key the
|
|
45
45
|
# matched pattern fills with a parameter type that has a transformer.
|
|
46
46
|
:transformed, #: Hash[String, String]
|
|
47
|
+
# Each files key: the list read from an earlier step's record
|
|
48
|
+
# (`label`, `paths`, `measured`), or why there is none (`unjudged`).
|
|
49
|
+
:files, #: Hash[String, Hash[Symbol, untyped]]
|
|
50
|
+
# Each events key: the reading of an earlier step's execution events
|
|
51
|
+
# (`label`, `of`, `reading`, `counted`, `left_out`), or why there is
|
|
52
|
+
# none (`broken`, `unjudged`).
|
|
53
|
+
:events, #: Hash[String, Hash[Symbol, untyped]]
|
|
54
|
+
# Each from key the claims read, with the step that gave it, the key
|
|
55
|
+
# of its result, and what its returns dropped there.
|
|
56
|
+
:from_drops, #: Hash[String, Hash[Symbol, untyped]]
|
|
47
57
|
)
|
|
48
58
|
|
|
49
59
|
# A Data block's methods are its own, but rbs-inline reads only a class
|
|
50
60
|
# body, so they are written in one.
|
|
51
61
|
class Inputs
|
|
52
|
-
#: (?transformed: Hash[String, String], **untyped) -> void
|
|
53
|
-
def initialize(transformed: {}, **rest) = super
|
|
62
|
+
#: (?transformed: Hash[String, String], ?files: Hash[String, Hash[Symbol, untyped]], ?events: Hash[String, Hash[Symbol, untyped]], ?from_drops: Hash[String, Hash[Symbol, untyped]], **untyped) -> void
|
|
63
|
+
def initialize(transformed: {}, files: {}, events: {}, from_drops: {}, **rest) = super
|
|
54
64
|
end
|
|
55
65
|
|
|
56
66
|
#: (Place, String?) -> Place
|
|
@@ -259,6 +269,30 @@ module Nukadoko
|
|
|
259
269
|
[side_of(read, base, rest, skip), at_read]
|
|
260
270
|
end
|
|
261
271
|
|
|
272
|
+
# The args path of the value a claim's actual reads, or nil for a
|
|
273
|
+
# value no earlier step returned: one observe returned, or one a path
|
|
274
|
+
# with an empty part names, which reads nothing.
|
|
275
|
+
#: (Hash[Symbol, untyped], Inputs) -> Array[String]?
|
|
276
|
+
def self.value_path(claim, inputs)
|
|
277
|
+
text = claim[:actual].to_s
|
|
278
|
+
path = segments(text)
|
|
279
|
+
return nil unless path.size == text.split(".", -1).size
|
|
280
|
+
return nil unless inputs.from_keys.include?(path.first) || !inputs.observes
|
|
281
|
+
|
|
282
|
+
claim[:view].nil? && claim[:at] ? path + claim[:at].to_s.split(".") : path
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
# The args path of the value one item claim reads inside item `index`
|
|
286
|
+
# of the array at `array_path`.
|
|
287
|
+
#: (Array[String]?, Integer, Hash[Symbol, untyped]) -> Array[String]?
|
|
288
|
+
def self.item_path(array_path, index, entry)
|
|
289
|
+
return nil if array_path.nil?
|
|
290
|
+
|
|
291
|
+
path = entry[:actual] ? segments(entry[:actual].to_s) : []
|
|
292
|
+
inside = entry[:view].nil? && entry[:at] ? path + entry[:at].to_s.split(".") : path
|
|
293
|
+
[*array_path, index.to_s, *inside]
|
|
294
|
+
end
|
|
295
|
+
|
|
262
296
|
# The value after a view, or why the view could not read it.
|
|
263
297
|
#: (String?, untyped) -> Hash[Symbol, untyped]
|
|
264
298
|
def self.apply_view(view, value)
|
|
@@ -354,16 +388,24 @@ module Nukadoko
|
|
|
354
388
|
# A top-level comparison claim, judged as Claims.judge_one reports one.
|
|
355
389
|
#: (Hash[Symbol, untyped], Inputs) -> Hash[Symbol, untyped]
|
|
356
390
|
def self.judge(claim, inputs)
|
|
391
|
+
events = inputs.events[claim[:actual].to_s]
|
|
392
|
+
return judge_events(claim, events, inputs) if events
|
|
393
|
+
|
|
394
|
+
files = inputs.files[claim[:actual].to_s]
|
|
395
|
+
return judge_files(claim, files, inputs) if files
|
|
396
|
+
|
|
357
397
|
raw, at_read = top_side(claim, inputs)
|
|
358
|
-
judge_comparison(claim, raw, inputs, at_read)
|
|
398
|
+
judge_comparison(claim, raw, inputs, at_read, value_path: value_path(claim, inputs))
|
|
359
399
|
rescue StandardError => e
|
|
360
400
|
unjudgeable(claim, e)
|
|
361
401
|
end
|
|
362
402
|
|
|
363
403
|
# One comparison on a side already read: a top-level claim's, or one
|
|
364
|
-
# item's under an each.
|
|
365
|
-
|
|
366
|
-
|
|
404
|
+
# item's under an each. `value_path` is the args path of the actual
|
|
405
|
+
# value before a view and a count, and `where` marks a where clause,
|
|
406
|
+
# whose broken outcome decides which items an each selects.
|
|
407
|
+
#: (Hash[Symbol, untyped], Side, Inputs, ?bool, ?value_path: Array[String]?, ?where: bool) -> Hash[Symbol, untyped]
|
|
408
|
+
def self.judge_comparison(claim, raw, inputs, at_read = false, value_path: nil, where: false)
|
|
367
409
|
expected, from_observe = expected_side(claim, inputs)
|
|
368
410
|
actual = counted(shaped(raw, claim[:view], claim[:at], at_read), claim[:count])
|
|
369
411
|
base = { **(actual.found.key?(:value) ? { actual: actual.found[:value] } : {}), compare: claim[:compare],
|
|
@@ -373,12 +415,106 @@ module Nukadoko
|
|
|
373
415
|
return base.merge(holds: true, for_judgment: true) if claim[:compare] == "judged-as"
|
|
374
416
|
|
|
375
417
|
result = Claims.compare(claim[:compare], actual.found[:value], expected.found[:value])
|
|
418
|
+
if result.key?(:holds)
|
|
419
|
+
changed = dropped_change(claim, result[:holds] == true, actual, expected, inputs, value_path, where)
|
|
420
|
+
return base.merge(holds: false, reason: changed, unjudged: true) if changed
|
|
421
|
+
end
|
|
376
422
|
base.merge(holds: result[:holds] == true, **(result[:reason] ? { reason: result[:reason] } : {}),
|
|
377
423
|
**(result[:stopped] ? { reason: result[:stopped], unjudged: true } : {}))
|
|
378
424
|
rescue StandardError => e
|
|
379
425
|
unjudgeable(claim, e)
|
|
380
426
|
end
|
|
381
427
|
|
|
428
|
+
# Why a comparison may have come out otherwise on the values the
|
|
429
|
+
# steps returned, before a returns schema dropped keys of them, or
|
|
430
|
+
# nil. A view or a count makes a value of its own, which no returns
|
|
431
|
+
# parsed, so neither side carries a path then.
|
|
432
|
+
#: (Hash[Symbol, untyped], bool, Side, Side, Inputs, Array[String]?, bool) -> String?
|
|
433
|
+
def self.dropped_change(claim, holds, actual, expected, inputs, value_path, where)
|
|
434
|
+
actual_side = ClaimDrops.side(actual.place, claim[:view].nil? && claim[:count] != true ? value_path : nil, inputs.from_drops)
|
|
435
|
+
expected_side = ClaimDrops.side(expected.place, claim[:expected_view].nil? ? expected_path(claim) : nil, inputs.from_drops)
|
|
436
|
+
ClaimDrops.change(claim[:compare].to_s, holds, { value: actual.found[:value], side: actual_side },
|
|
437
|
+
{ value: expected.found[:value], side: expected_side }, where)
|
|
438
|
+
end
|
|
439
|
+
|
|
440
|
+
# The args path of a claim's expected value, or nil for one the line
|
|
441
|
+
# states or observe returned.
|
|
442
|
+
#: (Hash[Symbol, untyped]) -> Array[String]?
|
|
443
|
+
def self.expected_path(claim)
|
|
444
|
+
case claim[:expected]
|
|
445
|
+
in String => key then [key]
|
|
446
|
+
in { from: String => key } then segments(key)
|
|
447
|
+
else nil
|
|
448
|
+
end
|
|
449
|
+
end
|
|
450
|
+
|
|
451
|
+
# A claim on a files key reads the list nukadoko made from an earlier
|
|
452
|
+
# step's record, never what observe returned: a key observe returns
|
|
453
|
+
# under the same name breaks the claim, so each name has one source.
|
|
454
|
+
#: (Hash[Symbol, untyped], Hash[Symbol, untyped], Inputs) -> Hash[Symbol, untyped]
|
|
455
|
+
def self.judge_files(claim, files, inputs)
|
|
456
|
+
key = claim[:actual].to_s
|
|
457
|
+
observed = inputs.observed
|
|
458
|
+
if inputs.observes && observed.is_a?(Hash) && (observed.key?(key) || observed.key?(key.to_sym))
|
|
459
|
+
return { compare: claim[:compare], holds: false,
|
|
460
|
+
reason: %(observe returned "#{key}", and files has a key of the same name, so actual "#{key}" reads the paths an earlier step's commands changed and never what observe returned. ) +
|
|
461
|
+
"Rename the key observe returns, or the files key, so each name has one source" }
|
|
462
|
+
end
|
|
463
|
+
|
|
464
|
+
place = Place.new(origin: "files:#{key}", segments: [], label: files[:label], open: false)
|
|
465
|
+
found = files[:paths] ? { value: files[:paths] } : { unjudged: files[:unjudged] }
|
|
466
|
+
judged = judge_comparison(claim, Side.new(place: place, found: found), inputs)
|
|
467
|
+
files[:paths] ? judged.merge(files_read: true) : judged
|
|
468
|
+
end
|
|
469
|
+
|
|
470
|
+
# A claim on an events key: the range the step read against the
|
|
471
|
+
# expected number. `actual` is the count when the range is one number,
|
|
472
|
+
# and `actual_range` the range otherwise, with the lines it counted,
|
|
473
|
+
# and those it left out, beside it. A key observe returns under the
|
|
474
|
+
# same name breaks the claim, so each name has one source.
|
|
475
|
+
#: (Hash[Symbol, untyped], Hash[Symbol, untyped], Inputs) -> Hash[Symbol, untyped]
|
|
476
|
+
def self.judge_events(claim, side, inputs)
|
|
477
|
+
key = claim[:actual].to_s
|
|
478
|
+
observed = inputs.observed
|
|
479
|
+
if inputs.observes && observed.is_a?(Hash) && (observed.key?(key) || observed.key?(key.to_sym))
|
|
480
|
+
return { compare: claim[:compare], holds: false,
|
|
481
|
+
reason: %(observe returned "#{key}", and events has a key of the same name, so actual "#{key}" reads the count of execution events and never what observe returned. ) +
|
|
482
|
+
"Rename the key observe returns, or the events key, so each name has one source" }
|
|
483
|
+
end
|
|
484
|
+
|
|
485
|
+
expected, from_observe = expected_side(claim, inputs)
|
|
486
|
+
range = side.dig(:reading, :range)
|
|
487
|
+
base = { **(range.nil? ? {} : range[:at_most] == range[:at_least] ? { actual: range[:at_least] } : { actual_range: range.dup }),
|
|
488
|
+
**side.slice(:counted, :left_out), compare: claim[:compare], **(expected.found.key?(:value) ? { expected: expected.found[:value] } : {}) }
|
|
489
|
+
return base.merge(holds: false, reason: side[:broken]) if side[:broken]
|
|
490
|
+
return base.merge(holds: false, reason: side[:unjudged], unjudged: true) if side[:unjudged]
|
|
491
|
+
|
|
492
|
+
stop = if expected.found[:broken] then { broken: expected.found[:broken] }
|
|
493
|
+
elsif expected.found[:unjudged] then { unjudged: expected.found[:unjudged] }
|
|
494
|
+
else observe_received(expected.place, inputs, "the expected value reads")
|
|
495
|
+
end
|
|
496
|
+
if stop.nil? && from_observe && [true, false].include?(expected.found[:value])
|
|
497
|
+
stop = { broken: "the expected value #{expected.place.label} is a boolean observe computed, which is a judgment made in code: " \
|
|
498
|
+
"return the thing measured and let the claim compare it" }
|
|
499
|
+
end
|
|
500
|
+
return base.merge(holds: false, reason: stop[:broken] || stop[:unjudged], **(stop[:unjudged] ? { unjudged: true } : {})) if stop
|
|
501
|
+
|
|
502
|
+
value = expected.found[:value]
|
|
503
|
+
unless Events::Count::COMPARES.include?(claim[:compare])
|
|
504
|
+
return base.merge(holds: false, reason: "a count of execution events is a number, and #{claim[:compare]} does not compare two numbers")
|
|
505
|
+
end
|
|
506
|
+
unless value.is_a?(Numeric) && value.finite?
|
|
507
|
+
return base.merge(holds: false, reason: "the expected value #{expected.place.label} is #{article(Claims.json_type(value))}, and a count of execution events is compared with a number")
|
|
508
|
+
end
|
|
509
|
+
|
|
510
|
+
judgment = Events::Count.judge(side[:reading], claim[:compare], value, side[:of])
|
|
511
|
+
case judgment[:outcome]
|
|
512
|
+
when :held then base.merge(holds: true, events_read: true)
|
|
513
|
+
when :broken then base.merge(holds: false, events_read: true)
|
|
514
|
+
else base.merge(holds: false, reason: judgment[:reason], unjudged: true, events_read: true)
|
|
515
|
+
end
|
|
516
|
+
end
|
|
517
|
+
|
|
382
518
|
#: (Hash[Symbol, untyped], StandardError) -> Hash[Symbol, untyped]
|
|
383
519
|
def self.unjudgeable(claim, error)
|
|
384
520
|
{ compare: claim[:compare], holds: false, reason: "nukadoko could not judge this claim: #{error.message}", unjudged: true }
|
|
@@ -390,6 +526,11 @@ module Nukadoko
|
|
|
390
526
|
raw, at_read = top_side(claim, inputs)
|
|
391
527
|
shaped(raw, claim[:view], claim[:at], at_read)
|
|
392
528
|
end
|
|
529
|
+
|
|
530
|
+
# The args path of the array an each reads, or nil: after a view, the
|
|
531
|
+
# items are values of the view's own, which no returns parsed.
|
|
532
|
+
#: (Hash[Symbol, untyped], Inputs) -> Array[String]?
|
|
533
|
+
def self.array_path(claim, inputs) = claim[:view] ? nil : value_path(claim, inputs)
|
|
393
534
|
|
|
394
535
|
# The side an item claim reads: the item, or a path inside it. The item
|
|
395
536
|
# is part of a snapshot, so a read inside it finds a value or nothing.
|
|
@@ -400,14 +541,21 @@ module Nukadoko
|
|
|
400
541
|
end
|
|
401
542
|
|
|
402
543
|
# What ends an each before any item: a declaration whose expected value
|
|
403
|
-
# observe received, or reads through
|
|
404
|
-
# received the array, does not
|
|
405
|
-
# would hide it. Then a where
|
|
544
|
+
# a transformer made, one observe received, or one that reads through
|
|
545
|
+
# what observe returned while observe received the array, does not
|
|
546
|
+
# depend on an item, and an empty array would hide it. Then a where
|
|
547
|
+
# clause that implies an item claim.
|
|
406
548
|
#: (Hash[Symbol, untyped], Place, Inputs) -> Hash[Symbol, String]?
|
|
407
549
|
def self.each_stop(claim, array, inputs)
|
|
408
550
|
entries = (claim[:each][:where] || []).each_with_index.map { ["each.where[#{_2}]", _1] } +
|
|
409
551
|
claim[:each][:claims].each_with_index.map { ["each.claims[#{_2}]", _1] }
|
|
410
552
|
entries.each do |label, entry|
|
|
553
|
+
# The whole each, not the one item: the reason is the same on every
|
|
554
|
+
# item, and a claim nothing was judged for says so once.
|
|
555
|
+
key = entry[:expected]
|
|
556
|
+
reason = key.is_a?(String) ? inputs.transformed[key] : nil
|
|
557
|
+
return { unjudged: "#{label}: #{reason}" } if reason
|
|
558
|
+
|
|
411
559
|
expected, from_observe = expected_side(entry, inputs)
|
|
412
560
|
stop = observe_received(expected.place, inputs, "#{label}'s expected value reads")
|
|
413
561
|
stop ||= observe_received(array, inputs, "#{label} reads each item of") if from_observe
|