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.

!include once #1034831 // Gazelle 22 Function Include for Testing

svoid test_leftArrowScript_forIterator() {
  ItIt<Pair<Int, Long>> it = cast leftArrowVerbose(
    [[ for iterator i in ll 2 3 { pair i (nanoTime) }]]
  );
  assertTrue(it.hasNext();
  long time = nanoTime();
  sleep(1);
  var p = it.next();
  assertEquals(2, p.a);
  assertTrue(p.b > time);
  time = p.b;
  sleep(1);
  assertTrue(it.hasNext();
  p = it.next();
  assertEquals(3, p.a);
  assertTrue(p.b > time);
  assertFalse(it.hasNext());
  
  // for nested
  
  ItIt<Int> it2 = cast leftArrowVerbose(
    [[ for nested i in ll 2 3 { ll i (neg i) }]]
  );
  assertEqualsVerbose(ll(2, -2, 3, -3), asList(it2));
  
  // for nested + continue
  
  it2 = (ItIt) leftArrowVerbose([[
    for nested i in ll 2 3 4 {
      if eq i 3 { continue }
      ll i (neg i)
    }
  ]]);
  assertEqualsVerbose(ll(2, -2, 4, -4), asList(it2));
}

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: 151 / 212
Version history: 5 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)