Esempio n. 1
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());
 }
Esempio n. 2
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");
  }
Esempio n. 3
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");
  }
Esempio n. 4
0
  @Test
  public void testCopyZeroSource() {
    Wasavi.send("i1\n2\n3\u001b");

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

    assertValue("!a\n!b");
  }
Esempio n. 6
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");
 }
Esempio n. 7
0
  @Test
  public void testSubst2() {
    Wasavi.send("iaaaa\nbbbb\u001b");
    Wasavi.send("1G", ":%s/a/b/g\n");

    assertValue("bbbb\nbbbb");
  }
Esempio n. 8
0
  @Test
  public void testWrite() {
    Wasavi.send("ifoobar\u001b");
    Wasavi.send(":write\n");

    String text = driver.findElement(By.id("t2")).getAttribute("value");
    assertEquals("#1-1", "foobar", text);
  }
Esempio n. 9
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");
  }
Esempio n. 10
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!");
  }
Esempio n. 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);
 }
Esempio n. 12
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);
 }
Esempio n. 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);
  }
Esempio n. 14
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");
  }
Esempio n. 15
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);
  }
Esempio n. 16
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");
  }
Esempio n. 17
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()));
  }
Esempio n. 18
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);
  }
Esempio n. 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);
  }
Esempio n. 20
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());
  }
Esempio n. 21
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);
  }
Esempio n. 22
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);
  }
Esempio n. 23
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*");
  }
Esempio n. 24
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());
  }
Esempio n. 25
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");
  }
Esempio n. 26
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);
  }
Esempio n. 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());
  }
Esempio n. 28
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");
  }
Esempio n. 29
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");
  }
Esempio n. 30
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);
  }