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

24
LINES

< > BotCompany Repo | #1034834 // test_exceptionInTimeout

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

Libraryless. Click here for Pure Java version (6602L/37K).

svoid test_exceptionInTimeout() {
  class Calcer is IF0<Long> {
    public Long get() {
      long time = sysNow()+2000, x = 0;
      while (sysNow_noPing() < time) ++x;
      ret x;
    }
  }
  
  var either = evalWithTimeout(1.0, new Calcer);
  var stackTrace = either.b().getStackTrace();
  
  var cause = new ThrowableWithCustomStackTrace("Still calculating", stackTrace);
  
  S rendered = renderStackTrace(cause);
  print(+rendered);
  assertBetween(1, 3, indexOfLineContaining(rendered, "Calcer.get"));
  
  var timeoutException = new RuntimeException("Timeout", cause);
  print();
  S rendered2 = renderStackTrace(timeoutException);
  print(rendered2);
  assertContains(rendered2, "Calcer.get");
}

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

-
Snippet ID: #1034834
Snippet name: test_exceptionInTimeout
Eternal ID of this version: #1034834/1
Text MD5: cff8ae7bb1bcdb98e2b2bbf009c1b603
Transpilation MD5: 2257d78ed7fb40e0d1617afeea77e6f0
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-11 03:25:24
Source code size: 728 bytes / 24 lines
Pitched / IR pitched: No / No
Views / Downloads: 113 / 165
Referenced in: