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).

static <A> A assertEqualsVerbose(O x, A y) {
  assertEqualsVerbose((S) null, x, y);
  ret y;
}

// x = expected, y = actual
static <A> A assertEqualsVerbose(S msg, O x, A y) {
  if (!eq(x, y)) {
    ifdef assertEqualsVerbose_advancedDiff
    if (x instanceof S && y instanceof S && (containsNewLine((S) x) || containsNewLine((S) y)))
      nlPrintNL(unidiff((S) x, (S) y));
    endifdef

    fail((nempty(msg) ? msg + ": " : "") + "expected: "+ x + ", got: " + y);
  } else
    print("OK" + (empty(msg) ? "" : " " + msg) + ": " + /*sfu*/(x));
  ret y;
}

ifclass Scorer
static void assertEqualsVerbose(Scorer scorer, S msg default "", O x, O y) {
  if (scorer == null) ret with assertEqualsVerbose(x, y);
  if (!eq(x, y)) {
    print(appendColonIfNempty(msg) + y + " != " + x);
    scorer.add(false);
  } else {
    print("OK: " + appendColonIfNempty(msg) + x);
    scorer.add(true);
  }
}
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: 848 / 961
Version history: 22 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1012221 - assertTripleEqicVerbose
#1012689 - assertNotEqualsVerbose
#1013635 - assertSameVerbose
#1014739 - assertEqualsVerbose_trim - trim both values
#1017828 - assertEqualsVerbose_match - use match()
#1018446 - assertEqualsVerbose_struct - print structs
#1022099 - assertNullVerbose
#1023082 - assertEqualsVerboseIC
#1023270 - assertNotNullVerbose
#1027813 - assertEqualsOneOfVerbose
#1029597 - assertEqualsBothDirectionsVerbose
#1031312 - assertEqualsVerboseUnder - apply transformation before comparing
#3000382 - Answer for ferdie (>> t = 1, f = 0)