Package memory.trailing

Examples of memory.trailing.EnvironmentTrailing


*/
public class StoredIntLinkedListTest {

    @Test(groups = "1s")
    public void test1() {
        EnvironmentTrailing environment = new EnvironmentTrailing();
        Set_Std_LinkedList llist = new Set_Std_LinkedList(environment);

        Assert.assertFalse(llist.contain(1));
        Assert.assertFalse(llist.contain(2));
        Assert.assertFalse(llist.contain(3));

        environment.worldPush();

        llist.add(1);
        llist.add(2);
        Assert.assertTrue(llist.contain(1));
        Assert.assertTrue(llist.contain(2));
        Assert.assertFalse(llist.contain(3));

        environment.worldPop();

        Assert.assertFalse(llist.contain(1));
        Assert.assertFalse(llist.contain(2));
        Assert.assertFalse(llist.contain(3));
        llist.add(1);
        llist.add(2);
        Assert.assertTrue(llist.contain(1));
        Assert.assertTrue(llist.contain(2));
        Assert.assertFalse(llist.contain(3));

        environment.worldPush();

        Assert.assertTrue(llist.contain(1));
        Assert.assertTrue(llist.contain(2));
        Assert.assertFalse(llist.contain(3));
        llist.remove(2);
        llist.add(3);
        Assert.assertTrue(llist.contain(1));
        Assert.assertFalse(llist.contain(2));
        Assert.assertTrue(llist.contain(3));

        environment.worldPop();

        Assert.assertTrue(llist.contain(1));
        Assert.assertTrue(llist.contain(2));
        Assert.assertFalse(llist.contain(3));

View Full Code Here


    }

    @Test(groups = "1s")
    public void test2() {
        EnvironmentTrailing environment = new EnvironmentTrailing();
        Set_Std_LinkedList llist = new Set_Std_LinkedList(environment);

        int n = 100;

        for (int i = 0; i < n; i++) {
            Assert.assertFalse(llist.contain(i));
            Assert.assertFalse(llist.contain(i + 1));

            llist.add(i);
            Assert.assertTrue(llist.contain(i));

            environment.worldPush();
            llist.remove(i);
            llist.add(i + 1);

            environment.worldPush();
            Assert.assertFalse(llist.contain(i));
            Assert.assertTrue(llist.contain(i + 1));
            environment.worldPop();
            Assert.assertFalse(llist.contain(i));
            Assert.assertTrue(llist.contain(i + 1));
            environment.worldPop();
            Assert.assertTrue(llist.contain(i));
        }
        for (int i = 0; i < n; i++) {
            Assert.assertTrue(llist.contain(i));
        }
View Full Code Here

    }

    @Test(groups = "10s")
    public void test3() {
        EnvironmentTrailing environment = new EnvironmentTrailing();
        Set_Std_LinkedList llist = new Set_Std_LinkedList(environment);

        int n = 49999;

        environment.worldPush();
        for (int i = 0; i < n; i++) {
            llist.add(i);
            Assert.assertTrue(llist.contain(i));
            environment.worldPush();
        }
        environment.worldPop();
        for (int i = n - 1; i >= 0; i--) {
            Assert.assertTrue(llist.contain(i));
            environment.worldPop();
            Assert.assertFalse(llist.contain(i));
        }

    }
View Full Code Here

public class BasicIndexBipartiteSetTest {


    @Test(groups = "1s")
    public void test1() {
        IEnvironment env = new EnvironmentTrailing();
        BasicIndexedBipartiteSet set = new BasicIndexedBipartiteSet(env, 2);

        int b1 = set.add();
        int b2 = set.add();
        int b3 = set.add();
        int b4 = set.add();

        set.swap(b2);

        Assert.assertTrue(set.bundle(b1));
        Assert.assertFalse(set.bundle(b2));
        Assert.assertTrue(set.bundle(b3));
        Assert.assertTrue(set.bundle(b4));

        env.worldPush();
        set.swap(b3); // b3 is now fixed
        int b5 = set.add();

        Assert.assertTrue(set.bundle(b1));
        Assert.assertFalse(set.bundle(b2));
        Assert.assertFalse(set.bundle(b3));
        Assert.assertTrue(set.bundle(b4));
        Assert.assertTrue(set.bundle(b5));

        env.worldPush();

        set.swap(b1); // b1 is now fixed

        int b6 = set.add();
        set.swap(b6);

        Assert.assertFalse(set.bundle(b1));
        Assert.assertFalse(set.bundle(b2));
        Assert.assertFalse(set.bundle(b3));
        Assert.assertTrue(set.bundle(b4));
        Assert.assertTrue(set.bundle(b5));
        Assert.assertFalse(set.bundle(b6));

        // go back
        env.worldPop();
        Assert.assertTrue(set.bundle(b1));
        Assert.assertFalse(set.bundle(b2));
        Assert.assertFalse(set.bundle(b3));
        Assert.assertTrue(set.bundle(b4));
        Assert.assertTrue(set.bundle(b5));
        Assert.assertTrue(set.bundle(b6));

        env.worldPop();
        Assert.assertTrue(set.bundle(b1));
        Assert.assertFalse(set.bundle(b2));
        Assert.assertTrue(set.bundle(b3));
        Assert.assertTrue(set.bundle(b4));
        Assert.assertTrue(set.bundle(b5));
        Assert.assertTrue(set.bundle(b6));

        env.worldPop();
        Assert.assertTrue(set.bundle(b1));
        Assert.assertFalse(set.bundle(b2));
        Assert.assertTrue(set.bundle(b3));
        Assert.assertTrue(set.bundle(b4));
        Assert.assertTrue(set.bundle(b5));
View Full Code Here

*/
public class DynamicAdditionTest {

    @Test(groups = "1s")
    public void test1() {
        IEnvironment environment = new EnvironmentTrailing();
        environment.buildFakeHistoryOn(new Except_0(environment));
        IStateInt a = environment.makeInt(10);
        a.set(11);
        environment.worldPush();

        IStateInt b = environment.makeInt(21);
        a.set(12);
        b.set(22);
        environment.worldPush();

        IStateInt c = environment.makeInt(32);
        a.set(13);
        b.set(23);
        c.set(33);
        environment.worldPush();

        IStateInt d = environment.makeInt(43);
        a.set(14);
        b.set(24);
        c.set(34);
        d.set(44);
        environment.worldPush();

        a.set(15);
        b.set(25);
        c.set(35);
        d.set(45);


        Assert.assertEquals(a.get(), 15);
        Assert.assertEquals(b.get(), 25);
        Assert.assertEquals(c.get(), 35);
        Assert.assertEquals(d.get(), 45);

        // then roll back and assert
        environment.worldPop();
        Assert.assertEquals(a.get(), 14);
        Assert.assertEquals(b.get(), 24);
        Assert.assertEquals(c.get(), 34);
        Assert.assertEquals(d.get(), 44);

        environment.worldPop();
        Assert.assertEquals(a.get(), 13);
        Assert.assertEquals(b.get(), 23);
        Assert.assertEquals(c.get(), 33);
        Assert.assertEquals(d.get(), 43);

        environment.worldPop();
        Assert.assertEquals(a.get(), 12);
        Assert.assertEquals(b.get(), 22);
        Assert.assertEquals(c.get(), 32);
        Assert.assertEquals(d.get(), 43);

        environment.worldPop();
        Assert.assertEquals(a.get(), 11);
        Assert.assertEquals(b.get(), 21);
        Assert.assertEquals(c.get(), 32);
        Assert.assertEquals(d.get(), 43);

View Full Code Here

TOP

Related Classes of memory.trailing.EnvironmentTrailing

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.