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

1  
svoid test_exceptionInTimeout() {
2  
  class Calcer is IF0<Long> {
3  
    public Long get() {
4  
      long time = sysNow()+2000, x = 0;
5  
      while (sysNow_noPing() < time) ++x;
6  
      ret x;
7  
    }
8  
  }
9  
  
10  
  var either = evalWithTimeout(1.0, new Calcer);
11  
  var stackTrace = either.b().getStackTrace();
12  
  
13  
  var cause = new ThrowableWithCustomStackTrace("Still calculating", stackTrace);
14  
  
15  
  S rendered = renderStackTrace(cause);
16  
  print(+rendered);
17  
  assertBetween(1, 3, indexOfLineContaining(rendered, "Calcer.get"));
18  
  
19  
  var timeoutException = new RuntimeException("Timeout", cause);
20  
  print();
21  
  S rendered2 = renderStackTrace(timeoutException);
22  
  print(rendered2);
23  
  assertContains(rendered2, "Calcer.get");
24  
}

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: 114 / 166
Referenced in: [show references]