diff options
author | Gustaf Lindstedt <gustaflindstedt@gmail.com> | 2015-03-15 21:14:31 +0800 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2015-03-20 18:19:19 -0400 |
commit | a9e6a768c5a59a1ab69ccfbfb37c8939583a0284 (patch) | |
tree | 61c9c7be374e1667f396c19342e89d23fa7acc8f | |
parent | 26e6bca769ca5972063657bb01f157523d51c44f (diff) | |
download | rneovim-a9e6a768c5a59a1ab69ccfbfb37c8939583a0284.tar.gz rneovim-a9e6a768c5a59a1ab69ccfbfb37c8939583a0284.tar.bz2 rneovim-a9e6a768c5a59a1ab69ccfbfb37c8939583a0284.zip |
legacy test script: minor string handling fix #2181
Add check to see if a string contains ], which can result in
cases where wrapping a string in [[...]] breaks. Use [=[...]=] instead
on those strings.
Use [=[...]=] for insert() and expect().
-rwxr-xr-x | scripts/legacy2luatest.pl | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/scripts/legacy2luatest.pl b/scripts/legacy2luatest.pl index fb14da8157..51997c037b 100755 --- a/scripts/legacy2luatest.pl +++ b/scripts/legacy2luatest.pl @@ -54,9 +54,9 @@ sub read_in_file { if (@{$input_lines}) { my $last_input_line = pop @{$input_lines}; unshift @{$command_lines}, ''; - unshift @{$command_lines}, $last_input_line . ']])'; + unshift @{$command_lines}, $last_input_line . ']=])'; unshift @{$command_lines}, @{$input_lines}; - unshift @{$command_lines}, "insert([["; + unshift @{$command_lines}, "insert([=["; @{$input_lines} = (); } @@ -133,8 +133,15 @@ sub read_in_file { # If line contains single quotes or backslashes, use double # square brackets to wrap string. if (/'/ || /\\/) { - $startstr = '[['; - $endstr = ']]'; + # If the line contains a closing square bracket, + # wrap it with [=[...]=]. + if (/\]/) { + $startstr = '[=['; + $endstr = ']=]'; + } else { + $startstr = '[['; + $endstr = ']]'; + } } # Emit 'feed' if not a search ('/') or ex (':') command. @@ -190,7 +197,7 @@ sub read_ok_file { if (-f $ok_file) { push @assertions, ''; push @assertions, "-- Assert buffer contents."; - push @assertions, "expect([["; + push @assertions, "expect([=["; open my $ok_file_handle, '<', $ok_file; @@ -202,7 +209,7 @@ sub read_ok_file { close $ok_file_handle; - $assertions[-1] .= "]])"; + $assertions[-1] .= "]=])"; } return \@assertions; |