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

32
LINES

< > BotCompany Repo | #1026391 // Test swappable (OK)

JavaX source code (desktop) [tags: use-pretranspiled] - run with: x30.jar

Download Jar. Transpiled version (15332L) is out of date.

1  
!7
2  
3  
//import javax.validation.constraints.NotNull;
4  
5  
sclass Bla {
6  
  swappable S hello() { ret "yo"; }
7  
  swappable void bla() {}
8  
  swappable void blu(S s) { print(s); }
9  
  persistently swappable void blo(S s) { print(s); }
10  
  //swappable void notNullTest(@NotNull S s) { print(s); }
11  
}
12  
13  
static swappable S staticTest() { null; }
14  
swappable static S staticTest2() { null; }
15  
swappable static S staticTest3(Long a, int b) { null; }
16  
swappable static bool staticTest4() { false; }
17  
swappable static LS staticTest5() { null; }
18  
19  
p-exp {
20  
  new Bla bla;
21  
  
22  
  // normal call
23  
  assertEqualsVerbose("yo", bla.hello());
24  
  
25  
  // override method at runtime (!)
26  
  bla.hello = () -> "Here is random stuff: " + randomID();
27  
  
28  
  // overridden call
29  
  assertStartsWith_rev("Here is random stuff:", print(bla.hello()));
30  
  
31  
  print("OK");
32  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1026391
Snippet name: Test swappable (OK)
Eternal ID of this version: #1026391/21
Text MD5: a6acb9110b7e1a464a5aa5edba897870
Author: stefan
Category: javax
Type: JavaX source code (desktop)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-08-20 17:40:22
Source code size: 841 bytes / 32 lines
Pitched / IR pitched: No / No
Views / Downloads: 437 / 1111
Version history: 20 change(s)
Referenced in: [show references]