spoofax_prop/test/manual-suite.spt

73 lines
3.0 KiB
Cheetah

/** md
Title: The Remaining Tests
## Programmable Rewriting strategies
The manual then begins to discuss "programmable rewriting strategies" in
[Section 5.2](http://www.metaborg.org/en/latest/source/langdev/meta/lang/stratego/strategoxt/05-rewriting-strategies.html#programmable-rewriting-strategies)
and beyond to show how to use Stratego's various features to overcome the
difficulties with the last several examples.
The next example is in Section 5.3.1, which shows a unified treatment of
disjunctive and conjunctive normal forms that avoids the potential combinatorial
explosion of rules seen in the functionalized example. As usual, the example
Stratego module `prop-laws` is in `trans/prop-laws.str` and included in
`trans/spoofax_propositional_language.str`. Also as typical, some of the identifiers
in the module had to be changed to avoid namespace conflicts when they are all
imported into the main language module.
But after going through the previous examples, it seems that trying them is most
convenient with the Spoofax Testing Language:
* No glue transformation is needed and no ESV files need to be modified.
* It's not necessary to place the SPL expression to be tested in a separate file.
* The SPL expression, name of strategy to run, and results of that run are all
kept together (in the `test/manual-suite.spt` file).
Hence, the test cases for Section 5.3.1 and beyond, through the end of the
Tutorial/Reference Manual, are captured in this repository solely in terms
of SPT Test Cases. You can of course clone the repository and create menu items
for any of them if you want to try them that way. Just remember to add a
"glue" strategy for them as shown in the [first example](../trans/prop-eval-rules.md).
Hopefully these examples are helpful to your exploration and understanding of
Stratego -- certainly creating them was to mine.
**/
module manual-suite
language Spoofax-Propositional-Language
test sec4_2_test3 [[
(r -> p & q) & p
]] run dnf to Atom("x")
test sec4_2_test3_ex [[
(r -> p & q) & p
]] run dnf to Or(And(Not(Atom("r")),Atom("p")),And(And(Atom("p"),Atom("q")),Atom("p")))
test sec5_1_2_test1_ex [[
(r -> p & q) & p
]] run dnf3 to Or(And(Not(Atom("r")),Atom("p")),And(And(Atom("p"),Atom("q")),Atom("p")))
test sec5_1_2_test1_cnf_ex [[
(r -> p & q) & p
]] run cnf3 to And(And(Or(Not(Atom("r")), Atom("p")),
Or(Not(Atom("r")), Atom("q"))),
Atom("p"))
test sec5_1_2_test1_both_ex [[
(r -> p & q) & p
]] run dcnf to (Or(And(Not(Atom("r")),Atom("p")),And(And(Atom("p"),Atom("q")),Atom("p"))),
And(And(Or(Not(Atom("r")), Atom("p")),
Or(Not(Atom("r")), Atom("q"))),
Atom("p")))
test sec5_3_1_test1_dnf_ex [[
(r -> p & q) & p
]] run dnf4 to Or(And(Not(Atom("r")),Atom("p")),And(And(Atom("p"),Atom("q")),Atom("p")))
test sec5_3_1_test1_cnf_ex [[
(r -> p & q) & p
]] run cnf4 to And(And(Or(Not(Atom("r")), Atom("p")),
Or(Not(Atom("r")), Atom("q"))),
Atom("p"))