Пример #1
0
 @Test
 public void match1() throws ProcessorException {
   Object lResult = scripty.process("str-match \"(a+)(b*)c\" aaabbbbbc");
   Assert.assertTrue(lResult instanceof List);
   List lListResult = (List) lResult;
   Assert.assertTrue(lListResult.size() == 3);
   Assert.assertEquals("aaabbbbbc", lListResult.get(0));
   Assert.assertEquals("aaa", lListResult.get(1));
   Assert.assertEquals("bbbbb", lListResult.get(2));
 }
Пример #2
0
  @Test
  public void match2() throws ProcessorException {
    Object lResult = scripty.process("str-match* \"(\\d+)\\s*\" \"10 11 12 13\"");
    Assert.assertTrue(lResult instanceof List);
    List lListResult = (List) lResult;
    Assert.assertTrue(lListResult.size() == 4);

    Assert.assertEquals("10", ((List) lListResult.get(0)).get(1));
    Assert.assertEquals("11", ((List) lListResult.get(1)).get(1));
    Assert.assertEquals("12", ((List) lListResult.get(2)).get(1));
    Assert.assertEquals("13", ((List) lListResult.get(3)).get(1));
  }
Пример #3
0
 @Test
 public void format1() throws ProcessorException {
   Object lResult = scripty.process("str-format \"1-%s, 2-%s\" uno duo");
   Assert.assertTrue(lResult instanceof String);
   Assert.assertEquals("1-uno, 2-duo", lResult);
 }
Пример #4
0
 @Test
 public void trim1() throws ProcessorException {
   Object lResult = scripty.process("str-trim \"  abc  \"");
   Assert.assertTrue(lResult instanceof String);
   Assert.assertEquals("abc", lResult);
 }
Пример #5
0
 @Test
 public void isString3() throws ProcessorException {
   Object lResult = scripty.process("str? $null");
   Assert.assertTrue(lResult instanceof Boolean);
   Assert.assertFalse((Boolean) lResult);
 }
Пример #6
0
 @Before
 public void initialize() throws ExtensionException {
   scripty = new ScriptyStreamProcessor();
   scripty.addLibraryClasses(StringLibrary.class);
 }
Пример #7
0
 @Test
 public void isMatch2() throws ProcessorException {
   Object lResult = scripty.process("str-match? \"(a+)(b*)c\" aaabbbbb");
   Assert.assertTrue(lResult instanceof Boolean);
   Assert.assertFalse(((Boolean) lResult));
 }