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

69
LINES

< > BotCompany Repo | #1022661 // Gazelle Tests v2 [Dyn Module, with CRUD]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 911K of libraries. Click here for Pure Java version (22018L/131K).

!7

!include once #1021761 // Gazelle Fakery
 
set flag DynModule.

concept Test {
  S name, contents;
  long lastRun, runtime;
  bool success, anySuccess;
}

cmodule GazelleTests > DynCRUD<Test> {
  transient bool running;
  
  transient O[] flags = litparams(
    debugSorting := true,
    useRepeat_v2 := true);
  
  start {
    dm_useLocalMechListCopies();
    crud.multiLineFields = litset('contents);
  }
  
  visualize {
    JComponent c = super.visualize();
    addSelectionDependentButton("Run", r { doIt(selected().name) });
    ret jvsplit(c,
      centerAndSouthWithMargin(dm_printLogComponent(),
        withMargin(jbutton("Run Tests", r runAll))));
  }
  
  void runAll() {
    doIt("");
  }
  
  void doIt(S testName) q {
    _doIt(testName);
  }
  
  void _doIt(S testName) {
    temp dm_tempSetField(running := true);
    
    clearPrintLog();
    gazelle_performMultipleTests(mL_raw("Gazelle Tests"),
      paramsPlus(flags,
        performOnly := testName,
      testStarting := voidfunc(S name, S contents) {
        cset(uniq_sync Test(+name), lastRun := now(), +contents)
      },
      testDone := voidfunc(S name, ErrorCounter scorer) {
        Test test = conceptWhere Test(+name);
        cset(test, runtime := now()-test.lastRun);
        cset(test, success := scorer.allCorrect());
        if (test.success) cset(test, anySuccess := true);
      }
    ));
  }
  
  // API
  
  void runTestAndWait(S testName) {
    dm_runInQAndWait(r { _doIt(testName) });
  }
  
  Pair<Int> countAndSuccesses() {
    ret pair(countConcepts(Test), countConceptsWhere(Test, success := true));
  }
}

Author comment

Began life as a copy of #1022442

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1022661
Snippet name: Gazelle Tests v2 [Dyn Module, with CRUD]
Eternal ID of this version: #1022661/7
Text MD5: 24827cf86464af98fc2c4e2f2f8174df
Transpilation MD5: 56f9d1f760d96fbab5df082a2b00e79e
Author: stefan
Category: javax / gazelle
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-03-29 18:30:08
Source code size: 1678 bytes / 69 lines
Pitched / IR pitched: No / No
Views / Downloads: 197 / 2304
Version history: 6 change(s)
Referenced in: [show references]