Ejemplo n.º 1
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");
  }
Ejemplo n.º 2
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");
  }
Ejemplo n.º 3
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");
 }
Ejemplo n.º 4
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);
  }
Ejemplo n.º 5
0
  @Test
  public void testSubstMatchedEmpty() {
    Wasavi.send(":sushi\n");
    Wasavi.send("i1*\n012\n3*\u001b");

    Wasavi.send("1G", ":s/\\*\\?$/<\\/li>/g\n");
    assertValue("#1-1", "1</li>\n012\n3*");

    Wasavi.send("2G", ":s/a\\?/!/g\n");
    assertValue("#1-2", "1</li>\n!0!1!2\n3*");
  }
Ejemplo n.º 6
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);
  }
Ejemplo n.º 7
0
  @Test
  public void testSubstLastReplacement() {
    Wasavi.send(":sushi\n");
    Wasavi.send("i1\n2\n3\u001b");

    Wasavi.send(":s/\\d/%\n");
    assertEquals("#1-1", "s: No previous substitution.", Wasavi.getLastMessage());

    Wasavi.send(":s/\\d/!\n");
    assertValue("#2-1", "1\n2\n!");
    Wasavi.send(":1\n");
    Wasavi.send(":s/\\d/%\n");
    assertValue("#2-2", "!\n2\n!");
  }
Ejemplo n.º 8
0
  @Test
  public void testSubstOmitAll() {
    Wasavi.send(":sushi\n");
    Wasavi.send("i1\n2\n3\u001b");

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

    Wasavi.send(":s/\\d/foo\n");
    assertValue("#2-1", "1\n2\nfoo");
    Wasavi.send(":1\n");
    Wasavi.send(":s//\n");
    assertValue("#2-2", "foo\n2\nfoo");
  }
Ejemplo n.º 9
0
  @Test
  public void testSubstAnd2() {
    Wasavi.send(":sushi\n");
    Wasavi.send("i1\n2\n3\u001b");

    Wasavi.send("&");
    assertEquals("#1-1", "&: No previous search pattern.", Wasavi.getLastMessage());

    Wasavi.send("1G", ":s/\\d/!/c\ny");
    assertValue("#2-1", "!\n2\n3");

    Wasavi.send("2G", "&");
    assertValue("#3-1", "!\n!\n3");
  }
Ejemplo n.º 10
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");
  }
Ejemplo n.º 11
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");
  }
Ejemplo n.º 12
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");
  }
Ejemplo n.º 13
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");
  }
Ejemplo n.º 14
0
  @Test
  public void testSubst2() {
    Wasavi.send("iaaaa\nbbbb\u001b");
    Wasavi.send("1G", ":%s/a/b/g\n");

    assertValue("bbbb\nbbbb");
  }
Ejemplo n.º 15
0
  @Test
  public void testCopyZeroSource() {
    Wasavi.send("i1\n2\n3\u001b");

    Wasavi.send(":0copy2\n");
    assertValue("#1-1", "1\n2\n1\n3");
  }
Ejemplo n.º 16
0
  @Test
  public void testSubst3() {
    Wasavi.send("i\ta\n\tb\u001b");
    Wasavi.send("1G", ":%s/^\\t\\+/!/g\n");

    assertValue("!a\n!b");
  }
Ejemplo n.º 17
0
  @Test
  public void testSubstQueried() {
    Wasavi.send("ifirst\nsecond\nthird\u001b");

    Wasavi.send("1G", ":%s/i/I/gc\n");
    Wasavi.send("y", "y");
    assertEquals("#1-1", "2 substitutions on 3 lines.", Wasavi.getLastMessage());
    assertValue("#1-2", "fIrst\nsecond\nthIrd");
    assertPos("#1-3", 2, 0);

    Wasavi.send("u");
    assertValue("#2-1", "fIrst\nsecond\nthird");

    Wasavi.send("u");
    assertValue("#3-1", "first\nsecond\nthird");
  }
Ejemplo n.º 18
0
  @Test
  public void testSubstUpper() {
    Wasavi.send("ifirst\nsecond\nthird\u001b");
    Wasavi.send(":%s/\\w\\+/\\u&/g\n");
    assertValue("#1-1", "First\nSecond\nThird");

    Wasavi.send("u");
    assertValue("#2-1", "first\nsecond\nthird");
    Wasavi.send(":%s/\\w\\+/\\U&/g\n");
    assertValue("#2-2", "FIRST\nSECOND\nTHIRD");

    Wasavi.send("u");
    assertValue("#3-1", "first\nsecond\nthird");
    Wasavi.send(":%s/\\w\\+/\\U&\\E \\uline/g\n");
    assertValue("#3-2", "FIRST Line\nSECOND Line\nTHIRD Line");
  }
Ejemplo n.º 19
0
  @Test
  public void testSubstLower() {
    Wasavi.send("iFIRST\nSECOND\nTHIRD\u001b");
    Wasavi.send(":%s/\\w\\+/\\l&/g\n");
    assertValue("#1-1", "fIRST\nsECOND\ntHIRD");

    Wasavi.send("u");
    assertValue("#2-1", "FIRST\nSECOND\nTHIRD");
    Wasavi.send(":%s/\\w\\+/\\L&/g\n");
    assertValue("#2-2", "first\nsecond\nthird");

    Wasavi.send("u");
    assertValue("#3-1", "FIRST\nSECOND\nTHIRD");
    Wasavi.send(":%s/\\w\\+/\\L&\\E \\lLine/g\n");
    assertValue("#3-2", "first line\nsecond line\nthird line");
  }
Ejemplo n.º 20
0
  @Test
  public void testAbbreviateAction() {
    Wasavi.send(":ab foo FOO\n");
    Wasavi.send("ifoo bar foo\u001b");
    assertValue("#1-1", "FOO bar FOO");

    Wasavi.send(":unab foo\n");
  }
Ejemplo n.º 21
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());
  }
Ejemplo n.º 22
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);
 }
Ejemplo n.º 23
0
  @Test
  public void testSubstReplOmit() {
    Wasavi.send(":sushi\n");
    Wasavi.send("i1\n2\n3\u001b");

    Wasavi.send(":s/\\d//\n");
    assertValue("#1-1", "1\n2\n");
  }
Ejemplo n.º 24
0
  @Test
  public void testEditMapUnique() {
    Wasavi.send(":map! [clear]\n");
    Wasavi.send(":map! Q quick\u0016\u0016 brown\u0016\u0016 fox\n");

    Wasavi.send("iQ!\u001b");
    assertValue("#1-1", "quick brown fox!");
  }
Ejemplo n.º 25
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");
  }
Ejemplo n.º 26
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);
 }
Ejemplo n.º 27
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");
  }
Ejemplo n.º 28
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");
  }
Ejemplo n.º 29
0
  @Test
  public void testSubstTilde() {
    Wasavi.send(":sushi\n");
    Wasavi.send("i1\n2\n3\u001b");

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

    Wasavi.send("1G", ":s/\\d/&!/c\ny");
    assertValue("#2-1", "1!\n2\n3");

    Wasavi.send("2G", ":~\n");
    assertValue("#3-1", "1!\n2!\n3");

    Wasavi.send(":%~g\n");
    assertValue("#4-1", "1!!\n2!!\n3!");

    Wasavi.send("1G", "/!\n");
    Wasavi.send(":%~g\n");
    assertValue("#5-1", "1!!!!\n2!!!!\n3!!");
  }
Ejemplo n.º 30
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());
  }