-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add method to recover expression from string item effect.
- Loading branch information
1 parent
4458f52
commit f4a4e0b
Showing
3 changed files
with
133 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using FluentAssertions; | ||
using RandomizerCore.Logic; | ||
using RandomizerCore.StringItems; | ||
using RandomizerCore.StringParsing; | ||
|
||
namespace RandomizerCoreTests | ||
{ | ||
public class EffectToExpressionTests | ||
{ | ||
[Theory] | ||
[InlineData("_")] | ||
[InlineData("A++")] | ||
[InlineData("A++ >> B++")] | ||
[InlineData("A++ >> B++ >> C++")] | ||
[InlineData("A++ >> B++ >|> C++")] | ||
[InlineData("`A<1` => B++")] | ||
[InlineData("!`A<1` => B++")] | ||
[InlineData("*I")] | ||
public void IdentityTest(string infix) | ||
{ | ||
LogicManagerBuilder lmb = new(); | ||
string[] terms = ["A", "B", "C"]; | ||
foreach (string s in terms) lmb.GetOrAddTerm(s); | ||
lmb.AddItem(new StringItemTemplate("I", "_")); | ||
|
||
lmb.AddItem(new StringItemTemplate("Test_Item", infix)); | ||
|
||
LogicManager lm = new(lmb); | ||
|
||
StringItem item = (StringItem)lm.GetItemStrict("Test_Item"); | ||
|
||
item.Effect.ToEffectString().Should().Be(infix); | ||
} | ||
|
||
[Theory] | ||
[InlineData("A++ >> (B++ >> C++)", "A++ >> B++ >> C++")] | ||
[InlineData("A += 1", "A++")] | ||
[InlineData("A+=2", "A += 2")] | ||
public void NonidentityTest(string infix, string result) | ||
{ | ||
LogicManagerBuilder lmb = new(); | ||
string[] terms = ["A", "B", "C"]; | ||
foreach (string s in terms) lmb.GetOrAddTerm(s); | ||
lmb.AddItem(new StringItemTemplate("I", "_")); | ||
|
||
lmb.AddItem(new StringItemTemplate("Test_Item", infix)); | ||
|
||
LogicManager lm = new(lmb); | ||
|
||
StringItem item = (StringItem)lm.GetItemStrict("Test_Item"); | ||
|
||
item.Effect.ToEffectString().Should().Be(result); | ||
} | ||
} | ||
} |