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

44
LINES

< > BotCompany Repo | #1031666 // Test ManagedStringList (seems OK!)

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Uses 12447K of libraries. Click here for Pure Java version (10656L/55K).

1  
cmodule2 TestManagedStringList > DynTestModule {
2  
  class Test {
3  
    PersistentManagedObjects_v1<ManagedStringList> pm = new(ManagedStringList.factory());
4  
    ManagedStringList l = new(pm.mem);
5  
    ListTester tester;
6  
    int garbageCollectAtLeastEvery = 10;
7  
  
8  
    run {
9  
      pm.setUserData(l);
10  
      tester = new ListTester(l, lambda1 rotate);
11  
      tester.rotateAtLeastEvery = 3;
12  
      tester.run();
13  
    }
14  
  
15  
    LS rotate(LS _l) {
16  
      print("Rotating. memSize=" + pm.mem.size() + ", free=" + pm.mem.freeList.totalFree);
17  
      //print("Free list: " + pm.mem.freeList.lengthStats());
18  
      print("Free list: " + pm.mem.freeList.asList());
19  
      pm.mem.freeList.sanityTest();
20  
      l.flush();
21  
      pm.setUserData(l);
22  
      pm.flush();
23  
      
24  
      bool gc = oneIn(tester.random, garbageCollectAtLeastEvery);
25  
      if (gc) {
26  
        print("GC!");
27  
        pm.collectAndCompact();
28  
        print("New mem size: " + pm.mem.size());
29  
      }
30  
      
31  
      S hex = print(intArrayToHex(takeFirst(40, pm.mem.mem)));
32  
      pm = pm.rotate();
33  
      if (!gc) {
34  
        S hex2 = print(intArrayToHex(takeFirst(40, pm.mem.mem)));
35  
        assertEquals(hex, hex2);
36  
      }
37  
      ret l = pm.getUserData();
38  
    }
39  
  }
40  
  
41  
  void test {
42  
    new Test().run();
43  
  }
44  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt

No comments. add comment

Snippet ID: #1031666
Snippet name: Test ManagedStringList (seems OK!)
Eternal ID of this version: #1031666/21
Text MD5: 9ecfcd3a0a98d576edcc813b72d83601
Transpilation MD5: 96bce3b19811d748a8477ab22ca91e66
Author: stefan
Category: javax
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-06-25 13:06:23
Source code size: 1285 bytes / 44 lines
Pitched / IR pitched: No / No
Views / Downloads: 247 / 690
Version history: 20 change(s)
Referenced in: [show references]