Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

48
LINES

< > BotCompany Repo | #1021532 // A Rule Test with regexp [OK]

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Libraryless. Click here for Pure Java version (7620L/54K).

1  
!7
2  
3  
sS input = [[
4  
  Rule:
5  
  
6  
  /,/ [regexp]
7  
  => The line contains a comma.
8  
  
9  
  Input: "Hello,"
10  
  
11  
  Output: "The line contains a comma."
12  
  
13  
  ----
14  
  
15  
  Same rule.
16  
  
17  
  Input: "Yo."
18  
  
19  
  Output: -
20  
]];
21  
22  
p-exp {
23  
  scoreToConsole(voidfunc(Scorer scorer) {
24  
    LS tests = splitAtMultipleMinusLines(input);
25  
    SS map = null;
26  
    for (S test : tests) {
27  
      print();
28  
      SS lastMap = map;
29  
      map = parseColonProperties_withMultiLines(test, ciSS());
30  
      if (containsTrimmedLineIC(test, "Same rule."))
31  
        map.put("Rule", lastMap.get("Rule"));
32  
      pnlStruct(map);
33  
      
34  
      S input = unquote(map.get("Input"));
35  
      S output = unquote(map.get("Output"));
36  
      PairS rule = splitAtDoubleArrow_pair(map.get("Rule"));
37  
      S out = "-";
38  
      
39  
      S in = rule.a;
40  
      PairS inAndType = splitTrailingSquareBracketStuff(in);
41  
      if (eqic(inAndType.b, "regexp"))
42  
        if (regexpContains(dropTrailingAndLeadingSlash(inAndType.a), input))
43  
          out = rule.b;
44  
45  
      scorer.eq(out, output);
46  
    }
47  
  });
48  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 8 computer(s): bhatertpkbcr, cfunsshuasjs, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xfasiavlzxuf

No comments. add comment

Snippet ID: #1021532
Snippet name: A Rule Test with regexp [OK]
Eternal ID of this version: #1021532/12
Text MD5: d32f4eee8f389ecc600b83028cbcdc71
Transpilation MD5: 6837d0220bfb7f102f8a0e3add96076c
Author: stefan
Category: javax / stefan's os / a.i.
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-02-17 15:26:26
Source code size: 1067 bytes / 48 lines
Pitched / IR pitched: No / No
Views / Downloads: 544 / 1422
Version history: 11 change(s)
Referenced in: [show references]