Package com.google.collide.dto

Examples of com.google.collide.dto.DocOp


  }

  public void testSingleLineInsertVsInsertInMultiLineDocument() throws Exception {
    {
      // Simple test of a insertion
      DocOp c = dob.rl(3).b();
      DocOp s = dob.rl(1).i(TEN).eolR(1).rl(1).b();
      DocOp cPrime = dob.rl(3).b();
      DocOp sPrime = dob.rl(1).i(TEN).eolR(1).rl(1).b();
      new ReversibleTestParameters(c, s, cPrime, sPrime).run();
    }

    {
      // A's insertion spatially above B's insertion
      DocOp c = dob.r(5).i(FIVE).eolR(5).rl(2).b();
      DocOp s = dob.rl(2).i(TEN).eolR(10).b();
      DocOp cPrime = c;
      DocOp sPrime = s;
      new ReversibleTestParameters(c, s, cPrime, sPrime).run();
    }

    {
      // A's insertion spatially directly above B's insertion
      DocOp c = dob.r(5).i(FIVE).eolR(5).rl(1).b();
      DocOp s = dob.rl(1).i(TEN).eolR(10).b();
      DocOp cPrime = c;
      DocOp sPrime = s;
      new ReversibleTestParameters(c, s, cPrime, sPrime).run();
    }

    {
      // A's insertion spatially intertwined with B's insertion
      DocOp c = dob.r(5).i(FIVE).eolR(5).r(2).d(FIVE).r(4).b();
      DocOp s = dob.rl(1).i(TEN).eolR(11).b();
      DocOp cPrime = dob.r(5).i(FIVE).eolR(5).r(12).d(FIVE).r(4).b();
      DocOp sPrime = dob.rl(1).i(TEN).eolR(6).b();
      new ReversibleTestParameters(c, s, cPrime, sPrime).run();
    }

    {
      // A's insertion would be a subset of B's insertion if this were text
      // replacement
      DocOp c = dob.rl(2).r(5).i(FIVE).eolR(5).rl(2).b();
      DocOp s = dob.rl(2).r(2).i(TWENTY).eolR(8).rl(2).b();
      DocOp cPrime = dob.rl(2).r(25).i(FIVE).eolR(5).rl(2).b();
      DocOp sPrime = dob.rl(2).r(2).i(TWENTY).eolR(13).rl(2).b();
      new ReversibleTestParameters(c, s, cPrime, sPrime).run();
    }
  }
View Full Code Here


    }
  }

  public void testSubstituteRetainCountForRetainLineProcessor() throws Exception {
    {
      DocOp c = dob.rl(1).d("b").b();
      DocOp s = dob.r(1).d("\n").r(1).b();

      DocOp cPrime = dob.r(1).d("b").b();
      DocOp sPrime = dob.r(1).d("\n").b();
      new ReversibleTestParameters(c, s, cPrime, sPrime).run();
    }
    {
      DocOp c = dob.rl(1).i("a").r(1).b();
      DocOp s = dob.d("aaaa").r(3).d("\n").r(1).b();

      DocOp cPrime = dob.r(3).i("a").r(1).b();
      DocOp sPrime = dob.d("aaaa").r(3).d("\n").r(2).b();
      new ReversibleTestParameters(c, s, cPrime, sPrime).run();
    }
  }
View Full Code Here

  }
 
  public void testEmptyLineVsRetainLine() throws Exception {
    {
      // rl will match empty and nothing will be transformed
      DocOp c = dob.b();
      DocOp s = dob.rl(1).b();

      DocOp cPrime = dob.b();
      DocOp sPrime = dob.rl(1).b();
      new ReversibleTestParameters(c, s, cPrime, sPrime).run();
    }
    {
      // rl will match the empty string after the retain here as well
      DocOp c = dob.d("\n").b();
      DocOp s = dob.eolR(1).rl(1).b();

      DocOp cPrime = dob.d("\n").b();
      DocOp sPrime = dob.rl(1).b();
      new ReversibleTestParameters(c, s, cPrime, sPrime).run();
    }
    {
      // rl cannot suffix here since it can only span an entire line
      DocOp c = dob.r(2).d("\n").b();
      DocOp s = dob.r(1).d("a").eolR(1).rl(1).b();

      DocOp cPrime = dob.r(1).d("\n").b();
      DocOp sPrime = dob.r(1).d("a").rl(1).b();
      new ReversibleTestParameters(c, s, cPrime, sPrime).run();
    }
    {
      DocOp c = dob.r(5).b();
      DocOp s = dob.rl(1).b();

      new ReversibleTestParameters(c, s, c, s).run();
    }
  }
View Full Code Here

   * B: R(6)I(f)R(1\n)
   * @throws Exception
   */
  public void testThatTransformationDoesNotRemoveEmptyLineBeingRetainLine1() throws Exception {
    {
      DocOp s = dob.r(7).i("\n").rl(1).b();
      DocOp c = dob.r(6).i("f").r(1).b();
     
      DocOp sPrime = dob.r(8).i("\n").rl(1).b();
      DocOp cPrime = dob.r(6).i("f").eolR(2).rl(1).b();
     
      singleTest(c, s, cPrime, sPrime);
    }
   
    {
      DocOp s = dob.i("\n").rl(1).b();
      DocOp c = dob.i("f").b();
      DocOp cPrime = dob.i("f").eolR(1).rl(1).b();
      DocOp sPrime = dob.r(1).i("\n").rl(1).b();
      singleTest(c, s, cPrime, sPrime);
    }
   
    {
      DocOp s = dob.i("f").b();
      DocOp c = dob.i("\n").rl(1).b();
      DocOp sPrime = dob.eolR(1).i("f").b();
      singleTest(c, s, c, sPrime);
    }
     
    {
      DocOp s = dob.i("\n").rl(1).b();
      DocOp c = dob.i("f").r(1).b();
      DocOp cPrime = dob.i("f").eolR(1).r(1).b();
      DocOp sPrime = dob.r(1).i("\n").rl(1).b();
      singleTest(c, s, cPrime, sPrime);
    }
  }
View Full Code Here

      singleTest(c, s, cPrime, sPrime);
    }
  }
 
  public void testSimpleRetainLineOfEmptyLastLine() throws Exception {
    DocOp c = dob.i("alex\n").rl(2).b();
    DocOp s = dob.i("b").eolR(1).rl(1).b();
   
    DocOp sPrime = dob.eolR(5).i("b").eolR(1).rl(1).b();
   
    singleTest(c, s, c, sPrime);
  }
View Full Code Here

 
  public void testDeleteOfEmptyLastLine() throws Exception {
    // alex\n
    //
   
    DocOp c = dob.r(4).d("\n").rl(1).b();
    DocOp s = dob.i("a").eolR(5).rl(1).b();
   
    DocOp cPrime = dob.r(5).d("\n").rl(1).b();
    DocOp sPrime = dob.i("a").r(4).rl(1).b();
   
    new ReversibleTestParameters(s, c, sPrime, cPrime).run();
  }
View Full Code Here

    // Empty mutations

    {
      // This is an strange edge case, but might as well cover it
      doc = Document.createFromString("");
      DocOp actual = delete(0, 0, 0);
      DocOp expected = builder.rl(1).b();
      assertDocOpEquals(expected, actual);
    }

    {
      // This is an strange edge case, but might as well cover it
      doc = Document.createFromString("");
      DocOp actual = insert(0, 0, "");
      DocOp expected = builder.rl(1).b();
      assertDocOpEquals(expected, actual);
    }

    // Mutations without newlines

    {
      // Ensure no RL
      doc = Document.createFromString("");
      DocOp actual = insert(0, 0, "a");
      DocOp expected = builder.i("a").b();
      assertDocOpEquals(expected, actual);
    }

    {
      doc = Document.createFromString("a");
      DocOp actual = delete(0, 0, 1);
      DocOp expected = builder.d("a").rl(1).b();
      assertDocOpEquals(expected, actual);
    }

    // One/two-line documents and mutations with newlines

    {
      doc = Document.createFromString("");
      DocOp actual = insert(0, 0, "\n");
      DocOp expected = builder.i("\n").rl(1).b();
      assertDocOpEquals(expected, actual);
    }

    {
      doc = Document.createFromString("\n");
      DocOp actual = delete(0, 0, 1);
      DocOp expected = builder.d("\n").rl(1).b();
      assertDocOpEquals(expected, actual);
    }

    // Multiple line documents

    {
      doc = Document.createFromString("\n\n");
      DocOp actual = insert(0, 0, "\n");
      DocOp expected = builder.i("\n").eolR(1).rl(2).b();
      assertDocOpEquals(expected, actual);
    }

    {
      doc = Document.createFromString("\n\n");
      DocOp actual = insert(0, 0, "\n\n");
      DocOp expected = builder.i("\n").i("\n").eolR(1).rl(2).b();
      assertDocOpEquals(expected, actual);
    }

    {
      doc = Document.createFromString("\n\n");
      DocOp actual = delete(0, 0, 1);
      DocOp expected = builder.d("\n").eolR(1).rl(1).b();
      assertDocOpEquals(expected, actual);
    }

    {
      doc = Document.createFromString("\n\n");
      DocOp actual = delete(0, 0, 2);
      DocOp expected = builder.d("\n").d("\n").rl(1).b();
      assertDocOpEquals(expected, actual);
    }

    // Misc

    {
      doc = Document.createFromString("a\n");
      DocOp actual = insert(0, 0, "a");
      DocOp expected = builder.i("a").eolR(2).rl(1).b();
      assertDocOpEquals(expected, actual);
    }
  }
View Full Code Here

      assertDocOpEquals(expected, actual);
    }
  }

  public void testComposer() {
    DocOp a, b;
   
    // Insert vs Delete
    a = builder.i("a").b();
    b = builder.d("a").rl(1).b();
    assertCompose(builder.rl(1).b(), a, b);
View Full Code Here

  private TerseDocOpBuilder builder;

  public void testOneLastRetainLineMatchesOtherLastComponentWithoutNewline() {
    {
      DocOp a = builder.rl(1).b();
      DocOp b = builder.r(14).b();
      assertCompose(b, a, b);
    }

    {
      DocOp a = builder.rl(1).b();
      DocOp b = builder.d("test").b();
      assertCompose(b, a, b);
    }

    {
      DocOp a = builder.r(14).b();
      DocOp b = builder.rl(1).b();
      assertCompose(a, a, b);
    }

    {
      DocOp a = builder.i("test").b();
      DocOp b = builder.rl(1).b();
      assertCompose(a, a, b);
    }
  }
View Full Code Here

    assertCompose(builder.i("h").d("i").b(),
        builder.i("h").r(1).b(), builder.r(1).d("i").b());
  }

  public void testRetainLineIndependent() {
    DocOp a = builder.i("a\n").rl(1).b();
    DocOp b = builder.rl(2).i("b\n").b();
    assertCompose(builder.i("a\n").rl(1).i("b\n").b(), a, b);

    a = builder.d("a\n").rl(1).b();
    b = builder.i("b").eolR(1).b();
    assertCompose(builder.d("a\n").i("b").eolR(1).b(), a, b);
View Full Code Here

TOP

Related Classes of com.google.collide.dto.DocOp

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.