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

42
LINES

< > BotCompany Repo | #1035656 // test_leftArrowScript_tilde

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

Transpiled version (37273L) is out of date.

1  
!include once #1034831 // Gazelle 22 Function Include for Testing
2  
3  
scope test_leftArrowScript_tilde
4  
5  
sclass #GetOptImpl {
6  
  public O getOpt(S key) { ret key + "!"; }
7  
}
8  
9  
svoid test_leftArrowScript_tilde() {
10  
  var test = new TestFunctionValues<S, O>(l1 leftArrowVerbose);
11  
  
12  
  // function inversion with an extra argument (2 in total)
13  
  test
14  
    .io([[litmap "a" 2 "b" 3, ~a]], 2)
15  
    .io([[litmap "a" 2 "b" 3, ~b]], 3)
16  
    .io([[litmap "a" 2 "b" 3, ~c]], null)
17  
    .io([[litmap "a" (litmap "x" 2) "b" 3, ~a ~x]], 2).runAndClear();
18  
    
19  
  // get list element
20  
  test
21  
    .io([[ll "a" "b", ~0]], "a")
22  
    .io([[ll "a" "b", ~1]], "b")
23  
    .io([[ll "a" "b", ~2]], null)
24  
    .runAndClear();
25  
    
26  
  // tilde directly after function call
27  
  test
28  
    .io([[def bla { litmap "a" 2 }
29  
          bla~a]], 2)
30  
    .runAndClear();
31  
    
32  
  // Any object implementing getOpt(key)
33  
  test
34  
    .io(replaceIdentifiers([[new GetOptImpl, ~hey]], "GetOptImpl", className(GetOptImpl)), "hey!")
35  
    .runAndClear();
36  
    
37  
  // It's okay to do "null, ~whatever"
38  
  
39  
  test
40  
    .io("null, ~bla", null)
41  
    .runAndClear();
42  
}

Author comment

Began life as a copy of #1035535

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): elmgxqgtpvxh, gjtlkbvenryc, mqqgnosmbjvj, wnsclhtenguj

No comments. add comment

Snippet ID: #1035656
Snippet name: test_leftArrowScript_tilde
Eternal ID of this version: #1035656/12
Text MD5: f8efd9fe48c63aa191f41ff9a28b3675
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2023-10-21 15:04:28
Source code size: 1129 bytes / 42 lines
Pitched / IR pitched: No / No
Views / Downloads: 114 / 184
Version history: 11 change(s)
Referenced in: [show references]