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

31
LINES

< > BotCompany Repo | #1002936 // assertEqualsVerbose

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (3809L/22K).

1  
static <A> A assertEqualsVerbose(O x, A y) {
2  
  assertEqualsVerbose((S) null, x, y);
3  
  ret y;
4  
}
5  
6  
// x = expected, y = actual
7  
static <A> A assertEqualsVerbose(S msg, O x, A y) {
8  
  if (!eq(x, y)) {
9  
    ifdef assertEqualsVerbose_advancedDiff
10  
    if (x instanceof S && y instanceof S && (containsNewLine((S) x) || containsNewLine((S) y)))
11  
      nlPrintNL(unidiff((S) x, (S) y));
12  
    endifdef
13  
14  
    fail((nempty(msg) ? msg + ": " : "") + "expected: "+ x + ", got: " + y);
15  
  } else
16  
    print("OK" + (empty(msg) ? "" : " " + msg) + ": " + /*sfu*/(x));
17  
  ret y;
18  
}
19  
20  
ifclass Scorer
21  
static void assertEqualsVerbose(Scorer scorer, S msg default "", O x, O y) {
22  
  if (scorer == null) ret with assertEqualsVerbose(x, y);
23  
  if (!eq(x, y)) {
24  
    print(appendColonIfNempty(msg) + y + " != " + x);
25  
    scorer.add(false);
26  
  } else {
27  
    print("OK: " + appendColonIfNempty(msg) + x);
28  
    scorer.add(true);
29  
  }
30  
}
31  
endif

Author comment

Began life as a copy of #1001055

download  show line numbers  debug dex  old transpilations   

Travelled to 18 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ekrmjmnbrukm, elmgxqgtpvxh, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1002936
Snippet name: assertEqualsVerbose
Eternal ID of this version: #1002936/23
Text MD5: cbafb03df98c2791287abf4e58f046f0
Transpilation MD5: d56f679b4827c6b82dae120b96ec3a31
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-07 08:18:42
Source code size: 925 bytes / 31 lines
Pitched / IR pitched: No / No
Views / Downloads: 761 / 862
Version history: 22 change(s)
Referenced in: [show references]