tinymux/testcases/trigger_cmd.mux
Stephen Dennis 66f5255433 tests: convert lambda and command-test hash pins to semantic assertions (#755)
41 more pins gone across seven files. Every preimage was recovered and
verified by hashing the candidate locally before substituting:

- lambda_fn: all values derivable from the lambda semantics
  (map +1 over 1..5 is "2 3 4 5 6", fold add is 15, ulambda mul(6,7)
  and u(#apply/inc,41) are both sha1("42"), the empty-lambda result is
  the sha1 of the empty string - now asserted via strlen)
- if/switch/wait/trigger/dolist_cmd: the pinned tcNNN_result values
  were the strings the tests themselves set ("true", "matched",
  "untouched", "AB" from @switch's match-all default, "Hello World"
  from #$ substitution, "alpha bravo charlie" from %0 %1 %2 and ##)
- oemit_fn: both pins were sha1("") - oemit returns nothing - now
  asserted via strlen

Failure messages echo the actual value instead of %q0's hash.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-12 18:54:19 -06:00

119 lines
2.5 KiB
Text

#
# trigger_cmd.mux - Test Cases for @trigger command.
#
@create test_trigger_cmd
-
@set test_trigger_cmd=INHERIT QUIET
-
#
# Beginning of Test Cases
#
&tr.tc000 test_trigger_cmd=
@log smoke=Beginning @trigger command test cases.
-
#
# Test Case #1 - Basic @trigger executes attribute.
#
&tr.helper1 test_trigger_cmd=
&tc001_result me=triggered
-
&tr.tc001 test_trigger_cmd=
&tc001_result me=;
@trig me/tr.helper1;
@wait 0.1=
{
@if strmatch([get(me/tc001_result)], triggered)=
{
@log smoke=TC001: trigger basic. Succeeded.
},
{
@log smoke=TC001: trigger basic. Failed (actual=.[get(me/tc001_result)].).
}
}
-
#
# Test Case #2 - @trigger passes %0 argument.
#
&tr.helper2 test_trigger_cmd=
&tc002_result me=%0
-
&tr.tc002 test_trigger_cmd=
&tc002_result me=;
@trig me/tr.helper2=hello;
@wait 0.1=
{
@if strmatch([get(me/tc002_result)], hello)=
{
@log smoke=TC002: trigger with %0. Succeeded.
},
{
@log smoke=TC002: trigger with %0. Failed (actual=.[get(me/tc002_result)].).
}
}
-
#
# Test Case #3 - @trigger passes multiple args (%0-%2).
#
&tr.helper3 test_trigger_cmd=
&tc003_result me=%0 %1 %2
-
&tr.tc003 test_trigger_cmd=
&tc003_result me=;
@trig me/tr.helper3=alpha,bravo,charlie;
@wait 0.1=
{
@if strmatch([get(me/tc003_result)], alpha bravo charlie)=
{
@log smoke=TC003: trigger multiple args. Succeeded.
},
{
@log smoke=TC003: trigger multiple args. Failed (actual=.[get(me/tc003_result)].).
}
}
-
#
# Test Case #4 - @trigger/now executes inline (result visible
# immediately without @wait).
#
&tr.helper4 test_trigger_cmd=
&tc004_result me=inline
-
&tr.tc004 test_trigger_cmd=
&tc004_result me=;
@trig/now me/tr.helper4;
@if strmatch([get(me/tc004_result)], inline)=
{
@log smoke=TC004: trigger/now inline. Succeeded.
},
{
@log smoke=TC004: trigger/now inline. Failed (actual=.[get(me/tc003_result)].).
}
-
#
# Test Case #5 - @trigger nonexistent attribute does nothing.
#
&tr.tc005 test_trigger_cmd=
&tc005_result me=untouched;
@trig me/tr.nosuchattr;
@wait 0.1=
{
@if strmatch([get(me/tc005_result)], untouched)=
{
@log smoke=TC005: trigger nonexistent attr. Succeeded.;
@trig me/tr.done
},
{
@log smoke=TC005: trigger nonexistent attr. Failed (actual=.[get(me/tc003_result)].).;
@trig me/tr.done
}
}
-
&tr.done test_trigger_cmd=
@log smoke=End @trigger command test cases.;
@notify smoke
-
drop test_trigger_cmd
-
#
# End of Test Cases
#