Пример #1
0
  @Test
  public void testAddressAll() {
    Wasavi.send("i1\n2\n3\u001b");
    Wasavi.send(":%p\n");
    assertEquals("#1-1", "1\n2\n3", Wasavi.getLastMessage());

    Wasavi.send(":% +1p\n\u001b");
    assertFalse("#2-1", "".equals(Wasavi.getLastMessage()));
  }
Пример #2
0
  @Test
  public void testNull() {
    Wasavi.send("i1\n2\n3\u001b");

    Wasavi.send("2G", ":\n");
    assertEquals("#1-1", "", Wasavi.getLastMessage());
    assertPos("#1-2", 1, 0);

    Wasavi.send(":||\n");
    assertEquals("#2-1", "2\n2", Wasavi.getLastMessage());
  }
Пример #3
0
  @Test
  public void testAbbreviate() {
    Wasavi.send(":abbreviate [clear]\n");
    Wasavi.send(":abbreviate\n");
    assertEquals("#1-1", "No abbreviations are defined.", Wasavi.getLastMessage());

    Wasavi.send(":abbreviat test\n");
    assertEquals("#2-1", "No abbreviations are defined.", Wasavi.getLastMessage());

    Wasavi.send(":abbrevia foo? bar\n");
    assertEquals(
        "#3-1",
        "abbreviate: The keyword of abbreviation must end with a word character.",
        Wasavi.getLastMessage());

    Wasavi.send(":abbrevi foo bar\n");
    assertTrue("#4-1", "".equals(Wasavi.getLastMessage()));
    Wasavi.send(":abbre\n");
    assertEquals("#4-2", join("\n", "*** abbreviations ***", "foo\tbar"), Wasavi.getLastMessage());

    Wasavi.send(":abbr bar BAZ\n");
    Wasavi.send(":abbr foo\n");
    assertEquals("#5-1", join("\n", "*** abbreviations ***", "foo\tbar"), Wasavi.getLastMessage());
    Wasavi.send(":abbr\n");
    assertEquals(
        "#5-2",
        join("\n", "*** abbreviations ***", "bar\tBAZ", "foo\tbar"),
        Wasavi.getLastMessage());

    Wasavi.send(":abb [clear]\n");
    Wasavi.send(":ab\n");
    assertEquals("#6-1", "No abbreviations are defined.", Wasavi.getLastMessage());
  }
Пример #4
0
 @Test
 public void testWriteReadonlyWarning() {
   Wasavi.send(":set readonly\n");
   Wasavi.send(":w\n");
   assertEquals(
       "#1-1", "write: Readonly option is set (use \"!\" to override).", Wasavi.getLastMessage());
 }
Пример #5
0
  @Test
  public void testRegisters() {
    Wasavi.send(":registers\n");
    assertEquals(
        "#1-1",
        join("\n", "*** registers ***", "\"\"  C  ", "\":  C  registers"),
        Wasavi.getLastMessage());

    Wasavi.send("i1\n2\n3\u001b");
    Wasavi.send("yy");
    Wasavi.send(":reg\n");
    assertEquals(
        "#2-1",
        join("\n", "*** registers ***", "\"\"  L  3^J", "\".  C  1^J2^J3", "\":  C  reg"),
        Wasavi.getLastMessage());
  }
Пример #6
0
  @Test
  public void testAddressOffsetInteger() {
    Wasavi.send("i1\n2\n3\u001b");

    Wasavi.send("2G", ":+0p\n");
    assertEquals("#1-1", "2", Wasavi.getLastMessage());

    Wasavi.send("2G", ":+p\n");
    assertEquals("#2-1", "3", Wasavi.getLastMessage());

    Wasavi.send("2G", ":-0p\n");
    assertEquals("#3-1", "2", Wasavi.getLastMessage());

    Wasavi.send("2G", ":-p\n");
    assertEquals("#4-1", "1", Wasavi.getLastMessage());
  }
Пример #7
0
  @Test
  public void testPut() {
    Wasavi.send("ifoo\nbar\u001b");

    Wasavi.send("1G", "1|yy");
    Wasavi.send(":put\n");
    assertValue("#1-1", "foo\nfoo\nbar");
    assertPos("#1-2", 1, 0);

    Wasavi.send("1G", "1|yw");
    Wasavi.send(":put\n");
    assertValue("#2-1", "foo\nfoo\nfoo\nbar");
    assertPos("#2-2", 1, 0);

    Wasavi.send("G", "\"ayy");
    Wasavi.send(":2pu a\n");
    assertValue("#3-1", "foo\nfoo\nbar\nfoo\nbar");
    assertPos("#3-2", 2, 0);

    Wasavi.send(":pu z\n");
    assertValue("#4-1", "foo\nfoo\nbar\nfoo\nbar");
    assertPos("#4-2", 2, 0);
    assertEquals("#4-3", "put: Register z is empty.", Wasavi.getLastMessage());

    setClipboardText("clipboard text");
    Wasavi.send("G", ":0pu *\n");
    assertValue("#5-1", "clipboard text\nfoo\nfoo\nbar\nfoo\nbar");
    assertPos("#5-2", 0, 0);
  }
Пример #8
0
 @Test
 public void testInvertedGlobalWithEmptyCommand() {
   Wasavi.send("ia\nb\nc\u001b");
   Wasavi.send(":v/b/\n");
   assertValue("#1-1", "a\nb\nc");
   assertEquals("#1-2", "", Wasavi.getLastMessage());
   assertPos("#1-3", 2, 0);
 }
Пример #9
0
  @Test
  public void testUnmap() {
    Wasavi.send(":map [clear]\n");
    Wasavi.send(":unmap\n");
    assertEquals("#1-1", "unmap: Invalid argument.", Wasavi.getLastMessage());

    Wasavi.send(":map H ^\n");
    Wasavi.send(":map\n");
    assertEquals("#1-1", join("\n", "*** command mode map ***", "H\t^"), Wasavi.getLastMessage());

    Wasavi.send(":unma xyz\n");
    assertEquals("#2-1", "unmap: xyz is not mapped.", Wasavi.getLastMessage());

    Wasavi.send(":unm H\n");
    Wasavi.send(":map\n");
    assertEquals("#3-1", "No mappings for command mode are defined.", Wasavi.getLastMessage());
  }
Пример #10
0
  @Test
  public void testUnabbreviate() {
    Wasavi.send(":ab foo bar\n:ab\n");
    assertEquals("#1-1", join("\n", "*** abbreviations ***", "foo\tbar"), Wasavi.getLastMessage());

    Wasavi.send(":unabbreviate\n");
    assertEquals("#2-1", "unabbreviate: Invalid argument.", Wasavi.getLastMessage());

    Wasavi.send(":unabb xyz\n");
    assertEquals("#3-1", "unabbreviate: xyz is not an abbreviation.", Wasavi.getLastMessage());

    Wasavi.send(":unabb foo\n");
    assertEquals("#4-1", "", Wasavi.getLastMessage());

    Wasavi.send(":ab\n");
    assertEquals("#5-1", "No abbreviations are defined.", Wasavi.getLastMessage());
  }
Пример #11
0
 @Test
 public void testGlobalWithEmptyCommand() {
   Wasavi.send("i1\n2\n3\u001b");
   Wasavi.send(":g/./\n");
   assertValue("#1-1", "1\n2\n3");
   assertEquals("#1-2", "", Wasavi.getLastMessage());
   assertPos("#1-3", 2, 0);
 }
Пример #12
0
  @Test
  public void testUndoAndRedo() {
    Wasavi.send(":undo\n");
    assertEquals("#1-1", "undo: No undo item.", Wasavi.getLastMessage());

    Wasavi.send("i1\n2\n3\u001b");
    assertValue("#2-1", "1\n2\n3");

    Wasavi.send(":undo\n");
    assertValue("#3-1", "");

    Wasavi.send(":redo\n");
    assertValue("#4-1", "1\n2\n3");

    Wasavi.send(":redo\n");
    assertEquals("#5-1", "redo: No redo item.", Wasavi.getLastMessage());
  }
Пример #13
0
  @Test
  public void testAddressMark() {
    Wasavi.send("i1\n2\n3\n4\u001b");

    Wasavi.send("4G", "ma1G", ":'ap\n");
    assertEquals("#1-1", "4", Wasavi.getLastMessage());
    assertPos("#1-2", 3, 0);
  }
Пример #14
0
  @Test
  public void testAddressCurrent() {
    Wasavi.send("i1\n2\n3\u001b");
    Wasavi.send("2G", ":.p\n");
    assertEquals("#1-1", "2", Wasavi.getLastMessage());

    Wasavi.send("2G", ":.+p\n");
    assertEquals("#2-1", "3", Wasavi.getLastMessage());
    assertPos("#2-2", 2, 0);
    Wasavi.send("2G", ":.+1p\n");
    assertEquals("#2-3", "3", Wasavi.getLastMessage());
    assertPos("#2-4", 2, 0);
    Wasavi.send("2G", ":. +1p\n");
    assertEquals("#2-5", "3", Wasavi.getLastMessage());
    assertPos("#2-6", 2, 0);

    Wasavi.send("2G", ":.-p\n");
    assertEquals("#3-1", "1", Wasavi.getLastMessage());
    assertPos("#3-2", 0, 0);
    Wasavi.send("2G", ":.-1p\n");
    assertEquals("#3-3", "1", Wasavi.getLastMessage());
    assertPos("#3-4", 0, 0);
    Wasavi.send("2G", ":. -1p\n");
    assertEquals("#3-5", "1", Wasavi.getLastMessage());
    assertPos("#3-6", 0, 0);
  }
Пример #15
0
  @Test
  public void testRangeStatic() {
    Wasavi.send(":set nowrapscan\n");
    Wasavi.send("i1 foo\n2 bar\n3 foo\n4 bar\n5 foo\u001b");

    /*
     * 1 foo *                        1 foo
     * 2 bar                          2 bar * selected range (reversed, causes an error)
     * 3 foo    -- :/foo/,/bar/p -->  3 foo *
     * 4 bar                          4 bar
     * 5 foo                          5 foo
     */
    Wasavi.send("1G", ":/foo/,/bar/p\n");
    assertEquals("#1-1", "The second address is smaller than the first.", Wasavi.getLastMessage());

    Wasavi.send("1G", ":/bar/,/foo/p\n");
    assertEquals("#2-1", "2 bar\n3 foo", Wasavi.getLastMessage());
  }
Пример #16
0
  @Test
  public void testNumericAddress() {
    Wasavi.send("i1\n2\n3\n4\n5\u001b");

    Wasavi.send(":1\n");
    assertPos("#1-1", 0, 0);

    Wasavi.send(":+2\n");
    assertPos("#2-1", 2, 0);

    Wasavi.send("1G", ":/5/\n");
    assertPos("#3-1", 4, 0);
    assertEquals("#3-2", "", Wasavi.getLastMessage());

    Wasavi.send("1G", ":/5\n");
    assertPos("#4-1", 4, 0);
    assertEquals("#4-2", "", Wasavi.getLastMessage());
  }
Пример #17
0
  @Test
  public void testGlobalRanged() {
    Wasavi.send("i1 x\n2 y\n3 z\n4 x\n5 y\n6 z\u001b");

    // ranged
    Wasavi.send(":3,5g/x/p\n");
    assertEquals("#1-1", "4 x", Wasavi.getLastMessage());
    assertPos("#1-2", 3, 0);
  }
Пример #18
0
  @Test
  public void testGlobalWithNestDeniedCommand() {
    Wasavi.send("i1\n2\n3\u001b");

    Wasavi.send(":g/./g/./d\n");
    assertEquals(
        "#1-1", "global: Cannot use the global or v command recursively.", Wasavi.getLastMessage());
    assertValue("#1-2", "1\n2\n3");
  }
Пример #19
0
  @Test
  public void testGlobalZeroMatch() {
    Wasavi.send("i1 x\n2 y\n3 z\n4 x\n5 y\n6 z\u001b");

    // zero match regexp
    Wasavi.send(":g/^/p\n");
    assertEquals("#1-1", "1 x\n2 y\n3 z\n4 x\n5 y\n6 z", Wasavi.getLastMessage());
    assertPos("#1-2", 5, 0);
  }
Пример #20
0
  @Test
  public void testGlobal() {
    Wasavi.send("i1 x\n2 y\n3 z\n4 x\n5 y\n6 z\u001b");

    // if range does not specified, all of text should be processed.
    Wasavi.send(":g/\\d/p\n");
    assertEquals("#1-1", "1 x\n2 y\n3 z\n4 x\n5 y\n6 z", Wasavi.getLastMessage());
    assertPos("#1-2", 5, 0);
  }
Пример #21
0
  @Test
  public void testMarks() {
    Wasavi.send("i1 first\n2 second\n3 third\u001b");

    Wasavi.send(":marks\n");
    assertEquals(
        "#1-1",
        join(
            "\n",
            "*** marks ***",
            "mark  line   col   text",
            "====  =====  ====  ====",
            " ^        3     6  3 third"),
        Wasavi.getLastMessage());

    Wasavi.send("1G", "1|:mark a\n");
    Wasavi.send(":marks\n");
    assertEquals(
        "#2-1",
        join(
            "\n",
            "*** marks ***",
            "mark  line   col   text",
            "====  =====  ====  ====",
            " ^        3     6  3 third",
            " '        3     6  3 third",
            " a        1     0  1 first"),
        Wasavi.getLastMessage());

    Wasavi.send("2G", "2|:mark b\n");
    Wasavi.send(":marks\n");
    assertEquals(
        "#3-1",
        join(
            "\n",
            "*** marks ***",
            "mark  line   col   text",
            "====  =====  ====  ====",
            " ^        3     6  3 third",
            " '        1     0  1 first",
            " a        1     0  1 first",
            " b        2     0  2 second"),
        Wasavi.getLastMessage());
  }
Пример #22
0
  @Test
  public void testRangeDynamic() {
    Wasavi.send(":set nowrapscan\n");
    Wasavi.send("i1 foo\n2 bar\n3 foo\n4 bar\n5 foo\u001b");

    /*
     * 1 foo *                        1 foo
     * 2 bar                          2 bar
     * 3 foo    -- :/foo/;/bar/p -->  3 foo * selected range
     * 4 bar                          4 bar *
     * 5 foo                          5 foo
     */
    Wasavi.send("1G", ":/foo/;/bar/p\n");
    assertEquals("#1-1", "3 foo\n4 bar", Wasavi.getLastMessage());

    // if dynamic address is out of range, causes an error (even command has roundMax flag)
    Wasavi.send("1G", ":100;?foo?\n");
    assertEquals("#2-1", "Out of range.", Wasavi.getLastMessage());
  }
Пример #23
0
  @Test
  public void testCopyBadDest() {
    Wasavi.send("i1\n2\n3\n4\n5\u001b");

    /*
     * should be an error if destination address does not specified
     */
    Wasavi.send(":1copy\n");
    assertEquals("#1-1", "copy: Invalid argument.", Wasavi.getLastMessage());
  }
Пример #24
0
  @Test
  public void testMark2() {
    Wasavi.send("i1\n2\n3\u001b");

    Wasavi.send(":2G\n:mark\n");
    assertEquals("#1-1", "mark: Invalid argument.", Wasavi.getLastMessage());

    Wasavi.send(":3G\n:mark a\n");
    Wasavi.send(":1\n:'a\n");
    assertPos("#2-1", 2, 0);
  }
Пример #25
0
  @Test
  public void testMap() {
    Wasavi.send(":map\n");
    assertEquals(
        "#1-1", join("\n", "No mappings for command mode are defined."), Wasavi.getLastMessage());

    Wasavi.send(":map Q 1G\n");
    Wasavi.send(":map XQ G\n");
    Wasavi.send(":map\n");
    assertEquals(
        "#2-1", join("\n", "*** command mode map ***", "Q \t1G", "XQ\tG"), Wasavi.getLastMessage());

    Wasavi.send(":map X\n");
    assertEquals("#3-1", join("\n", "*** command mode map ***", "XQ\tG"), Wasavi.getLastMessage());

    Wasavi.send(":map [clear]\n");
    Wasavi.send(":map\n");
    assertEquals(
        "#4-1", join("\n", "No mappings for command mode are defined."), Wasavi.getLastMessage());
  }
Пример #26
0
  @Test
  public void testJoinWithCount() {
    Wasavi.send("ifirst\nsecond\nthird\nfourth\u001b");

    /*
     * zero count is error.
     */
    Wasavi.send("1G", ":join0\n");
    assertEquals("#0-1", "join: Count may not be zero.", Wasavi.getLastMessage());
    assertValue("#0-2", "first\nsecond\nthird\nfourth");

    /*
     * no address was specified:
     *
     * first  * :j2       first second
     * second        -->  third
     * third              fourth
     * fourth
     */
    Wasavi.send("1G", ":joi!2\n");
    assertValue("#1-1", "firstsecond\nthird\nfourth");
    assertPos("#1-2", 0, 0);
    Wasavi.send("u");
    assertValue("#1-3", "first\nsecond\nthird\nfourth");

    /*
     * one address was specified:
     *
     * first               first
     * second * :2j2  -->  second third
     * third               fourth
     * fourth
     */
    Wasavi.send(":2jo 2\n");
    assertValue("#2-1", "first\nsecond third\nfourth");
    assertPos("#2-2", 1, 0);
    Wasavi.send("u");
    assertValue("#2-3", "first\nsecond\nthird\nfourth");

    /*
     * two addresses were specified:
     *
     * first  * :1,2j2       first second third
     * second           -->  fourth
     * third
     * fourth
     */
    Wasavi.send(":1,2j2\n");
    assertValue("#3-1", "first second third\nfourth");
    assertPos("#3-2", 0, 0);
    Wasavi.send("u");
    assertValue("#3-3", "first\nsecond\nthird\nfourth");
  }
Пример #27
0
  @Test
  public void testEditReload() {
    Wasavi.send("ifoo\u001b");

    Wasavi.send(":edit\n");
    assertEquals(
        "#1-1", "edit: File is modified; write or use \"!\" to override.", Wasavi.getLastMessage());
    assertValue("#1-2", "foo");

    Wasavi.send(":e!\n");
    assertEquals("#1-3", driver.findElement(By.id("t2")).getAttribute("value"), Wasavi.getValue());
  }
Пример #28
0
  @Test
  public void testAddressInteger() {
    Wasavi.send("i1\n2\n3\u001b");

    // sould be clipped
    Wasavi.send(":0p\n");
    assertEquals("#1-1", "1", Wasavi.getLastMessage());
    assertPos("#1-2", 0, 0);

    Wasavi.send(":1p\n");
    assertEquals("#2-1", "1", Wasavi.getLastMessage());
    assertPos("#2-2", 0, 0);

    Wasavi.send(":2p\n");
    assertEquals("#3-1", "2", Wasavi.getLastMessage());
    assertPos("#3-2", 1, 0);

    Wasavi.send(":3p\n");
    assertEquals("#4-1", "3", Wasavi.getLastMessage());
    assertPos("#4-2", 2, 0);

    // implicit print, sould be clipped
    Wasavi.send(":4\n");
    assertEquals("#5-1", "", Wasavi.getLastMessage());
    assertPos("#5-2", 2, 0);

    // explicit print, should be an error
    Wasavi.send(":4p\n");
    assertPos("#6-2", 2, 0);
    assertEquals("#6-1", "print: Out of range.", Wasavi.getLastMessage());
  }
Пример #29
0
  @Test
  public void testSubstPatternOmit() {
    Wasavi.send(":sushi\n");
    Wasavi.send("i1\n2\n3\u001b");

    Wasavi.send(":s//foo\n");
    assertEquals("#1-1", "s: No previous search pattern.", Wasavi.getLastMessage());

    Wasavi.send("gg", "/\\d\n");
    assertPos("#2-1", 1, 0);
    Wasavi.send(":s//foo\n");
    assertValue("#2-2", "1\nfoo\n3");
  }
Пример #30
0
  @Test
  public void testPrint() {
    Wasavi.send("i1\t$\u0016\u0010\\\n2\n3\n4\n5\u001b");

    Wasavi.send(":print\n");
    assertEquals("#1-1", "5", Wasavi.getLastMessage());

    Wasavi.send(":1,2print\n");
    assertEquals("#2-1", "1\t$\u0010\\\n2", Wasavi.getLastMessage());

    Wasavi.send(":2\n");
    Wasavi.send(":print3\n");
    assertEquals("#3-1", "2\n3\n4", Wasavi.getLastMessage());

    Wasavi.send(":1,3print2\n");
    assertEquals("#4-1", "3\n4", Wasavi.getLastMessage());

    /*
     * list command conversion:
     *
     * native       list
     * ------  -->  ----
     * 1            1
     * <u+0009>     <u+0009>
     * $            \$
     * <u+0010>     \020
     * \            \\
     * <eol>        $
     */
    Wasavi.send(":1p l\n");
    assertEquals("#5-1", "1\t\\$\\020\\\\$", Wasavi.getLastMessage());

    /*
     * number command
     *
     * number format: sprintf("%6d  ", line_number)
     */
    Wasavi.send(":1p #\n");
    assertEquals("#6-1", "     1  1\t$\u0010\\", Wasavi.getLastMessage());

    /*
     * number + line command
     */
    Wasavi.send(":1p #l\n");
    assertEquals("#7-1", "     1  1\t\\$\\020\\\\$", Wasavi.getLastMessage());
    Wasavi.send(":1p #lp\n");
    assertEquals("#7-2", "     1  1\t\\$\\020\\\\$", Wasavi.getLastMessage());
  }