test: add failing tests for PPP variable-vs-variable comparison support
Add 4 TDD tests for the var-vs-var comparison feature (S1-TT2): - test_cmd_if_var_vs_var_eq - test_cmd_if_var_vs_var_ne - test_cmd_if_var_vs_var_contains - test_cmd_if_var_vs_var_not_contains All tests fail because the grammar only accepts SIMPLEVALUE on RHS, not IDENTIFIER. Implementation in S1-T2 will make them pass.
This commit is contained in:
@@ -1328,6 +1328,43 @@ class TestPromptPostProcessor(TestPromptPostProcessorBase):
|
||||
ppp=self.nocupppp,
|
||||
)
|
||||
|
||||
# Variable-vs-variable comparison tests
|
||||
|
||||
def test_cmd_if_var_vs_var_eq(self): # var eq var: both set to same value, if-branch taken
|
||||
self.process(
|
||||
PromptPair(
|
||||
"<ppp:set v1>hello<ppp:/set><ppp:set v2>hello<ppp:/set><ppp:if v1 eq v2>YES<ppp:else>NO<ppp:/if>",
|
||||
"",
|
||||
),
|
||||
PromptPair("YES", ""),
|
||||
)
|
||||
|
||||
def test_cmd_if_var_vs_var_ne(self): # var ne var: different values, ne condition true
|
||||
self.process(
|
||||
PromptPair(
|
||||
"<ppp:set v1>apple<ppp:/set><ppp:set v2>orange<ppp:/set><ppp:if v1 ne v2>YES<ppp:else>NO<ppp:/if>",
|
||||
"",
|
||||
),
|
||||
PromptPair("YES", ""),
|
||||
)
|
||||
|
||||
def test_cmd_if_var_vs_var_contains(self): # var contains var: var1 contains var2's value
|
||||
self.process(
|
||||
PromptPair(
|
||||
"<ppp:set v1>hello world<ppp:/set><ppp:set v2>hello<ppp:/set><ppp:if v1 contains v2>YES<ppp:else>NO<ppp:/if>",
|
||||
"",
|
||||
),
|
||||
PromptPair("YES", ""),
|
||||
)
|
||||
|
||||
def test_cmd_if_var_vs_var_not_contains(self): # var not contains var: var1 does not contain var2's value
|
||||
self.process(
|
||||
PromptPair(
|
||||
"<ppp:set v1>hello world<ppp:/set><ppp:set v2>goodbye<ppp:/set><ppp:if v1 not contains v2>YES<ppp:else>NO<ppp:/if>",
|
||||
"",
|
||||
),
|
||||
PromptPair("YES", ""),
|
||||
)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user