Skip to content

Commit

Permalink
Add vader tests bundle for aligning
Browse files Browse the repository at this point in the history
  • Loading branch information
Felixoid committed Aug 8, 2018
1 parent 545e6f1 commit 5e559e7
Show file tree
Hide file tree
Showing 3 changed files with 142 additions and 0 deletions.
137 changes: 137 additions & 0 deletions test/aligning/bundle.vader
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
Given puppet (Sample class):
class some::example (
# It's not possible to allign class without leading spaces/tabs. Sad but true
$the_most_longest_argument,
String $arg2,
$arg3=4,
$rsa_private_key = undef,
Type::Server::Hostname $hostname =$::hostname,
Type::Inet $intern_ip= $::intern_ip,
Optional[Type::Inet6] $primary_ip6 = defined('$::primary_ip6') ? {
true=>$::primary_ip6,
false=> undef,
},
# comment with => and $var inside
# comment with only =>
# comment with only $argument
Type::Server::Hostname $project = $::project,
Enum[
'online',
'offline',
'WIP'
] $state= $::state,
String[1] $environment = $::environment,
Optional[String[1]] $function = $::function,
Type::Server::Hostname $monitoring_queue = $::monitoring_queue,
Array[Pattern[/\A[a-z][a-z0-9_-]*\Z/]] $monitoring_checks =$::monitoring_checks,
Optional[Type::Server::Hostname] $project_network= defined('$::project_network') ? {
true => $::project_network,
false =>undef,
default=>'',
},
) {
file { '/just_example':
ensure=>'directory',
require=>Package['example'],
}
}

Execute (Tabularize class and resource):
2 Tabularize puppet_class
33 Tabularize puppet_class

Expect (Aligning works fine):
class some::example (
# It's not possible to allign class without leading spaces/tabs. Sad but true
$the_most_longest_argument,
String $arg2,
$arg3 = 4,
$rsa_private_key = undef,
Type::Server::Hostname $hostname = $::hostname,
Type::Inet $intern_ip = $::intern_ip,
Optional[Type::Inet6] $primary_ip6 = defined('$::primary_ip6') ? {
true => $::primary_ip6,
false => undef,
},
# comment with => and $var inside
# comment with only =>
# comment with only $argument
Type::Server::Hostname $project = $::project,
Enum[
'online',
'offline',
'WIP'
] $state = $::state,
String[1] $environment = $::environment,
Optional[String[1]] $function = $::function,
Type::Server::Hostname $monitoring_queue = $::monitoring_queue,
Array[Pattern[/\A[a-z][a-z0-9_-]*\Z/]] $monitoring_checks = $::monitoring_checks,
Optional[Type::Server::Hostname] $project_network = defined('$::project_network') ? {
true => $::project_network,
false => undef,
default => '',
},
) {
file { '/just_example':
ensure => 'directory',
require => Package['example'],
}
}

Given puppet (Resource brakes by Tabularize):
# Another useful case
# Breaks by <C-a>, works with => autoalignment
if $rsa_private_key != undef {
some::cool::helper { $user:
home_dir=> '/home/user',
authorized_keys =>[
convert_ssh_rsa_private_to_public_key($rsa_private_key)
],
rsa_private_key =>$rsa_private_key,
}
}

Execute (Tabularize in 4th line):
4 Tabularize puppet_class

Expect (Unhappily, the aligning here is broken):
# Another useful case
# Breaks by <C-a>, works with => autoalignment
if $rsa_private_key! = undef {
some::cool::helper { $user :
home_dir => '/home/user',
authorized_keys => [
convert_ssh_rsa_private_to_public_key($rsa_private_key)
],
rsa_private_key => $rsa_private_key,
}
}

Given puppet (Resource brakes by Tabularize):
# Another useful case
# Breaks by <C-a>, works with => autoalignment
if $rsa_private_key != undef {
some::cool::helper { $user:
home_dir=> '/home/user',
authorized_keys =>[
convert_ssh_rsa_private_to_public_key($rsa_private_key)
],
rsa_private_key =>$rsa_private_key,
}
}

Do (Apply '=>' aligning):
4jf=2s=>

Expect (Aligning with '=>' works):
# Another useful case
# Breaks by <C-a>, works with => autoalignment
if $rsa_private_key != undef {
some::cool::helper { $user:
home_dir => '/home/user',
authorized_keys => [
convert_ssh_rsa_private_to_public_key($rsa_private_key)
],
rsa_private_key => $rsa_private_key,
}
}
1 change: 1 addition & 0 deletions test/init.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
set nocompatible
filetype off
set rtp+=vader.vim
set rtp+=tabular
set rtp+=.
set rtp+=after
filetype plugin indent on
Expand Down
4 changes: 4 additions & 0 deletions test/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ cd "${SCRIPT_FOLDER}/.."
if [ ! -d "vader.vim" ]; then
git clone https://github.com/junegunn/vader.vim.git
fi
if [ ! -d "tabular" ]; then
git clone https://github.com/godlygeek/tabular.git
fi


"${RUNVIM}" -u test/init.vim -c 'Vader! test/**/*.vader' > /dev/null
vader_exit=$?
Expand Down

0 comments on commit 5e559e7

Please sign in to comment.