Пример #1
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);
  }
Пример #2
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");
  }
Пример #3
0
  @Test
  public void testMapUnique() {
    Wasavi.send(":map [clear]\n");
    Wasavi.send(":map Q G\ni1\n2\n3\u001bgg");
    assertPos("#1-1", 0, 0);
    Wasavi.send("Q");
    assertPos("#2-1", 2, 0);

    Wasavi.send(":map <f1> <esc>if1\u0016\u0016 key\u0016\u0016 pressed<esc>\n");
    Wasavi.send(Keys.F1);
    assertValue("#3-1", "1\n2\nf1 key pressed3");
  }
Пример #4
0
  @Test
  public void testSubstNewline() {
    Wasavi.send("i1\n2\n3\n4\u001b");
    Wasavi.send(":%s/\\d/&\\nline/g\n");
    assertValue("#1-1", "1\nline\n2\nline\n3\nline\n4\nline");
    assertPos("#1-2", 7, 0);

    Wasavi.send(":1\n");
    Wasavi.send(":s/\\d/&\u0016\012LINE/g\n");
    assertValue("#2-1", "1\nLINE\nline\n2\nline\n3\nline\n4\nline");
    assertPos("#2-2", 1, 0);
  }
Пример #5
0
  @Test
  public void testSubstQueriedNonMatch() {
    Wasavi.send("ifirst\nsecond\nthird\u001b");

    Wasavi.send("2G", "3|");
    Wasavi.send(":%s/foo/bar/gc\n");
    assertPos("#1-1", 1, 2);

    Wasavi.send("1G", "1|");
    Wasavi.send(":%s/i/!/gc\n");
    Wasavi.send("yn");
    assertPos("#2-1", 2, 0);
  }
Пример #6
0
  @Test
  public void mapSpecialKey() {
    Wasavi.send(":map [clear]\n");
    Wasavi.send(":map Q <down><down>$\n");

    Wasavi.send("i1\n2\n3 here!\n4\u001bgg");
    assertPos("#1-1", 0, 0);
    Wasavi.send("Q");
    assertPos("#1-2", 2, 6);

    Wasavi.send(":map <down> <up>\nG");
    Wasavi.send(Keys.ARROW_DOWN);
    assertPos("#2-1", 2, 0);
  }
Пример #7
0
  @Test
  public void testNestedMap() {
    Wasavi.send(":map [clear]\n");
    Wasavi.send(":map Q G\n");
    Wasavi.send(":map q Q\n");
    Wasavi.send("i1\n2\n3\n4\n5\u001b");

    Wasavi.send("ggq");
    assertPos("#1-1", 4, 0);

    Wasavi.send(":map [noremap] q Q\n");
    Wasavi.send("ggq");
    assertPos("#2-1", 0, 0);
  }
Пример #8
0
  @Test
  public void testGlobalDeleteSpecial() {
    Wasavi.send("i1\n2\n3\n4\n5\n6\u001b");

    /*
     * :g/\d/+1d
     *
     * 1     1*     1      1
     * 2     3      3*     3
     * 3 --> 4  --> 5  --> 5*
     * 4     5      6
     * 5     6
     * 6
     *
     * *: current corsor line
     */

    Wasavi.send(":g/\\d/+1d\n");
    assertValue("#1-1", "1\n3\n5");
    assertPos("#1-2", 2, 0);

    Wasavi.send("u");
    assertValue("#2-1", "1\n2\n3\n4\n5\n6");

    Wasavi.send("\u0012");
    assertValue("#3-1", "1\n3\n5");
  }
Пример #9
0
 @Test
 public void testCopyToLower() {
   Wasavi.send("i1\n2\n3\n4\n5\u001b");
   /*
    * copy to lower line
    * ---------
    *  s: source range
    *  d: destination position
    *  *: copied line
    *
    * 1 d     1 d
    * 2 s     2 *
    * 3 s --> 3 * final cursor line
    * 4       2 s
    * 5       3 s
    *         4
    *         5
    */
   Wasavi.send(":2,3cop1\n");
   assertValue("#1-1", "1\n2\n3\n2\n3\n4\n5");
   assertPos("#1-2", 2, 0);
   Wasavi.send("u");
   assertValue("#1-3", "1\n2\n3\n4\n5");
   Wasavi.send("\u0012");
   assertValue("#1-4", "1\n2\n3\n2\n3\n4\n5");
 }
Пример #10
0
  @Test
  public void testDeleteByCountWithRange() {
    /*
     * if both range and count are specified, first range should be discarded:
     *
     * 1                        1
     * 2 first                  2 first
     * 3                        3
     * 4 second  -- :2,4d2 -->  6
     * 5                        7
     * 6
     * 7
     *
     * or in other words, :2,4d2 == 4,5d
     */
    Wasavi.send("i1\n2\n3\n4\n5\n6\n7\u001b");

    Wasavi.send(":2, 4d2\n");
    assertValue("#1-1", "1\n2\n3\n6\n7");
    assertPos("#1-2", 3, 0);
    assertEquals("#1-3", "4\n5\n", Wasavi.getRegister("\""));

    Wasavi.send("u");
    assertValue("#2-1", "1\n2\n3\n4\n5\n6\n7");

    Wasavi.send("\u0012");
    assertValue("#3-1", "1\n2\n3\n6\n7");
  }
Пример #11
0
  @Test
  public void testJoinWithNoCount() {
    Wasavi.send("ifirst\nsecond\nthird\nfourth\u001b");

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

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

    /*
     * two addresses were specified:
     *
     * first  *              first second third
     * second    :1,3j  -->  fourth
     * third
     * fourth
     */
    Wasavi.send(":1,3j\n");
    assertValue("#3-1", "first second third\nfourth");
    assertPos("#3-2", 0, 0);
    Wasavi.send("u");
    assertValue("#3-3", "first\nsecond\nthird\nfourth");
  }
Пример #12
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);
 }
Пример #13
0
  @Test
  public void testUnshiftMulti() {
    Wasavi.send(":set sw=8 noai\n");
    Wasavi.send("i\t\t\t1\n\t2\n3\u001b");
    Wasavi.send("1G", "1|");
    assertPos("#1-1", 0, 0);

    Wasavi.send(":<<2\n");
    assertValue("#2-1", "\t1\n2\n3");
    assertPos("#2-2", 1, 0);

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

    Wasavi.send(":redo\n");
    assertValue("#4-1", "\t1\n2\n3");
  }
Пример #14
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);
 }
Пример #15
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);
  }
Пример #16
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);
  }
Пример #17
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());
  }
Пример #18
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);
  }
Пример #19
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);
  }
Пример #20
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());
  }
Пример #21
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);
  }
Пример #22
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);
  }
Пример #23
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());
  }
Пример #24
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");
  }
Пример #25
0
  @Test
  public void testMapAmbiguous() {
    Wasavi.send(":map [clear]\n");
    Wasavi.send(":map Q 1G\n");
    Wasavi.send(":map QQ G\n");
    Wasavi.send("i1\n2\n3\n4\n5\u001b");

    // ambiguous, timed out
    Wasavi.send("Q");
    assertPos("#1-1", 0, 0);

    // ambiguous, not timed out
    Wasavi.send("G", "Qj");
    assertPos("#2-1", 1, 0);

    //
    Wasavi.send("QQ");
    assertPos("#3-1", 4, 0);

    //
    Wasavi.send("QQk");
    assertPos("#4-1", 3, 0);
  }
Пример #26
0
  @Test
  public void testExecuteRegister() {
    Wasavi.send("is/\\d/\tfoo\u0016\u001b\\n\u0016\u0009\u001b");
    assertValue("#1-1", "s/\\d/\tfoo\u001b\\n\t");
    Wasavi.send("\"ayy");
    assertEquals("#1-2", "s/\\d/\tfoo\u001b\\n\t\n", Wasavi.getRegister("a"));
    Wasavi.send("u");
    assertValue("#1-3", "");
    assertPos("#1-4", 0, 0);

    Wasavi.send("i1\n2\n3\u001b");
    Wasavi.send(":%@a\n");
    assertValue("#2-1", "1\n2\n\tfoo\u001b\n\t");
  }
Пример #27
0
  @Test
  public void testDeleteByCount() {
    Wasavi.send("i1\n2\n3\n4\n5\u001b");

    Wasavi.send(":2dele3\n");
    assertValue("#1-1", "1\n5");
    assertPos("#1-2", 1, 0);
    assertEquals("#1-3", "2\n3\n4\n", Wasavi.getRegister("\""));

    Wasavi.send("u");
    assertValue("#2-1", "1\n2\n3\n4\n5");

    Wasavi.send("\u0012");
    assertValue("#3-1", "1\n5");
  }
Пример #28
0
  @Test
  public void testYank() {
    Wasavi.send(":set noai\n");
    Wasavi.send("i\t1.\n2.\n3.\u001b");
    Wasavi.send("1G", "$");
    assertPos("#1-1", 0, 2);

    Wasavi.send(":yank\n");
    assertEquals("#2-1", "\t1.\n", Wasavi.getRegister("\""));
    assertPos("#2-2", 0, 2);

    Wasavi.send(":1,2yan a\n");
    assertEquals("#3-1", "\t1.\n2.\n", Wasavi.getRegister("a"));
    assertPos("#3-2", 0, 2);

    Wasavi.send(":2,3yan *\n");
    assertEquals("#4-1", "2.\n3.\n", Wasavi.getRegister("*"));
    assertEquals("#4-2", "2.\n3.\n", getClipboardText());
    assertPos("#4-3", 0, 2);

    Wasavi.send(":ya10\n");
    assertEquals("#5-1", "\t1.\n2.\n3.\n", Wasavi.getRegister("\""));
    assertPos("#5-2", 0, 2);
  }
Пример #29
0
  @Test
  public void testDeleteZeroSource() {
    Wasavi.send("i1\n2\n3\n4\n5\u001b");

    Wasavi.send(":0,2delete\n");
    assertValue("#1-1", "3\n4\n5");
    assertPos("#1-2", 0, 0);
    assertEquals("#1-3", "1\n2\n", Wasavi.getRegister("\""));

    Wasavi.send("u");
    assertValue("#2-1", "1\n2\n3\n4\n5");

    Wasavi.send("\u0012");
    assertValue("#3-1", "3\n4\n5");
  }
Пример #30
0
  @Test
  public void testDeleteTail() {
    Wasavi.send("i1\n2\n3\n4\n5\u001b");

    Wasavi.send(":4,5delet a\n");
    assertValue("#1-1", "1\n2\n3");
    assertPos("#1-2", 2, 0);
    assertEquals("#1-3", "4\n5\n", Wasavi.getRegister("a"));

    Wasavi.send("u");
    assertValue("#2-1", "1\n2\n3\n4\n5");

    Wasavi.send("\u0012");
    assertValue("#3-1", "1\n2\n3");
  }