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

37
LINES

< > BotCompany Repo | #1035104 // test_leftArrowScript_forIterator - test "for iterator" and "for nested"

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

Transpiled version (47250L) is out of date.

1  
!include once #1034831 // Gazelle 22 Function Include for Testing
2  
3  
svoid test_leftArrowScript_forIterator() {
4  
  ItIt<Pair<Int, Long>> it = cast leftArrowVerbose(
5  
    [[ for iterator i in ll 2 3 { pair i (nanoTime) }]]
6  
  );
7  
  assertTrue(it.hasNext();
8  
  long time = nanoTime();
9  
  sleep(1);
10  
  var p = it.next();
11  
  assertEquals(2, p.a);
12  
  assertTrue(p.b > time);
13  
  time = p.b;
14  
  sleep(1);
15  
  assertTrue(it.hasNext();
16  
  p = it.next();
17  
  assertEquals(3, p.a);
18  
  assertTrue(p.b > time);
19  
  assertFalse(it.hasNext());
20  
  
21  
  // for nested
22  
  
23  
  ItIt<Int> it2 = cast leftArrowVerbose(
24  
    [[ for nested i in ll 2 3 { ll i (neg i) }]]
25  
  );
26  
  assertEqualsVerbose(ll(2, -2, 3, -3), asList(it2));
27  
  
28  
  // for nested + continue
29  
  
30  
  it2 = (ItIt) leftArrowVerbose([[
31  
    for nested i in ll 2 3 4 {
32  
      if eq i 3 { continue }
33  
      ll i (neg i)
34  
    }
35  
  ]]);
36  
  assertEqualsVerbose(ll(2, -2, 4, -4), asList(it2));
37  
}

Author comment

Began life as a copy of #1034763

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1035104
Snippet name: test_leftArrowScript_forIterator - test "for iterator" and "for nested"
Eternal ID of this version: #1035104/6
Text MD5: 680c2cad1ca796a69821aaadc4ec9e73
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-30 02:54:22
Source code size: 930 bytes / 37 lines
Pitched / IR pitched: No / No
Views / Downloads: 152 / 215
Version history: 5 change(s)
Referenced in: [show references]