diff options
| author | Adam Stankiewicz <sheerun@sher.pl> | 2013-09-12 16:26:29 +0200 | 
|---|---|---|
| committer | Adam Stankiewicz <sheerun@sher.pl> | 2013-09-12 16:26:29 +0200 | 
| commit | 591d4d2517b86f6c4b88bf165fb9c01dcb861727 (patch) | |
| tree | 39f8cd5e5aa3bae95ceb78f153520f41a201fefb /ftplugin/go/test.sh | |
| parent | 9fa15ece8b6a08fe035669708db50ba76c93b2aa (diff) | |
| download | vim-polyglot-591d4d2517b86f6c4b88bf165fb9c01dcb861727.tar.gz vim-polyglot-591d4d2517b86f6c4b88bf165fb9c01dcb861727.zip  | |
Add go language support
Diffstat (limited to '')
| -rwxr-xr-x | ftplugin/go/test.sh | 78 | 
1 files changed, 78 insertions, 0 deletions
diff --git a/ftplugin/go/test.sh b/ftplugin/go/test.sh new file mode 100755 index 00000000..d8a5b895 --- /dev/null +++ b/ftplugin/go/test.sh @@ -0,0 +1,78 @@ +#!/bin/bash -e +# +# Copyright 2012 The Go Authors. All rights reserved. +# Use of this source code is governed by a BSD-style +# license that can be found in the LICENSE file. +# +# Tests for import.vim. + +cd $(dirname $0) + +cat > base.go <<EOF +package test + +import ( +	"bytes" +	"io" +	"net" + +	"mycorp/foo" +) +EOF + +fail=0 + +# usage: test_one command pattern +# Pattern is a PCRE expression that will match across lines. +test_one() { +  echo 2>&1 -n "$1: " +  vim -e -s -u /dev/null -U /dev/null --noplugin -c "source import.vim" \ +    -c "$1" -c 'wq! test.go' base.go +  # ensure blank lines are treated correctly +  if ! gofmt test.go | cmp test.go -; then +    echo 2>&1 "gofmt conflict" +    gofmt test.go | diff -u test.go - | sed "s/^/	/" 2>&1 +    fail=1 +    return +  fi +  if ! [[ $(cat test.go) =~ $2 ]]; then +    echo 2>&1 "$2 did not match" +    cat test.go | sed "s/^/	/" 2>&1 +    fail=1 +    return +  fi +  echo 2>&1 "ok" +} + +# Tests for Import + +test_one "Import baz" '"baz".*"bytes"' +test_one "Import io/ioutil" '"io".*"io/ioutil".*"net"' +test_one "Import myc" '"io".*"myc".*"net"'  # prefix of a site prefix +test_one "Import nat" '"io".*"nat".*"net"' +test_one "Import net/http" '"net".*"net/http".*"mycorp/foo"' +test_one "Import zoo" '"net".*"zoo".*"mycorp/foo"' +test_one "Import mycorp/bar" '"net".*"mycorp/bar".*"mycorp/foo"' +test_one "Import mycorp/goo" '"net".*"mycorp/foo".*"mycorp/goo"' + +# Tests for Drop + +cat > base.go <<EOF +package test + +import ( +	"foo" + +	"something" +	"zoo" +) +EOF + +test_one "Drop something" '\([^"]*"foo"[^"]*"zoo"[^"]*\)' + +rm -f base.go test.go +if [ $fail -gt 0 ]; then +  echo 2>&1 "FAIL" +  exit 1 +fi +echo 2>&1 "PASS"  | 
