public void ParseTransforms() { Chat c = CreateParentChat("c1"); TxForm tx; tx = TxForm.Parse("(a).Cap()", c)[0]; Assert.That(tx.text, Is.EqualTo("(a).Cap()")); Assert.That(tx.content, Is.EqualTo("a")); Assert.That(tx.transformText, Is.EqualTo(".Cap()")); tx = TxForm.Parse("(a b).Cap()", c)[0]; Assert.That(tx.text, Is.EqualTo("(a b).Cap()")); Assert.That(tx.content, Is.EqualTo("a b")); Assert.That(tx.transformText, Is.EqualTo(".Cap()")); tx = TxForm.Parse("((a b)).Cap()", c)[0]; Assert.That(tx.text, Is.EqualTo("((a b)).Cap()")); Assert.That(tx.content, Is.EqualTo("a b")); Assert.That(tx.transformText, Is.EqualTo(".Cap()")); tx = TxForm.Parse("((a) (b)).Cap()", c)[0]; Assert.That(tx.text, Is.EqualTo("((a) (b)).Cap()")); Assert.That(tx.content, Is.EqualTo("a b")); Assert.That(tx.transformText, Is.EqualTo(".Cap()")); tx = TxForm.Parse("((a)(b)).Cap()", c)[0]; Assert.That(tx.text, Is.EqualTo("((a)(b)).Cap()")); Assert.That(tx.content, Is.EqualTo("ab")); Assert.That(tx.transformText, Is.EqualTo(".Cap()")); tx = TxForm.Parse("((ab)).Cap()", c)[0]; Assert.That(tx.text, Is.EqualTo("((ab)).Cap()")); Assert.That(tx.content, Is.EqualTo("ab")); Assert.That(tx.transformText, Is.EqualTo(".Cap()")); tx = TxForm.Parse("(((ab)).Cap()", c)[0]; Assert.That(tx.text, Is.EqualTo("((ab)).Cap()")); Assert.That(tx.content, Is.EqualTo("ab")); Assert.That(tx.transformText, Is.EqualTo(".Cap()")); tx = TxForm.Parse("((((ab)).Cap()))", c)[0]; Assert.That(tx.text, Is.EqualTo("((ab)).Cap()")); Assert.That(tx.content, Is.EqualTo("ab")); Assert.That(tx.transformText, Is.EqualTo(".Cap()")); tx = TxForm.Parse(")((ab)).Cap()", c)[0]; Assert.That(tx.text, Is.EqualTo("((ab)).Cap()")); Assert.That(tx.content, Is.EqualTo("ab")); Assert.That(tx.transformText, Is.EqualTo(".Cap()")); }
public void SimpleTransformResolution() { string result, text; TxForm tran; Chat c1 = null; text = "The so-called (dog).Quotify() ran."; tran = TxForm.Parse(text, c1)[0]; result = tran.Resolve(); Assert.That(result.ToString(), Is.EqualTo(""dog"")); result = tran.Replace(text, result); Assert.That(result.ToString(), Is.EqualTo("The so-called "dog" ran.")); text = "The (dog).Cap() ran."; tran = TxForm.Parse(text, c1)[0]; result = tran.Resolve(); Assert.That(result.ToString(), Is.EqualTo("Dog")); result = tran.Replace(text, result); Assert.That(result.ToString(), Is.EqualTo("The Dog ran.")); text = "(ant).Articlize().Cap() ran."; tran = TxForm.Parse(text, c1)[0]; result = tran.Resolve(); Assert.That(result.ToString(), Is.EqualTo("An ant")); result = tran.Replace(text, result); Assert.That(result.ToString(), Is.EqualTo("An ant ran.")); text = "Today (ant).Cap().Articlize() ran."; tran = TxForm.Parse(text, c1)[0]; result = tran.Resolve(); Assert.That(result.ToString(), Is.EqualTo("an Ant")); result = tran.Replace(text, result); Assert.That(result.ToString(), Is.EqualTo("Today an Ant ran.")); text = "Today (an ant).Cap() ran."; tran = TxForm.Parse(text, c1)[0]; result = tran.Resolve(); Assert.That(result.ToString(), Is.EqualTo("An ant")); result = tran.Replace(text, result); Assert.That(result.ToString(), Is.EqualTo("Today An ant ran.")); text = "(a (then).Cap())"; tran = TxForm.Parse(text, c1)[0]; result = tran.Resolve(); Assert.That(result.ToString(), Is.EqualTo("Then")); result = tran.Replace(text, result); Assert.That(result.ToString(), Is.EqualTo("(a Then)")); }
public void ParseMultiTransforms() { Chat c = CreateParentChat("c1"); List <TxForm> txs; txs = TxForm.Parse("(a).Cap() (b).Cap()", c); Assert.That(txs.Count, Is.EqualTo(2)); Assert.That(txs[0].text, Is.EqualTo("(a).Cap()")); Assert.That(txs[0].content, Is.EqualTo("a")); Assert.That(txs[0].transformText, Is.EqualTo(".Cap()")); Assert.That(txs[1].text, Is.EqualTo("(b).Cap()")); Assert.That(txs[1].content, Is.EqualTo("b")); Assert.That(txs[1].transformText, Is.EqualTo(".Cap()")); txs = TxForm.Parse("((a).Cap()).Cap()", c); Assert.That(txs.Count, Is.EqualTo(2)); Assert.That(txs[0].text, Is.EqualTo("(a).Cap()")); Assert.That(txs[0].content, Is.EqualTo("a")); Assert.That(txs[0].transformText, Is.EqualTo(".Cap()")); Assert.That(txs[1].text, Is.EqualTo("((a).Cap()).Cap()")); Assert.That(txs[1].content, Is.EqualTo("(a).Cap()")); Assert.That(txs[1].transformText, Is.EqualTo(".Cap()")); txs = TxForm.Parse("(((a).Cap()).Cap()).Cap()", c); //Console.WriteLine(txs.Stringify()); Assert.That(txs.Count, Is.EqualTo(3)); Assert.That(txs[0].text, Is.EqualTo("(a).Cap()")); Assert.That(txs[0].content, Is.EqualTo("a")); Assert.That(txs[0].transformText, Is.EqualTo(".Cap()")); Assert.That(txs[1].text, Is.EqualTo("((a).Cap()).Cap()")); Assert.That(txs[1].content, Is.EqualTo("(a).Cap()")); Assert.That(txs[1].transformText, Is.EqualTo(".Cap()")); Assert.That(txs[2].text, Is.EqualTo("(((a).Cap()).Cap()).Cap()")); Assert.That(txs[2].content, Is.EqualTo("((a).Cap()).Cap()")); Assert.That(txs[2].transformText, Is.EqualTo(".Cap()")); }
private void ParseTransforms(string text, Chat context) { trans.Clear(); TxForm.Parse(trans, text, context); }