Skip to content

Commit

Permalink
✅ toString manually checked
Browse files Browse the repository at this point in the history
  • Loading branch information
trydofor committed Jan 29, 2024
1 parent 4d5eabd commit 34c8eb0
Show file tree
Hide file tree
Showing 13 changed files with 83 additions and 28 deletions.
3 changes: 3 additions & 0 deletions src/test/java/pro/fessional/meepo/bind/dna/DnaBkbTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package pro.fessional.meepo.bind.dna;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import pro.fessional.meepo.TraceTest;
import pro.fessional.meepo.bind.wow.Clop;
Expand All @@ -17,5 +18,7 @@ public class DnaBkbTest extends TraceTest {
public void testToString() {
logger.debug("d1={}", d1);
logger.debug("d2={}", d2);
Assertions.assertTrue(d1.toString().contains("name='BlackKingBar'"));
Assertions.assertTrue(d2.toString().contains("name='BlackKingBar'"));
}
}
3 changes: 3 additions & 0 deletions src/test/java/pro/fessional/meepo/bind/dna/DnaEndTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package pro.fessional.meepo.bind.dna;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import pro.fessional.meepo.TraceTest;
import pro.fessional.meepo.bind.wow.Clop;
Expand All @@ -19,5 +20,7 @@ public class DnaEndTest extends TraceTest {
public void testToString() {
logger.debug("d1={}", d1);
logger.debug("d2={}", d2);
Assertions.assertTrue(d1.toString().contains("name=[BlackKingBar,id]"));
Assertions.assertTrue(d2.toString().contains("name=[BlackKingBar,id]"));
}
}
3 changes: 3 additions & 0 deletions src/test/java/pro/fessional/meepo/bind/dna/DnaRawTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package pro.fessional.meepo.bind.dna;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import pro.fessional.meepo.TraceTest;
import pro.fessional.meepo.bind.wow.Clop;
Expand All @@ -19,6 +20,8 @@ public class DnaRawTest extends TraceTest {
public void testToString() {
logger.debug("d1={}", d1);
logger.debug("d2={}", d2);
Assertions.assertTrue(d1.toString().contains("text='SUPER(1010100'"));
Assertions.assertTrue(d2.toString().contains("text='SUPER(1010100'"));
}

}
3 changes: 3 additions & 0 deletions src/test/java/pro/fessional/meepo/bind/dna/DnaSetTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package pro.fessional.meepo.bind.dna;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import pro.fessional.meepo.TraceTest;
import pro.fessional.meepo.bind.wow.Clop;
Expand All @@ -20,5 +21,7 @@ public class DnaSetTest extends TraceTest {
public void testToString() {
logger.debug("d1={}", d1);
logger.debug("d2={}", d2);
Assertions.assertTrue(d1.toString().contains("find='false', repl='{{user.male}}'}"));
Assertions.assertTrue(d2.toString().contains("find='false', repl='{{user.male}}'"));
}
}
4 changes: 4 additions & 0 deletions src/test/java/pro/fessional/meepo/bind/rna/RnaPutTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package pro.fessional.meepo.bind.rna;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import pro.fessional.meepo.TraceTest;
import pro.fessional.meepo.bind.wow.Clop;
Expand All @@ -17,5 +18,8 @@ public class RnaPutTest extends TraceTest {
public void testToString() {
logger.debug("d1={}", d1);
logger.debug("d2={}", d2);

Assertions.assertTrue(d1.toString().contains("type='os', para='who', expr='basename $(pwd)'"));
Assertions.assertTrue(d2.toString().contains("type='os', para='who', expr='basename $(pwd)'"));
}
}
4 changes: 4 additions & 0 deletions src/test/java/pro/fessional/meepo/bind/rna/RnaRunTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package pro.fessional.meepo.bind.rna;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import pro.fessional.meepo.TraceTest;
import pro.fessional.meepo.bind.wow.Clop;
Expand All @@ -20,5 +21,8 @@ public class RnaRunTest extends TraceTest {
public void testToString() {
logger.debug("d1={}", d1);
logger.debug("d2={}", d2);

Assertions.assertTrue(d1.toString().contains("type='os', find='rand', expr='echo $RANDOM'"));
Assertions.assertTrue(d2.toString().contains("type='os', find='rand', expr='echo $RANDOM'"));
}
}
4 changes: 4 additions & 0 deletions src/test/java/pro/fessional/meepo/bind/rna/RnaUseTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package pro.fessional.meepo.bind.rna;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import pro.fessional.meepo.TraceTest;
import pro.fessional.meepo.bind.wow.Clop;
Expand All @@ -20,5 +21,8 @@ public class RnaUseTest extends TraceTest {
public void testToString() {
logger.debug("d1={}", d1);
logger.debug("d2={}", d2);

Assertions.assertTrue(d1.toString().contains("find='meepo', para='who'"));
Assertions.assertTrue(d2.toString().contains("find='meepo', para='who'"));
}
}
3 changes: 3 additions & 0 deletions src/test/java/pro/fessional/meepo/bind/txt/HiMeepoTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package pro.fessional.meepo.bind.txt;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import pro.fessional.meepo.TraceTest;
import pro.fessional.meepo.bind.wow.Clop;
Expand All @@ -17,5 +18,7 @@ public class HiMeepoTest extends TraceTest {
public void testToString() {
logger.debug("d1={}", d1);
logger.debug("d2={}", d2);
Assertions.assertTrue(d1.toString().contains("head='/*', tail='*/'"));
Assertions.assertTrue(d2.toString().contains("head='/*', tail='*/'"));
}
}
4 changes: 4 additions & 0 deletions src/test/java/pro/fessional/meepo/bind/txt/TxtSimpleTest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package pro.fessional.meepo.bind.txt;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import pro.fessional.meepo.TraceTest;
import pro.fessional.meepo.bind.wow.Clop;
Expand All @@ -17,5 +18,8 @@ public class TxtSimpleTest extends TraceTest {
public void testToString() {
logger.debug("d1={}", d1);
logger.debug("d2={}", d2);

Assertions.assertTrue(d1.toString().contains("text='123456789'"));
Assertions.assertTrue(d2.toString().contains("text='123456789'"));
}
}
10 changes: 5 additions & 5 deletions src/test/java/pro/fessional/meepo/poof/RnaManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void testFunNow1() {
Gene gene = Parser.parse(meepo);
Map<String, Object> ctx = new HashMap<>();
String out = gene.merge(ctx);
logger.debug(out);
logger.debug("testFunNow={}", out);
Pattern ptn = Pattern.compile("\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}");
assertTrue(ptn.matcher(out).find());
}
Expand All @@ -40,7 +40,7 @@ public void testFunNow2() {
Gene gene = Parser.parse(meepo);
Map<String, Object> ctx = new HashMap<>();
String out = gene.merge(ctx);
logger.debug(out);
logger.debug("testFunNow={}", out);
Pattern ptn = Pattern.compile("\\d{4}-\\d{2}-\\d{2}");
assertTrue(ptn.matcher(out).find());
}
Expand All @@ -52,7 +52,7 @@ public void testFunNow() {
Map<String, Object> ctx = new HashMap<>();
{
Object obj = fun.eval(ctx, null);
logger.debug("obj={}", obj);
logger.debug("testFunNow.obj={}", obj);
}
{
Object obj = fun.eval(ctx, new java.util.Date(0));
Expand Down Expand Up @@ -97,7 +97,7 @@ public void testFunAbs() {
ctx.put("number", -1);
Gene gene = Parser.parse(meepo);
String out = gene.merge(ctx);
logger.debug(out);
logger.debug("testFunAbs={}", out);
assertEquals("1", out);
}

Expand All @@ -112,7 +112,7 @@ public void testFunCtx() {

Gene gene = Parser.parse(meepo);
String out = gene.merge(ctx);
logger.debug(out);
logger.debug("testFunCtx={}", out);
assertEquals("1", out);
}
}
35 changes: 24 additions & 11 deletions src/test/java/pro/fessional/meepo/sack/HolderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,42 +20,55 @@ class HolderTest extends TraceTest {
void parseSimple() {
String hd = "this is {{var | PascalCase}} here";
final Gene gene = Holder.parse(hd);
logger.debug(gene.build());
logger.debug(gene.graph());
String build = gene.build();
String graph = gene.graph();
logger.debug("hd={}", hd);
logger.debug("build={}", build);
logger.debug("graph={}", graph);
String str = gene.merge(ctx);
assertEquals("this is TryDoFor here", str);
assertEquals(hd, build);
}

@Test
void parseEsc1() {
String hd = "this is /{{ //{{ var | PascalCase | BIG_SNAKE }} /}} here";
final Gene gene = Holder.parse(true, hd, "{{", "}}", "/");
logger.debug(hd);
logger.debug(gene.build());
logger.debug(gene.graph());
String build = gene.build();
String graph = gene.graph();
logger.debug("hd={}", hd);
logger.debug("build={}", build);
logger.debug("graph={}", graph);
String str = gene.merge(ctx);
assertEquals("this is {{ /TRY_DO_FOR }} here", str);
assertEquals("this is {{ /{{ var | PascalCase | BIG_SNAKE }} }} here", build);
}

@Test
void parseEsc2() {
String hd = "} this is /${ //${ var | PascalCase | BIG_SNAKE } /} here ${";
final Gene gene = Holder.parse(true, hd, "${", "}", "/");
logger.debug(hd);
logger.debug(gene.build());
logger.debug(gene.graph());
String build = gene.build();
String graph = gene.graph();
logger.debug("hd={}", hd);
logger.debug("build={}", build);
logger.debug("graph={}", graph);
String str = gene.merge(ctx);
assertEquals("} this is ${ /TRY_DO_FOR } here ${", str);
assertEquals("} this is ${ /${ var | PascalCase | BIG_SNAKE } } here ${", build);
}

@Test
void parseEsc3() {
String hd = "}}}} this is /${ //${ var | PascalCase | BIG_SNAKE }}} /}}}} here ${";
final Gene gene = Holder.parse(true, hd, "${", "}}}", "/");
logger.debug(hd);
logger.debug(gene.build());
logger.debug(gene.graph());
String graph = gene.graph();
String build = gene.build();
logger.debug("hd={}", hd);
logger.debug("build={}", build);
logger.debug("graph={}", graph);
String str = gene.merge(ctx);
assertEquals("}}}} this is ${ /TRY_DO_FOR }}}} here ${", str);
assertEquals("}}}} this is ${ /${ var | PascalCase | BIG_SNAKE }}} }}}} here ${", build);
}
}
32 changes: 21 additions & 11 deletions src/test/java/pro/fessional/meepo/sack/ParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ private void checkDnaBkb(HiMeepo meepo, String txt, String name, String build) {

Exon exon = Parser.dealDnaBkb(ctx);
assertNotNull(exon);
logger.debug("{}", exon);
String str = exon.toString();
logger.debug("checkDnaBkb={}", str);
if (name == null) {
assertEquals(0, exon.edge.until);
}
Expand Down Expand Up @@ -220,7 +221,8 @@ private void checkDnaEnd(HiMeepo meepo, String txt, String name, String build) {

Exon exon = Parser.dealDnaEnd(ctx);
assertNotNull(exon);
logger.debug(exon.toString());
String str = exon.toString();
logger.debug("checkDnaEnd={}", str);

if (name == null) {
assertEquals(0, exon.edge.until);
Expand Down Expand Up @@ -268,7 +270,8 @@ private void checkDnaSet(HiMeepo meepo, String txt, Life life, String find, Stri

Exon exon = Parser.dealDnaSet(ctx);
assertNotNull(exon);
logger.debug(exon.toString());
String str = exon.toString();
logger.debug("checkDnaSet={}", str);

if (life == null) {
assertEquals(0, exon.edge.until);
Expand Down Expand Up @@ -318,7 +321,7 @@ public void dealDnaSet() {
checkDnaSet(level5, "@@/* DNA:SET /false/mail */\n@@", null, null, null, "/* DNA:SET /false/mail */");

// nothing to test
TxtDnaSet tds = new TxtDnaSet("a", new Clop(0, 1,0,0), "TxtDnaSet-toString-Test");
TxtDnaSet tds = new TxtDnaSet("a", new Clop(0, 1, 0, 0), "TxtDnaSet-toString-Test");
Assertions.assertTrue(tds.toString().contains("TxtDnaSet-toString-Test"));
}

Expand All @@ -329,7 +332,8 @@ private void checkRnaRun(HiMeepo meepo, String txt, Life life, String type, Stri

Exon exon = Parser.dealRnaRun(ctx);
assertNotNull(exon);
logger.debug(exon.toString());
String str = exon.toString();
logger.debug("checkRnaRun={}", str);

if (type == null) {
assertEquals(0, exon.edge.until);
Expand Down Expand Up @@ -392,7 +396,8 @@ private void checkRnaUse(HiMeepo meepo, String txt, Life life, String find, Stri

Exon exon = Parser.dealRnaUse(ctx);
assertNotNull(exon);
logger.debug(exon.toString());
String str = exon.toString();
logger.debug("checkRnaUse={}", str);

if (life == null) {
assertEquals(0, exon.edge.until);
Expand Down Expand Up @@ -451,7 +456,8 @@ private void checkRnaPut(HiMeepo meepo, String txt, String type, String para, St
Exon exon = Parser.dealRnaPut(ctx);
assertNotNull(exon);
exon.check(ctx.errs, ctx.rngs);
logger.debug(exon.toString());
String str = exon.toString();
logger.debug("checkRnaPut={}", str);

if (type == null) {
assertEquals(0, exon.edge.until);
Expand Down Expand Up @@ -511,7 +517,8 @@ private void checkRnaWhen(HiMeepo meepo, String txt, String tock, String type, b
Exon exon = Parser.dealRnaWhen(ctx);
assertNotNull(exon);
exon.check(ctx.errs, ctx.rngs);
logger.debug(exon.toString());
String str = exon.toString();
logger.debug("checkRnaWhen={}", str);

if (type == null) {
assertEquals(0, exon.edge.until);
Expand Down Expand Up @@ -557,7 +564,8 @@ private void checkRnaEach(HiMeepo meepo, String txt, String tock, String type, i
Exon exon = Parser.dealRnaEach(ctx);
assertNotNull(exon);
exon.check(ctx.errs, ctx.rngs);
logger.debug(exon.toString());
String str = exon.toString();
logger.debug("checkRnaEach={}", str);

if (type == null) {
assertEquals(0, exon.edge.until);
Expand Down Expand Up @@ -601,7 +609,8 @@ private void checkRnaElse(HiMeepo meepo, String txt, String tock, String build)

Exon exon = Parser.dealRnaElse(ctx);
assertNotNull(exon);
logger.debug(exon.toString());
String str = exon.toString();
logger.debug("checkRnaElse={}", str);

if (tock == null) {
assertEquals(0, exon.edge.until);
Expand Down Expand Up @@ -637,7 +646,8 @@ private void checkRnaDone(HiMeepo meepo, String txt, String name, String build)

Exon exon = Parser.dealRnaDone(ctx);
assertNotNull(exon);
logger.debug(exon.toString());
String str = exon.toString();
logger.debug("checkRnaDone={}", str);

if (name == null) {
assertEquals(0, exon.edge.until);
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/pro/fessional/meepo/tmpl/TmplHelp.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public static void assertTmpl(String expected, String actual, Map<String, Object
public static void printGene(Logger logger, String clzPath) {
String strIn = Read.read(TmplHelp.class.getResourceAsStream(clzPath));
Gene gene = Parser.parse(strIn);
logger.debug(gene.graph());
String graph = gene.graph();
logger.debug("printGene={}", graph);
}
}

0 comments on commit 34c8eb0

Please sign in to comment.