Package com.google.javascript.jscomp.regex

Examples of com.google.javascript.jscomp.regex.CharRanges


    //     0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0
    // b-a  DD         DD DDD        D      DDD
    // a      AAAAAAAAA      A A A A   A AAA   AAA A A
    // b    BBB  BBB  BBB BBB        B B    BBB
    // a-b     DD   DD       D D D D     DDD   DDD D D
    CharRanges a = CharRanges.withRanges(new int[] {
        0x03, 0x0C, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
        0x1C, 0x1D, 0x1E, 0x21, 0x24, 0x27, 0x28, 0x29, 0x2A, 0x2B });
    CharRanges b = CharRanges.withRanges(new int[] {
        0x01, 0x04, 0x06, 0x09, 0x0B, 0x0E, 0x0F, 0x12, 0x1A, 0x1B,
        0x1C, 0x1D, 0x21, 0x24 });
    CharRanges empty = CharRanges.withMembers(new int[0]);

    assertEquals(empty, empty.union(empty));
    assertEquals(a, a.union(empty));
    assertEquals(b, empty.union(b));

    CharRanges aSb = a.difference(b);
    assertEquals(
        "[0x4-0x5 0x9-0xa 0x12 0x14 0x16 0x18 0x1e-0x20 0x24-0x26 0x28 0x2a]",
        aSb.toString());
    assertTrue(a.containsAll(aSb));
    assertFalse(aSb.containsAll(a));
    assertFalse(aSb.containsAll(b));

    CharRanges bSa = b.difference(a);
    assertEquals(
        "[0x1-0x2 0xc-0xd 0xf-0x11 0x1a 0x21-0x23]",
        bSa.toString());
    assertTrue(b.containsAll(bSa));
    assertFalse(bSa.containsAll(a));
    assertFalse(bSa.containsAll(b));

    // Check that a and b not changed by operation
    assertEquals(
        "[0x3-0xb 0x12 0x14 0x16 0x18 0x1c 0x1e-0x20 0x24-0x26 0x28 0x2a]",
        a.toString());
    assertEquals(
        "[0x1-0x3 0x6-0x8 0xb-0xd 0xf-0x11 0x1a 0x1c 0x21-0x23]",
        b.toString());

    //    0 1 2 3 4 5 6 7 8 9 a b c d e f
    // m: * * * *     *     * *       * *
    // s:     *     * * *     * *   * *
    // d: * *   *           *           *
    CharRanges m = CharRanges.withMembers(0, 1, 2, 3, 6, 9, 0xa, 0xe, 0xf);
    CharRanges s = CharRanges.withMembers(2, 5, 6, 7, 0xa, 0xb, 0xd, 0xe);
    CharRanges d = m.difference(s);
    assertEquals("[0x0-0x1 0x3 0x9 0xf]", d.toString());
    assertTrue(m.containsAll(d));
    assertFalse(d.containsAll(m));
    assertFalse(d.containsAll(s));
    assertFalse(s.containsAll(d));
    assertTrue(d.containsAll(d));
  }
View Full Code Here


    //                 1               2               3
    // 0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0
    //    AAAAAAAAA      A A A A   A AAA   AAA A A
    //  BBB  BBB  BBB BBB        B B    BBB
    //  UUUUUUUUUUUUU UUUU U U U U U UUUUUUUUU U U
    CharRanges a = CharRanges.withRanges(new int[] {
        0x03, 0x0C, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
        0x1C, 0x1D, 0x1E, 0x21, 0x24, 0x27, 0x28, 0x29, 0x2A, 0x2B });
    CharRanges b = CharRanges.withRanges(new int[] {
        0x01, 0x04, 0x06, 0x09, 0x0B, 0x0E, 0x0F, 0x12, 0x1A, 0x1B,
        0x1C, 0x1D, 0x21, 0x24 });
    CharRanges empty = CharRanges.withMembers(new int[0]);

    assertEquals(empty, empty.union(empty));
    assertEquals(a, a.union(empty));
    assertEquals(b, empty.union(b));

    CharRanges aUb = a.union(b);
    assertEquals(
        "[0x1-0xd 0xf-0x12 0x14 0x16 0x18 0x1a 0x1c 0x1e-0x26 0x28 0x2a]",
        aUb.toString());
    assertEquals(aUb, b.union(a));
    assertTrue(aUb.containsAll(a));
    assertTrue(aUb.containsAll(b));
    assertFalse(a.containsAll(b));
    assertFalse(b.containsAll(a));
    assertTrue(a.containsAll(a));
    assertTrue(b.containsAll(b));
    assertTrue(aUb.containsAll(aUb));

    // Check that a and b not changed by operation
    assertEquals(
        "[0x3-0xb 0x12 0x14 0x16 0x18 0x1c 0x1e-0x20 0x24-0x26 0x28 0x2a]",
        a.toString());
View Full Code Here

TOP

Related Classes of com.google.javascript.jscomp.regex.CharRanges

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.