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).

cmodule2 TestManagedStringList > DynTestModule {
  class Test {
    PersistentManagedObjects_v1<ManagedStringList> pm = new(ManagedStringList.factory());
    ManagedStringList l = new(pm.mem);
    ListTester tester;
    int garbageCollectAtLeastEvery = 10;
  
    run {
      pm.setUserData(l);
      tester = new ListTester(l, lambda1 rotate);
      tester.rotateAtLeastEvery = 3;
      tester.run();
    }
  
    LS rotate(LS _l) {
      print("Rotating. memSize=" + pm.mem.size() + ", free=" + pm.mem.freeList.totalFree);
      //print("Free list: " + pm.mem.freeList.lengthStats());
      print("Free list: " + pm.mem.freeList.asList());
      pm.mem.freeList.sanityTest();
      l.flush();
      pm.setUserData(l);
      pm.flush();
      
      bool gc = oneIn(tester.random, garbageCollectAtLeastEvery);
      if (gc) {
        print("GC!");
        pm.collectAndCompact();
        print("New mem size: " + pm.mem.size());
      }
      
      S hex = print(intArrayToHex(takeFirst(40, pm.mem.mem)));
      pm = pm.rotate();
      if (!gc) {
        S hex2 = print(intArrayToHex(takeFirst(40, pm.mem.mem)));
        assertEquals(hex, hex2);
      }
      ret l = pm.getUserData();
    }
  }
  
  void test {
    new Test().run();
  }
}

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: 167 / 590
Version history: 20 change(s)
Referenced in: [show references]