Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 29cb21b

Browse filesBrowse files
committed
Add test with vader
1 parent 5804b8b commit 29cb21b
Copy full SHA for 29cb21b

File tree

Expand file treeCollapse file tree

5 files changed

+116
-0
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+116
-0
lines changed

‎.gitignore

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/vendor

‎README.md

Copy file name to clipboardExpand all lines: README.md
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,3 +381,12 @@ class Foo {
381381
`<Leader>da` will call your documentation plugin (by default Php Documentor for vim https://github.com/tobyS/pdv) for every uncommented classes, methods, functions and properties.
382382

383383

384+
## Running tests
385+
386+
```
387+
bin/test
388+
```
389+
390+
### How to write tests?
391+
392+
See https://github.com/junegunn/vader.vim

‎bin/test

Copy file name to clipboard
+31Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#! /bin/sh -eu
2+
3+
installVader ()
4+
{
5+
vaderdir='vendor/vader.vim'
6+
vaderCommit='6fff477431ac3191c69a3a5e5f187925466e275a'
7+
8+
test -d "$vaderdir" || {
9+
{
10+
git clone \
11+
--branch=master \
12+
--single-branch \
13+
https://github.com/junegunn/vader.vim.git \
14+
"$vaderdir"
15+
16+
git \
17+
--work-tree="$vaderdir" \
18+
--git-dir="$vaderdir/.git" \
19+
reset --hard \
20+
"$vaderCommit" --
21+
} || {
22+
rm -rf "$vaderdir"
23+
24+
exit 1
25+
}
26+
}
27+
}
28+
29+
installVader
30+
31+
vim -esNu test/fixtures/vimrc -c 'Vader! test/*'

‎test/extract_variable.vader

Copy file name to clipboard
+61Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
Given php (condition on if):
2+
<?php
3+
4+
$sentence = 'Hello';
5+
6+
if ('foo' === $firstName) {
7+
$sentence .= ' ' . $firstName;
8+
}
9+
10+
Do (select the condition and extract variable):
11+
/foo\<CR>
12+
vi(
13+
;ev
14+
firstNameIsValid\<CR>
15+
16+
Expect php (variable is extracted):
17+
<?php
18+
19+
$sentence = 'Hello';
20+
21+
$firstNameIsValid = 'foo' === $firstName;
22+
23+
if ($firstNameIsValid) {
24+
$sentence .= ' ' . $firstName;
25+
}
26+
27+
Given php (condition on if and on function):
28+
<?php
29+
30+
function prepareSentence()
31+
{
32+
$sentence = 'Hello';
33+
34+
if ('foo' === $firstName) {
35+
$sentence .= ' ' . $firstName;
36+
}
37+
38+
return $sentence;
39+
}
40+
41+
Do (select the condition and extract variable):
42+
/foo\<CR>
43+
vi(
44+
;ev
45+
firstNameIsValid\<CR>
46+
47+
Expect php (variable is extracted):
48+
<?php
49+
50+
function prepareSentence()
51+
{
52+
$sentence = 'Hello';
53+
54+
$firstNameIsValid = 'foo' === $firstName;
55+
56+
if ($firstNameIsValid) {
57+
$sentence .= ' ' . $firstName;
58+
}
59+
60+
return $sentence;
61+
}

‎test/fixtures/vimrc

Copy file name to clipboard
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
" Setup a testing environment that is isolated from the other plugins.
2+
"
3+
filetype off
4+
5+
set rtp+=vendor/vader.vim
6+
set rtp+=.
7+
set rtp+=after
8+
9+
filetype plugin on
10+
filetype indent on
11+
12+
syntax enable
13+
14+
let mapleader = ";"

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.