├── .gitignore ├── .travis.yml ├── BUILD.bazel ├── Gopkg.lock ├── Gopkg.toml ├── LICENSE ├── README.md ├── WORKSPACE ├── breakpoint.go ├── breakpoint_test.go ├── context.go ├── context_test.go ├── doc.go ├── examples_test.go └── vendor └── github.com ├── gopherjs └── gopherjs │ ├── .gitignore │ ├── BUILD.bazel │ ├── LICENSE │ ├── README.md │ ├── build │ ├── BUILD.bazel │ ├── build.go │ └── build_test.go │ ├── circle.yml │ ├── compiler │ ├── BUILD.bazel │ ├── analysis │ │ ├── BUILD.bazel │ │ ├── bool.go │ │ ├── break.go │ │ ├── escape.go │ │ ├── info.go │ │ └── sideeffect.go │ ├── astutil │ │ ├── BUILD.bazel │ │ └── astutil.go │ ├── compiler.go │ ├── expressions.go │ ├── filter │ │ ├── BUILD.bazel │ │ ├── assign.go │ │ └── incdecstmt.go │ ├── natives │ │ ├── BUILD.bazel │ │ ├── doc.go │ │ ├── fs.go │ │ ├── fs_vfsdata.go │ │ └── src │ │ │ ├── bytes │ │ │ ├── bytes.go │ │ │ └── bytes_test.go │ │ │ ├── crypto │ │ │ ├── rand │ │ │ │ └── rand.go │ │ │ └── x509 │ │ │ │ ├── x509.go │ │ │ │ └── x509_test.go │ │ │ ├── database │ │ │ └── sql │ │ │ │ └── driver │ │ │ │ └── driver_test.go │ │ │ ├── debug │ │ │ └── elf │ │ │ │ └── elf_test.go │ │ │ ├── encoding │ │ │ ├── gob │ │ │ │ └── gob_test.go │ │ │ └── json │ │ │ │ └── stream_test.go │ │ │ ├── fmt │ │ │ └── fmt_test.go │ │ │ ├── go │ │ │ └── token │ │ │ │ └── token_test.go │ │ │ ├── internal │ │ │ ├── poll │ │ │ │ └── fd_poll_js.go │ │ │ └── testenv │ │ │ │ └── testenv.go │ │ │ ├── io │ │ │ └── io_test.go │ │ │ ├── math │ │ │ ├── big │ │ │ │ ├── big.go │ │ │ │ └── big_test.go │ │ │ ├── math.go │ │ │ ├── math_test.go │ │ │ └── rand │ │ │ │ └── rand_test.go │ │ │ ├── net │ │ │ ├── http │ │ │ │ ├── cookiejar │ │ │ │ │ └── example_test.go │ │ │ │ ├── fetch.go │ │ │ │ └── http.go │ │ │ └── net.go │ │ │ ├── os │ │ │ ├── os.go │ │ │ └── signal │ │ │ │ └── signal.go │ │ │ ├── reflect │ │ │ ├── example_test.go │ │ │ ├── reflect.go │ │ │ ├── reflect_test.go │ │ │ └── swapper.go │ │ │ ├── regexp │ │ │ └── regexp_test.go │ │ │ ├── runtime │ │ │ ├── debug │ │ │ │ └── debug.go │ │ │ ├── pprof │ │ │ │ └── pprof.go │ │ │ └── runtime.go │ │ │ ├── strings │ │ │ └── strings.go │ │ │ ├── sync │ │ │ ├── atomic │ │ │ │ ├── atomic.go │ │ │ │ └── atomic_test.go │ │ │ ├── cond.go │ │ │ ├── export_test.go │ │ │ ├── pool.go │ │ │ ├── sync.go │ │ │ ├── sync_test.go │ │ │ └── waitgroup.go │ │ │ ├── syscall │ │ │ ├── syscall.go │ │ │ ├── syscall_unix.go │ │ │ └── syscall_windows.go │ │ │ ├── testing │ │ │ ├── example.go │ │ │ ├── ioutil.go │ │ │ └── testing.go │ │ │ ├── text │ │ │ └── template │ │ │ │ └── template.go │ │ │ ├── time │ │ │ └── time.go │ │ │ └── unicode │ │ │ └── unicode.go │ ├── package.go │ ├── prelude │ │ ├── BUILD.bazel │ │ ├── goroutines.go │ │ ├── jsmapping.go │ │ ├── numeric.go │ │ ├── prelude.go │ │ └── types.go │ ├── statements.go │ ├── typesutil │ │ ├── BUILD.bazel │ │ └── typesutil.go │ ├── utils.go │ └── version_check.go │ ├── doc │ ├── packages.md │ └── syscalls.md │ ├── internal │ └── sysutil │ │ ├── BUILD.bazel │ │ ├── sysutil.go │ │ └── sysutil_windows.go │ ├── js │ ├── BUILD.bazel │ ├── js.go │ └── js_test.go │ ├── node-syscall │ ├── binding.gyp │ └── syscall.cc │ ├── nosync │ ├── BUILD.bazel │ ├── map.go │ ├── mutex.go │ ├── once.go │ └── pool.go │ ├── tests │ ├── BUILD.bazel │ ├── alias_test.go │ ├── copy_test.go │ ├── deferblock_test.go │ ├── doc.go │ ├── gorepo_test.go │ ├── goroutine_test.go │ ├── lowlevel_test.go │ ├── main │ │ ├── BUILD.bazel │ │ ├── main.go │ │ └── main_test.go │ ├── misc_test.go │ ├── otherpkg │ │ ├── BUILD.bazel │ │ └── otherpkg.go │ ├── run.go │ └── testdata │ │ ├── BUILD.bazel │ │ ├── time_inexternalization.go │ │ └── time_inexternalization.out │ └── tool.go ├── jtolds └── gls │ ├── BUILD.bazel │ ├── LICENSE │ ├── README.md │ ├── context.go │ ├── context_test.go │ ├── gen_sym.go │ ├── gid.go │ ├── id_pool.go │ ├── stack_tags.go │ ├── stack_tags_js.go │ └── stack_tags_main.go └── smartystreets ├── assertions ├── .gitignore ├── .travis.yml ├── BUILD.bazel ├── CONTRIBUTING.md ├── LICENSE.md ├── README.md ├── collections.go ├── collections_test.go ├── doc.go ├── doc_test.go ├── equal_method.go ├── equal_method_test.go ├── equality.go ├── equality_test.go ├── filter.go ├── internal │ ├── Makefile │ ├── go-render │ │ ├── .travis.yml │ │ ├── LICENSE │ │ ├── PRESUBMIT.py │ │ ├── README.md │ │ ├── WATCHLISTS │ │ ├── pre-commit-go.yml │ │ └── render │ │ │ ├── BUILD.bazel │ │ │ └── render.go │ └── oglematchers │ │ ├── .gitignore │ │ ├── .travis.yml │ │ ├── BUILD.bazel │ │ ├── LICENSE │ │ ├── README.md │ │ ├── any_of.go │ │ ├── contains.go │ │ ├── deep_equals.go │ │ ├── equals.go │ │ ├── greater_or_equal.go │ │ ├── greater_than.go │ │ ├── less_or_equal.go │ │ ├── less_than.go │ │ ├── matcher.go │ │ ├── not.go │ │ └── transform_description.go ├── messages.go ├── panic.go ├── panic_test.go ├── quantity.go ├── quantity_test.go ├── serializer.go ├── serializer_test.go ├── should │ ├── BUILD.bazel │ └── should.go ├── strings.go ├── strings_test.go ├── time.go ├── time_test.go ├── type.go ├── type_test.go └── utilities_for_test.go └── goconvey ├── .gitattributes ├── .gitignore ├── .travis.yml ├── BUILD.bazel ├── CONTRIBUTING.md ├── LICENSE.md ├── README.md ├── convey ├── BUILD.bazel ├── assertions.go ├── context.go ├── convey.goconvey ├── discovery.go ├── doc.go ├── focused_execution_test.go ├── gotest │ ├── BUILD.bazel │ ├── doc_test.go │ └── utils.go ├── init.go ├── isolated_execution_test.go ├── nilReporter.go ├── reporting │ ├── BUILD.bazel │ ├── console.go │ ├── doc.go │ ├── dot.go │ ├── dot_test.go │ ├── gotest.go │ ├── gotest_test.go │ ├── init.go │ ├── json.go │ ├── printer.go │ ├── printer_test.go │ ├── problems.go │ ├── problems_test.go │ ├── reporter.go │ ├── reporter_test.go │ ├── reporting.goconvey │ ├── reports.go │ ├── statistics.go │ └── story.go ├── reporting_hooks_test.go └── story_conventions_test.go ├── dependencies.go ├── examples ├── BUILD.bazel ├── assertion_examples_test.go ├── bowling_game.go ├── bowling_game_test.go ├── doc.go ├── examples.goconvey └── simple_example_test.go ├── goconvey.go └── web ├── client ├── composer.html ├── favicon.ico ├── index.html └── resources │ ├── css │ ├── common.css │ ├── composer.css │ ├── themes │ │ ├── dark-bigtext.css │ │ ├── dark.css │ │ └── light.css │ └── tipsy.css │ ├── fonts │ ├── FontAwesome │ │ ├── README.md │ │ ├── css │ │ │ └── font-awesome.css │ │ └── fonts │ │ │ ├── FontAwesome.otf │ │ │ ├── fontawesome-webfont.eot │ │ │ ├── fontawesome-webfont.svg │ │ │ ├── fontawesome-webfont.ttf │ │ │ ├── fontawesome-webfont.woff │ │ │ └── fontawesome-webfont.woff2 │ ├── Open_Sans │ │ ├── LICENSE.txt │ │ ├── OpenSans-Bold.ttf │ │ ├── OpenSans-Italic.ttf │ │ ├── OpenSans-Light.ttf │ │ ├── OpenSans-LightItalic.ttf │ │ └── OpenSans-Regular.ttf │ ├── Orbitron │ │ ├── OFL.txt │ │ └── Orbitron-Regular.ttf │ └── Oswald │ │ ├── OFL.txt │ │ └── Oswald-Regular.ttf │ ├── ico │ ├── goconvey-buildfail.ico │ ├── goconvey-fail.ico │ ├── goconvey-ok.ico │ └── goconvey-panic.ico │ └── js │ ├── composer.js │ ├── config.js │ ├── convey.js │ ├── goconvey.js │ ├── lib │ ├── ansispan.js │ ├── diff_match_patch.js │ ├── jquery-ui.js │ ├── jquery-ui.js.url │ ├── jquery.js │ ├── jquery.js.url │ ├── jquery.pretty-text-diff.js │ ├── jquery.pretty-text-diff.js.url │ ├── jquery.tipsy.js │ ├── jquery.tipsy.js.url │ ├── markup.js │ ├── markup.js.url │ ├── moment.js │ ├── moment.js.url │ ├── taboverride.js │ └── taboverride.js.url │ └── poller.js └── server ├── api ├── BUILD.bazel ├── api.goconvey ├── server.go └── server_test.go ├── contract ├── BUILD.bazel ├── contracts.go ├── doc_test.go └── result.go ├── executor ├── BUILD.bazel ├── contract.go ├── coordinator.go ├── executor.go ├── executor.goconvey ├── executor_test.go ├── tester.go └── tester_test.go ├── messaging ├── BUILD.bazel ├── doc_test.go └── messages.go ├── parser ├── BUILD.bazel ├── packageParser.go ├── package_parser_test.go ├── parser.go ├── parser.goconvey ├── parser_test.go ├── rules.go ├── testParser.go └── util.go ├── system ├── BUILD.bazel ├── shell.go ├── shell_integration_test.go ├── shell_test.go └── system.goconvey └── watch ├── BUILD.bazel ├── functional_core.go ├── functional_core_test.go ├── imperative_shell.go ├── integration.go ├── integration_test.go ├── integration_testing ├── BUILD.bazel ├── doc_test.go ├── main.go └── sub │ ├── .gitignore │ ├── BUILD.bazel │ ├── stuff.go │ ├── stuff_test.go │ └── sub.goconvey ├── util_test.go └── watch.goconvey /.gitignore: -------------------------------------------------------------------------------- 1 | .*.sw? 2 | bazel-* 3 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | dist: trusty 2 | sudo: required 3 | language: java 4 | os: 5 | - linux 6 | env: 7 | - V=0.5.3 8 | notifications: 9 | email: false 10 | before_install: 11 | - | 12 | OS=linux 13 | URL="https://github.com/bazelbuild/bazel/releases/download/${V}/bazel-${V}-installer-${OS}-x86_64.sh" 14 | wget -O install.sh "${URL}" 15 | chmod +x install.sh 16 | ./install.sh --user 17 | rm -f install.sh 18 | script: 19 | - bazel test :all 20 | -------------------------------------------------------------------------------- /BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "gazelle", "go_library", "go_prefix", "go_test") 2 | 3 | gazelle( 4 | name = "gazelle", 5 | command = "fix", 6 | external = "vendored", 7 | prefix = "euphoria.io/scope", 8 | ) 9 | 10 | go_prefix("euphoria.io/scope") 11 | 12 | go_library( 13 | name = "scope", 14 | srcs = glob(include=["*.go"], exclude=["*_test.go"]), 15 | visibility = ["//visibility:public"], 16 | ) 17 | 18 | go_test( 19 | name = "scope_test", 20 | srcs = glob(include=["*_test.go"], exclude=["examples_test.go"]), 21 | library = ":scope", 22 | deps = ["//vendor/github.com/smartystreets/goconvey/convey:go_default_library"], 23 | size = "small", 24 | ) 25 | 26 | go_test( 27 | name = "examples_test", 28 | srcs = ["examples_test.go"], 29 | deps = [":scope"], 30 | size = "small", 31 | ) 32 | -------------------------------------------------------------------------------- /Gopkg.lock: -------------------------------------------------------------------------------- 1 | # This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. 2 | 3 | 4 | [[projects]] 5 | branch = "master" 6 | name = "github.com/gopherjs/gopherjs" 7 | packages = ["js"] 8 | revision = "b40cd48c38f9a18eb3db20d163bad78de12cf0b7" 9 | 10 | [[projects]] 11 | name = "github.com/jtolds/gls" 12 | packages = ["."] 13 | revision = "77f18212c9c7edc9bd6a33d383a7b545ce62f064" 14 | version = "v4.2.1" 15 | 16 | [[projects]] 17 | name = "github.com/smartystreets/assertions" 18 | packages = [".","internal/go-render/render","internal/oglematchers"] 19 | revision = "9c0ea8acbc1d8ad689f9e6fe0c1fa5838e0cabc2" 20 | version = "1.7.0" 21 | 22 | [[projects]] 23 | name = "github.com/smartystreets/goconvey" 24 | packages = ["convey","convey/gotest","convey/reporting"] 25 | revision = "9e8dc3f972df6c8fcc0375ef492c24d0bb204857" 26 | version = "1.6.3" 27 | 28 | [solve-meta] 29 | analyzer-name = "dep" 30 | analyzer-version = 1 31 | inputs-digest = "40aa5c474be7fa9b112d50c33840db70c043b8124560d0344fc6721fde86f67a" 32 | solver-name = "gps-cdcl" 33 | solver-version = 1 34 | -------------------------------------------------------------------------------- /Gopkg.toml: -------------------------------------------------------------------------------- 1 | 2 | # Gopkg.toml example 3 | # 4 | # Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md 5 | # for detailed Gopkg.toml documentation. 6 | # 7 | # required = ["github.com/user/thing/cmd/thing"] 8 | # ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"] 9 | # 10 | # [[constraint]] 11 | # name = "github.com/user/project" 12 | # version = "1.0.0" 13 | # 14 | # [[constraint]] 15 | # name = "github.com/user/project2" 16 | # branch = "dev" 17 | # source = "github.com/myfork/project2" 18 | # 19 | # [[override]] 20 | # name = "github.com/x/y" 21 | # version = "2.4.0" 22 | 23 | 24 | [[constraint]] 25 | name = "github.com/smartystreets/goconvey" 26 | version = "1.6.3" 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Euphoria Ops, Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /WORKSPACE: -------------------------------------------------------------------------------- 1 | http_archive( 2 | name = "io_bazel_rules_go", 3 | url = "https://github.com/bazelbuild/rules_go/releases/download/0.5.5/rules_go-0.5.5.tar.gz", 4 | sha256 = "ca58b0b856dc95473b93f2228ab117913b82a6617fc0deabd107346e3981522a", 5 | ) 6 | load("@io_bazel_rules_go//go:def.bzl", "go_repositories") 7 | 8 | go_repositories() 9 | -------------------------------------------------------------------------------- /breakpoint.go: -------------------------------------------------------------------------------- 1 | package scope 2 | 3 | // Breakpointer provides a pair of methods for synchronizing across 4 | // goroutines and injecting errors. The Check method can be used 5 | // to provide a point of synchronization/injection. In normal operation, 6 | // this method will quickly return nil. A unit test can then use 7 | // Breakpoint, with the same parameters, to obtain a bidirectional 8 | // error channel. Receiving from this channel will block until Check 9 | // is called. The call to Check will block until an error value (or nil) 10 | // is sent back into the channel. 11 | type Breakpointer interface { 12 | // Breakpoint returns an error channel that can be used to synchronize 13 | // with a call to Check with the exact same parameters from another 14 | // goroutine. The call to Check will send a nil value across this 15 | // channel, and then receive a value to return to its caller. 16 | Breakpoint(scope ...interface{}) chan error 17 | 18 | // Check synchronizes with a registered breakpoint to obtain an error 19 | // value to return, or immediately returns nil if no breakpoint is 20 | // registered. 21 | Check(scope ...interface{}) error 22 | } 23 | 24 | type breakpoint struct { 25 | c chan error 26 | } 27 | 28 | type bpmap kvmap 29 | 30 | func (b bpmap) get(create bool, scope ...interface{}) chan error { 31 | switch len(scope) { 32 | case 0: 33 | return nil 34 | case 1: 35 | if obj, ok := b[scope[0]]; ok { 36 | if ch, ok := obj.(chan error); ok { 37 | return ch 38 | } 39 | return nil 40 | } 41 | if !create { 42 | return nil 43 | } 44 | ch := make(chan error) 45 | b[scope[0]] = ch 46 | return ch 47 | default: 48 | if obj, ok := b[scope[0]]; ok { 49 | if bpm, ok := obj.(bpmap); ok { 50 | return bpm.get(create, scope[1:]...) 51 | } 52 | return nil 53 | } 54 | bpm := bpmap{} 55 | b[scope[0]] = bpm 56 | return bpm.get(create, scope[1:]...) 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /breakpoint_test.go: -------------------------------------------------------------------------------- 1 | package scope 2 | 3 | import ( 4 | "testing" 5 | 6 | . "github.com/smartystreets/goconvey/convey" 7 | ) 8 | 9 | func TestBpmap(t *testing.T) { 10 | Convey("Lookups and storage", t, func() { 11 | bpm := bpmap{} 12 | 13 | So(bpm.get(false, "a"), ShouldBeNil) 14 | ch := bpm.get(true, "a") 15 | So(bpm.get(false, "a"), ShouldEqual, ch) 16 | So(bpm.get(true, "a"), ShouldEqual, ch) 17 | So(bpm.get(true, "a", "b", "c"), ShouldBeNil) 18 | 19 | delete(bpm, "a") 20 | nested := bpm.get(true, "a", "b", "c") 21 | So(bpm.get(false, "a", "b", "c"), ShouldEqual, nested) 22 | So(bpm.get(true, "a", "b", "c"), ShouldEqual, nested) 23 | So(bpm.get(true, "a", "b"), ShouldBeNil) 24 | So(bpm.get(false, "a", "b"), ShouldBeNil) 25 | 26 | So(bpm.get(true), ShouldBeNil) 27 | So(bpm.get(false), ShouldBeNil) 28 | }) 29 | } 30 | -------------------------------------------------------------------------------- /examples_test.go: -------------------------------------------------------------------------------- 1 | package scope_test 2 | 3 | import ( 4 | "fmt" 5 | "time" 6 | 7 | "euphoria.io/scope" 8 | ) 9 | 10 | func ExampleBreakpointer() { 11 | root := scope.New() 12 | 13 | // A function that returns an error, which we want to simulate. 14 | output := func(arg string) error { 15 | _, err := fmt.Println(arg) 16 | return err 17 | } 18 | 19 | // A function that we want to test the error handling of. 20 | verifyOutput := func(ctx scope.Context, arg string) error { 21 | if err := ctx.Check("output()", arg); err != nil { 22 | return err 23 | } 24 | return output(arg) 25 | } 26 | 27 | // Set a breakpoint on a particular invocation of output. 28 | ctrl := root.Breakpoint("output()", "fail") 29 | 30 | // Other invocations should proceed as normal. 31 | err := verifyOutput(root, "normal behavior") 32 | fmt.Println("verifyOutput returned", err) 33 | 34 | // Our breakpoint should allow us to inject an error. To control it 35 | // we must spin off a goroutine. 36 | go func() { 37 | <-ctrl // synchronize at beginning of verifyOutput 38 | ctrl <- fmt.Errorf("test error") 39 | }() 40 | 41 | err = verifyOutput(root, "fail") 42 | fmt.Println("verifyOutput returned", err) 43 | 44 | // We can also inject an error by terminating the context. 45 | go func() { 46 | <-ctrl 47 | root.Cancel() 48 | }() 49 | 50 | err = verifyOutput(root, "fail") 51 | fmt.Println("verifyOutput returned", err) 52 | 53 | // Output: 54 | // normal behavior 55 | // verifyOutput returned 56 | // verifyOutput returned test error 57 | // verifyOutput returned context cancelled 58 | } 59 | 60 | func ExampleContext_cancellation() { 61 | ctx := scope.New() 62 | 63 | go func() { 64 | time.Sleep(50 * time.Millisecond) 65 | ctx.Cancel() 66 | }() 67 | 68 | loop: 69 | for { 70 | t := time.After(10 * time.Millisecond) 71 | select { 72 | case <-ctx.Done(): 73 | break loop 74 | case <-t: 75 | fmt.Println("tick") 76 | } 77 | } 78 | fmt.Println("finished with", ctx.Err()) 79 | // Output: 80 | // tick 81 | // tick 82 | // tick 83 | // tick 84 | // finished with context cancelled 85 | } 86 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/.gitignore: -------------------------------------------------------------------------------- 1 | /node-syscall/build 2 | /node_modules 3 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["tool.go"], 6 | visibility = ["//visibility:private"], 7 | deps = [ 8 | "//vendor/github.com/gopherjs/gopherjs/build:go_default_library", 9 | "//vendor/github.com/gopherjs/gopherjs/compiler:go_default_library", 10 | "//vendor/github.com/gopherjs/gopherjs/internal/sysutil:go_default_library", 11 | "//vendor/github.com/kisielk/gotool:go_default_library", 12 | "//vendor/github.com/neelance/sourcemap:go_default_library", 13 | "//vendor/github.com/spf13/cobra:go_default_library", 14 | "//vendor/github.com/spf13/pflag:go_default_library", 15 | "//vendor/golang.org/x/crypto/ssh/terminal:go_default_library", 16 | ], 17 | ) 18 | 19 | go_binary( 20 | name = "gopherjs", 21 | library = ":go_default_library", 22 | visibility = ["//visibility:public"], 23 | ) 24 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013 Richard Musiol. All rights reserved. 2 | 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are 5 | met: 6 | 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above 10 | copyright notice, this list of conditions and the following disclaimer 11 | in the documentation and/or other materials provided with the 12 | distribution. 13 | 14 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 15 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 16 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 17 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 18 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 19 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 20 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/build/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["build.go"], 6 | visibility = ["//visibility:public"], 7 | deps = [ 8 | "//vendor/github.com/fsnotify/fsnotify:go_default_library", 9 | "//vendor/github.com/gopherjs/gopherjs/compiler:go_default_library", 10 | "//vendor/github.com/gopherjs/gopherjs/compiler/natives:go_default_library", 11 | "//vendor/github.com/neelance/sourcemap:go_default_library", 12 | ], 13 | ) 14 | 15 | go_test( 16 | name = "go_default_test", 17 | srcs = ["build_test.go"], 18 | library = ":go_default_library", 19 | deps = [ 20 | "//vendor/github.com/kisielk/gotool:go_default_library", 21 | "//vendor/github.com/shurcooL/go/importgraphutil:go_default_library", 22 | ], 23 | ) 24 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = [ 6 | "compiler.go", 7 | "expressions.go", 8 | "package.go", 9 | "statements.go", 10 | "utils.go", 11 | "version_check.go", 12 | ], 13 | visibility = ["//visibility:public"], 14 | deps = [ 15 | "//vendor/github.com/gopherjs/gopherjs/compiler/analysis:go_default_library", 16 | "//vendor/github.com/gopherjs/gopherjs/compiler/astutil:go_default_library", 17 | "//vendor/github.com/gopherjs/gopherjs/compiler/filter:go_default_library", 18 | "//vendor/github.com/gopherjs/gopherjs/compiler/prelude:go_default_library", 19 | "//vendor/github.com/gopherjs/gopherjs/compiler/typesutil:go_default_library", 20 | "//vendor/github.com/neelance/astrewrite:go_default_library", 21 | "//vendor/golang.org/x/tools/go/gcimporter15:go_default_library", 22 | "//vendor/golang.org/x/tools/go/types/typeutil:go_default_library", 23 | ], 24 | ) 25 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/analysis/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = [ 6 | "bool.go", 7 | "break.go", 8 | "escape.go", 9 | "info.go", 10 | "sideeffect.go", 11 | ], 12 | visibility = ["//visibility:public"], 13 | deps = [ 14 | "//vendor/github.com/gopherjs/gopherjs/compiler/astutil:go_default_library", 15 | "//vendor/github.com/gopherjs/gopherjs/compiler/typesutil:go_default_library", 16 | ], 17 | ) 18 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/analysis/bool.go: -------------------------------------------------------------------------------- 1 | package analysis 2 | 3 | import ( 4 | "go/ast" 5 | "go/constant" 6 | "go/token" 7 | "go/types" 8 | ) 9 | 10 | func BoolValue(expr ast.Expr, info *types.Info) (bool, bool) { 11 | v := info.Types[expr].Value 12 | if v != nil && v.Kind() == constant.Bool { 13 | return constant.BoolVal(v), true 14 | } 15 | switch e := expr.(type) { 16 | case *ast.BinaryExpr: 17 | switch e.Op { 18 | case token.LAND: 19 | if b, ok := BoolValue(e.X, info); ok { 20 | if !b { 21 | return false, true 22 | } 23 | return BoolValue(e.Y, info) 24 | } 25 | case token.LOR: 26 | if b, ok := BoolValue(e.X, info); ok { 27 | if b { 28 | return true, true 29 | } 30 | return BoolValue(e.Y, info) 31 | } 32 | } 33 | case *ast.UnaryExpr: 34 | if e.Op == token.NOT { 35 | if b, ok := BoolValue(e.X, info); ok { 36 | return !b, true 37 | } 38 | } 39 | case *ast.ParenExpr: 40 | return BoolValue(e.X, info) 41 | } 42 | return false, false 43 | } 44 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/analysis/break.go: -------------------------------------------------------------------------------- 1 | package analysis 2 | 3 | import ( 4 | "go/ast" 5 | "go/token" 6 | ) 7 | 8 | func HasBreak(n ast.Node) bool { 9 | v := hasBreakVisitor{} 10 | ast.Walk(&v, n) 11 | return v.hasBreak 12 | } 13 | 14 | type hasBreakVisitor struct { 15 | hasBreak bool 16 | } 17 | 18 | func (v *hasBreakVisitor) Visit(node ast.Node) (w ast.Visitor) { 19 | if v.hasBreak { 20 | return nil 21 | } 22 | switch n := node.(type) { 23 | case *ast.BranchStmt: 24 | if n.Tok == token.BREAK && n.Label == nil { 25 | v.hasBreak = true 26 | return nil 27 | } 28 | case *ast.ForStmt, *ast.RangeStmt, *ast.SwitchStmt, *ast.TypeSwitchStmt, *ast.SelectStmt, ast.Expr: 29 | return nil 30 | } 31 | return v 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/analysis/escape.go: -------------------------------------------------------------------------------- 1 | package analysis 2 | 3 | import ( 4 | "go/ast" 5 | "go/token" 6 | "go/types" 7 | ) 8 | 9 | func EscapingObjects(n ast.Node, info *types.Info) []*types.Var { 10 | v := escapeAnalysis{ 11 | info: info, 12 | escaping: make(map[*types.Var]bool), 13 | topScope: info.Scopes[n], 14 | bottomScopes: make(map[*types.Scope]bool), 15 | } 16 | ast.Walk(&v, n) 17 | var list []*types.Var 18 | for obj := range v.escaping { 19 | list = append(list, obj) 20 | } 21 | return list 22 | } 23 | 24 | type escapeAnalysis struct { 25 | info *types.Info 26 | escaping map[*types.Var]bool 27 | topScope *types.Scope 28 | bottomScopes map[*types.Scope]bool 29 | } 30 | 31 | func (v *escapeAnalysis) Visit(node ast.Node) (w ast.Visitor) { 32 | // huge overapproximation 33 | switch n := node.(type) { 34 | case *ast.UnaryExpr: 35 | if n.Op == token.AND { 36 | if _, ok := n.X.(*ast.Ident); ok { 37 | return &escapingObjectCollector{v} 38 | } 39 | } 40 | case *ast.FuncLit: 41 | v.bottomScopes[v.info.Scopes[n.Type]] = true 42 | return &escapingObjectCollector{v} 43 | case *ast.ForStmt: 44 | v.bottomScopes[v.info.Scopes[n.Body]] = true 45 | case *ast.RangeStmt: 46 | v.bottomScopes[v.info.Scopes[n.Body]] = true 47 | } 48 | return v 49 | } 50 | 51 | type escapingObjectCollector struct { 52 | analysis *escapeAnalysis 53 | } 54 | 55 | func (v *escapingObjectCollector) Visit(node ast.Node) (w ast.Visitor) { 56 | if id, ok := node.(*ast.Ident); ok { 57 | if obj, ok := v.analysis.info.Uses[id].(*types.Var); ok { 58 | for s := obj.Parent(); s != nil; s = s.Parent() { 59 | if s == v.analysis.topScope { 60 | v.analysis.escaping[obj] = true 61 | break 62 | } 63 | if v.analysis.bottomScopes[s] { 64 | break 65 | } 66 | } 67 | } 68 | } 69 | return v 70 | } 71 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/analysis/sideeffect.go: -------------------------------------------------------------------------------- 1 | package analysis 2 | 3 | import ( 4 | "go/ast" 5 | "go/token" 6 | "go/types" 7 | ) 8 | 9 | func HasSideEffect(n ast.Node, info *types.Info) bool { 10 | v := hasSideEffectVisitor{info: info} 11 | ast.Walk(&v, n) 12 | return v.hasSideEffect 13 | } 14 | 15 | type hasSideEffectVisitor struct { 16 | info *types.Info 17 | hasSideEffect bool 18 | } 19 | 20 | func (v *hasSideEffectVisitor) Visit(node ast.Node) (w ast.Visitor) { 21 | if v.hasSideEffect { 22 | return nil 23 | } 24 | switch n := node.(type) { 25 | case *ast.CallExpr: 26 | if _, isSig := v.info.TypeOf(n.Fun).(*types.Signature); isSig { // skip conversions 27 | v.hasSideEffect = true 28 | return nil 29 | } 30 | case *ast.UnaryExpr: 31 | if n.Op == token.ARROW { 32 | v.hasSideEffect = true 33 | return nil 34 | } 35 | } 36 | return v 37 | } 38 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/astutil/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["astutil.go"], 6 | visibility = ["//visibility:public"], 7 | ) 8 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/astutil/astutil.go: -------------------------------------------------------------------------------- 1 | package astutil 2 | 3 | import ( 4 | "go/ast" 5 | "go/types" 6 | ) 7 | 8 | func RemoveParens(e ast.Expr) ast.Expr { 9 | for { 10 | p, isParen := e.(*ast.ParenExpr) 11 | if !isParen { 12 | return e 13 | } 14 | e = p.X 15 | } 16 | } 17 | 18 | func SetType(info *types.Info, t types.Type, e ast.Expr) ast.Expr { 19 | info.Types[e] = types.TypeAndValue{Type: t} 20 | return e 21 | } 22 | 23 | func NewIdent(name string, t types.Type, info *types.Info, pkg *types.Package) *ast.Ident { 24 | ident := ast.NewIdent(name) 25 | info.Types[ident] = types.TypeAndValue{Type: t} 26 | obj := types.NewVar(0, pkg, name, t) 27 | info.Uses[ident] = obj 28 | return ident 29 | } 30 | 31 | func IsTypeExpr(expr ast.Expr, info *types.Info) bool { 32 | switch e := expr.(type) { 33 | case *ast.ArrayType, *ast.ChanType, *ast.FuncType, *ast.InterfaceType, *ast.MapType, *ast.StructType: 34 | return true 35 | case *ast.StarExpr: 36 | return IsTypeExpr(e.X, info) 37 | case *ast.Ident: 38 | _, ok := info.Uses[e].(*types.TypeName) 39 | return ok 40 | case *ast.SelectorExpr: 41 | _, ok := info.Uses[e.Sel].(*types.TypeName) 42 | return ok 43 | case *ast.ParenExpr: 44 | return IsTypeExpr(e.X, info) 45 | default: 46 | return false 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/filter/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = [ 6 | "assign.go", 7 | "incdecstmt.go", 8 | ], 9 | visibility = ["//visibility:public"], 10 | deps = ["//vendor/github.com/gopherjs/gopherjs/compiler/astutil:go_default_library"], 11 | ) 12 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/filter/incdecstmt.go: -------------------------------------------------------------------------------- 1 | package filter 2 | 3 | import ( 4 | "go/ast" 5 | "go/constant" 6 | "go/token" 7 | "go/types" 8 | ) 9 | 10 | func IncDecStmt(stmt ast.Stmt, info *types.Info) ast.Stmt { 11 | if s, ok := stmt.(*ast.IncDecStmt); ok { 12 | t := info.TypeOf(s.X) 13 | if iExpr, isIExpr := s.X.(*ast.IndexExpr); isIExpr { 14 | switch u := info.TypeOf(iExpr.X).Underlying().(type) { 15 | case *types.Array: 16 | t = u.Elem() 17 | case *types.Slice: 18 | t = u.Elem() 19 | case *types.Map: 20 | t = u.Elem() 21 | } 22 | } 23 | 24 | tok := token.ADD_ASSIGN 25 | if s.Tok == token.DEC { 26 | tok = token.SUB_ASSIGN 27 | } 28 | 29 | one := &ast.BasicLit{Kind: token.INT} 30 | info.Types[one] = types.TypeAndValue{Type: t, Value: constant.MakeInt64(1)} 31 | 32 | return &ast.AssignStmt{ 33 | Lhs: []ast.Expr{s.X}, 34 | Tok: tok, 35 | Rhs: []ast.Expr{one}, 36 | } 37 | } 38 | return stmt 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = [ 6 | "doc.go", 7 | "fs_vfsdata.go", 8 | ], 9 | visibility = ["//visibility:public"], 10 | ) 11 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/doc.go: -------------------------------------------------------------------------------- 1 | // Package natives provides native packages via a virtual filesystem. 2 | // 3 | // See documentation of parseAndAugment in github.com/gopherjs/gopherjs/build 4 | // for explanation of behavior used to augment the native packages using the files 5 | // in src subfolder. 6 | package natives 7 | 8 | //go:generate vfsgendev -source="github.com/gopherjs/gopherjs/compiler/natives".FS -tag=gopherjsdev 9 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/fs.go: -------------------------------------------------------------------------------- 1 | // +build gopherjsdev 2 | 3 | package natives 4 | 5 | import ( 6 | "go/build" 7 | "log" 8 | "net/http" 9 | "os" 10 | "strings" 11 | 12 | "github.com/shurcooL/httpfs/filter" 13 | ) 14 | 15 | func importPathToDir(importPath string) string { 16 | p, err := build.Import(importPath, "", build.FindOnly) 17 | if err != nil { 18 | log.Fatalln(err) 19 | } 20 | return p.Dir 21 | } 22 | 23 | // FS is a virtual filesystem that contains native packages. 24 | var FS = filter.Keep( 25 | http.Dir(importPathToDir("github.com/gopherjs/gopherjs/compiler/natives")), 26 | func(path string, fi os.FileInfo) bool { 27 | return path == "/" || path == "/src" || strings.HasPrefix(path, "/src/") 28 | }, 29 | ) 30 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/src/bytes/bytes.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package bytes 4 | 5 | func IndexByte(s []byte, c byte) int { 6 | for i, b := range s { 7 | if b == c { 8 | return i 9 | } 10 | } 11 | return -1 12 | } 13 | 14 | func Equal(a, b []byte) bool { 15 | if len(a) != len(b) { 16 | return false 17 | } 18 | for i, c := range a { 19 | if c != b[i] { 20 | return false 21 | } 22 | } 23 | return true 24 | } 25 | 26 | func Compare(a, b []byte) int { 27 | for i, ca := range a { 28 | if i >= len(b) { 29 | return 1 30 | } 31 | cb := b[i] 32 | if ca < cb { 33 | return -1 34 | } 35 | if ca > cb { 36 | return 1 37 | } 38 | } 39 | if len(a) < len(b) { 40 | return -1 41 | } 42 | return 0 43 | } 44 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/src/bytes/bytes_test.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package bytes_test 4 | 5 | import ( 6 | "testing" 7 | ) 8 | 9 | func TestEqualNearPageBoundary(t *testing.T) { 10 | t.Skip() 11 | } 12 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/src/crypto/rand/rand.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package rand 4 | 5 | import ( 6 | "errors" 7 | 8 | "github.com/gopherjs/gopherjs/js" 9 | ) 10 | 11 | func init() { 12 | Reader = &rngReader{} 13 | } 14 | 15 | type rngReader struct{} 16 | 17 | func (r *rngReader) Read(b []byte) (n int, err error) { 18 | array := js.InternalObject(b).Get("$array") 19 | offset := js.InternalObject(b).Get("$offset").Int() 20 | 21 | // browser 22 | crypto := js.Global.Get("crypto") 23 | if crypto == js.Undefined { 24 | crypto = js.Global.Get("msCrypto") 25 | } 26 | if crypto != js.Undefined { 27 | if crypto.Get("getRandomValues") != js.Undefined { 28 | n = len(b) 29 | if n > 65536 { 30 | // Avoid QuotaExceededError thrown by getRandomValues 31 | // when length is more than 65536, as specified in 32 | // http://www.w3.org/TR/WebCryptoAPI/#Crypto-method-getRandomValues 33 | n = 65536 34 | } 35 | crypto.Call("getRandomValues", array.Call("subarray", offset, offset+n)) 36 | return n, nil 37 | } 38 | } 39 | 40 | // Node.js 41 | if require := js.Global.Get("require"); require != js.Undefined { 42 | if randomBytes := require.Invoke("crypto").Get("randomBytes"); randomBytes != js.Undefined { 43 | array.Call("set", randomBytes.Invoke(len(b)), offset) 44 | return len(b), nil 45 | } 46 | } 47 | 48 | return 0, errors.New("crypto/rand not available in this environment") 49 | } 50 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/src/crypto/x509/x509.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package x509 4 | 5 | import "errors" 6 | 7 | func loadSystemRoots() (*CertPool, error) { 8 | return nil, errors.New("crypto/x509: system root pool is not available in GopherJS") 9 | } 10 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/src/crypto/x509/x509_test.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package x509 4 | 5 | import "testing" 6 | 7 | func TestSystemCertPool(t *testing.T) { 8 | t.Skip("no system roots") 9 | } 10 | 11 | func TestSystemRoots(t *testing.T) { 12 | t.Skip("no system roots") 13 | } 14 | 15 | func TestEnvVars(t *testing.T) { 16 | t.Skip("no system roots") 17 | } 18 | 19 | func TestSystemVerify(t *testing.T) { 20 | t.Skip("no system") 21 | } 22 | 23 | func TestImports(t *testing.T) { 24 | t.Skip("no system") 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/src/database/sql/driver/driver_test.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package driver 4 | 5 | var valueConverterTests = []valueConverterTest{ 6 | {Bool, "true", true, ""}, 7 | {Bool, "True", true, ""}, 8 | {Bool, []byte("t"), true, ""}, 9 | {Bool, true, true, ""}, 10 | {Bool, "1", true, ""}, 11 | {Bool, 1, true, ""}, 12 | {Bool, int64(1), true, ""}, 13 | {Bool, uint16(1), true, ""}, 14 | {Bool, "false", false, ""}, 15 | {Bool, false, false, ""}, 16 | {Bool, "0", false, ""}, 17 | {Bool, 0, false, ""}, 18 | {Bool, int64(0), false, ""}, 19 | {Bool, uint16(0), false, ""}, 20 | {c: Bool, in: "foo", err: "sql/driver: couldn't convert \"foo\" into type bool"}, 21 | {c: Bool, in: 2, err: "sql/driver: couldn't convert 2 into type bool"}, 22 | {DefaultParameterConverter, now, now, ""}, 23 | {DefaultParameterConverter, (*int64)(nil), nil, ""}, 24 | {DefaultParameterConverter, &answer, answer, ""}, 25 | {DefaultParameterConverter, &now, now, ""}, 26 | //{DefaultParameterConverter, i(9), int64(9), ""}, // TODO: Fix. 27 | {DefaultParameterConverter, f(0.1), float64(0.1), ""}, 28 | {DefaultParameterConverter, b(true), true, ""}, 29 | //{DefaultParameterConverter, bs{1}, []byte{1}, ""}, // TODO: Fix. 30 | {DefaultParameterConverter, s("a"), "a", ""}, 31 | {DefaultParameterConverter, is{1}, nil, "unsupported type driver.is, a slice of int"}, 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/src/debug/elf/elf_test.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package elf 4 | 5 | import "testing" 6 | 7 | func TestNoSectionOverlaps(t *testing.T) { 8 | t.Skip("not 6l") 9 | } 10 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/src/encoding/json/stream_test.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package json 4 | 5 | import "testing" 6 | 7 | func TestHTTPDecoding(t *testing.T) { 8 | t.Skip("network access is not supported by GopherJS") 9 | } 10 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/src/fmt/fmt_test.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package fmt_test 4 | 5 | const intCount = 100 6 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/src/go/token/token_test.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package token 4 | 5 | import ( 6 | "testing" 7 | ) 8 | 9 | func TestFileSetRace(t *testing.T) { 10 | t.Skip() 11 | } 12 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/src/internal/poll/fd_poll_js.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package poll 4 | 5 | import "time" 6 | 7 | // pollDesc is a no-op implementation of an I/O poller for GOARCH=js. 8 | // 9 | // Its implementation is based on NaCL in gc compiler (see GOROOT/src/internal/poll/fd_poll_nacl.go), 10 | // but it does even less. 11 | type pollDesc struct { 12 | closing bool 13 | } 14 | 15 | func (pd *pollDesc) init(fd *FD) error { return nil } 16 | 17 | func (pd *pollDesc) close() {} 18 | 19 | func (pd *pollDesc) evict() { pd.closing = true } 20 | 21 | func (pd *pollDesc) prepare(mode int, isFile bool) error { 22 | if pd.closing { 23 | return errClosing(isFile) 24 | } 25 | return nil 26 | } 27 | 28 | func (pd *pollDesc) prepareRead(isFile bool) error { return pd.prepare('r', isFile) } 29 | 30 | func (pd *pollDesc) prepareWrite(isFile bool) error { return pd.prepare('w', isFile) } 31 | 32 | func (pd *pollDesc) wait(mode int, isFile bool) error { 33 | if pd.closing { 34 | return errClosing(isFile) 35 | } 36 | return ErrTimeout 37 | } 38 | 39 | func (pd *pollDesc) waitRead(isFile bool) error { return pd.wait('r', isFile) } 40 | 41 | func (pd *pollDesc) waitWrite(isFile bool) error { return pd.wait('w', isFile) } 42 | 43 | func (*pollDesc) waitCanceled(mode int) {} 44 | 45 | func (*pollDesc) pollable() bool { return true } 46 | 47 | func (*FD) SetDeadline(t time.Time) error { return nil } 48 | 49 | func (*FD) SetReadDeadline(t time.Time) error { return nil } 50 | 51 | func (*FD) SetWriteDeadline(t time.Time) error { return nil } 52 | 53 | // PollDescriptor returns the descriptor being used by the poller, 54 | // or ^uintptr(0) if there isn't one. This is only used for testing. 55 | func PollDescriptor() uintptr { 56 | return ^uintptr(0) 57 | } 58 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/src/internal/testenv/testenv.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package testenv 4 | 5 | import ( 6 | "runtime" 7 | "strings" 8 | ) 9 | 10 | // HasExec reports whether the current system can start new processes 11 | // using os.StartProcess or (more commonly) exec.Command. 12 | func HasExec() bool { 13 | switch runtime.GOOS { 14 | case "nacl": 15 | return false 16 | case "darwin": 17 | if strings.HasPrefix(runtime.GOARCH, "arm") { 18 | return false 19 | } 20 | } 21 | switch runtime.GOARCH { 22 | case "js": 23 | return false 24 | } 25 | return true 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/src/io/io_test.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package io_test 4 | 5 | import ( 6 | "testing" 7 | ) 8 | 9 | func TestMultiWriter_WriteStringSingleAlloc(t *testing.T) { 10 | t.Skip() 11 | } 12 | 13 | func TestMultiReaderFlatten(t *testing.T) { 14 | t.Skip() 15 | } 16 | 17 | func TestMultiReaderFreesExhaustedReaders(t *testing.T) { 18 | t.Skip("test relies on runtime.SetFinalizer, which GopherJS does not implement") 19 | } 20 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/src/math/big/big.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package big 4 | 5 | // TODO: This is a workaround for https://github.com/gopherjs/gopherjs/issues/652. 6 | // Remove after that issue is resolved. 7 | type Word uintptr 8 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/src/math/big/big_test.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package big 4 | 5 | import "testing" 6 | 7 | func TestBytes(t *testing.T) { 8 | t.Skip("broken") 9 | } 10 | 11 | func TestModSqrt(t *testing.T) { 12 | t.Skip("slow") 13 | } 14 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/src/math/math_test.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package math_test 4 | 5 | // Slighly higher tolerances than upstream, otherwise TestGamma fails. 6 | // TODO: Is there a better way to fix TestGamma? It's weird that only one test 7 | // requires increasing tolerances. Perhaps there's a better fix? Maybe we 8 | // should override TestGamma specifically and not the package-wide tolerances, 9 | // because this will cause many other tests to be less accurate. Or maybe this 10 | // is fine? 11 | func close(a, b float64) bool { return tolerance(a, b, 4e-14) } 12 | func veryclose(a, b float64) bool { return tolerance(a, b, 6e-15) } 13 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/src/math/rand/rand_test.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package rand 4 | 5 | import "testing" 6 | 7 | func TestFloat32(t *testing.T) { 8 | t.Skip("slow") 9 | } 10 | 11 | func TestConcurrent(t *testing.T) { 12 | t.Skip("using nosync") 13 | } 14 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/src/net/http/cookiejar/example_test.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package cookiejar_test 4 | 5 | import "fmt" 6 | 7 | func ExampleNew() { 8 | // network access not supported by GopherJS, and this test depends on httptest.NewServer 9 | 10 | fmt.Println(`After 1st request: 11 | Flavor: Chocolate Chip 12 | After 2nd request: 13 | Flavor: Oatmeal Raisin`) 14 | } 15 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/src/net/net.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package net 4 | 5 | import ( 6 | "errors" 7 | "syscall" 8 | 9 | "github.com/gopherjs/gopherjs/js" 10 | ) 11 | 12 | func Listen(net, laddr string) (Listener, error) { 13 | panic(errors.New("network access is not supported by GopherJS")) 14 | } 15 | 16 | func (d *Dialer) Dial(network, address string) (Conn, error) { 17 | panic(errors.New("network access is not supported by GopherJS")) 18 | } 19 | 20 | func sysInit() { 21 | } 22 | 23 | func probeIPv4Stack() bool { 24 | return false 25 | } 26 | 27 | func probeIPv6Stack() (supportsIPv6, supportsIPv4map bool) { 28 | return false, false 29 | } 30 | 31 | func probeWindowsIPStack() (supportsVistaIP bool) { 32 | return false 33 | } 34 | 35 | func maxListenerBacklog() int { 36 | return syscall.SOMAXCONN 37 | } 38 | 39 | // Copy of strings.IndexByte. 40 | func byteIndex(s string, c byte) int { 41 | return js.InternalObject(s).Call("indexOf", js.Global.Get("String").Call("fromCharCode", c)).Int() 42 | } 43 | 44 | // Copy of bytes.Equal. 45 | func bytesEqual(x, y []byte) bool { 46 | if len(x) != len(y) { 47 | return false 48 | } 49 | for i, b := range x { 50 | if b != y[i] { 51 | return false 52 | } 53 | } 54 | return true 55 | } 56 | 57 | // Copy of bytes.IndexByte. 58 | func bytesIndexByte(s []byte, c byte) int { 59 | for i, b := range s { 60 | if b == c { 61 | return i 62 | } 63 | } 64 | return -1 65 | } 66 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/src/os/os.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package os 4 | 5 | import ( 6 | "errors" 7 | 8 | "github.com/gopherjs/gopherjs/js" 9 | ) 10 | 11 | func runtime_args() []string { // not called on Windows 12 | return Args 13 | } 14 | 15 | func init() { 16 | if process := js.Global.Get("process"); process != js.Undefined { 17 | argv := process.Get("argv") 18 | Args = make([]string, argv.Length()-1) 19 | for i := 0; i < argv.Length()-1; i++ { 20 | Args[i] = argv.Index(i + 1).String() 21 | } 22 | } 23 | if len(Args) == 0 { 24 | Args = []string{"?"} 25 | } 26 | } 27 | 28 | func runtime_beforeExit() {} 29 | 30 | func executable() (string, error) { 31 | return "", errors.New("Executable not implemented for GOARCH=js") 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/src/os/signal/signal.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package signal 4 | 5 | // Package signal is not implemented for GOARCH=js. 6 | 7 | func signal_disable(uint32) {} 8 | func signal_enable(uint32) {} 9 | func signal_ignore(uint32) {} 10 | func signal_recv() uint32 { return 0 } 11 | 12 | func loop() {} 13 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/src/reflect/example_test.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package reflect_test 4 | 5 | import "fmt" 6 | 7 | func ExampleStructOf() { 8 | // GopherJS does not implement reflect.addReflectOff needed for this test. 9 | // See https://github.com/gopherjs/gopherjs/issues/499 10 | 11 | fmt.Println(`value: &{Height:0.4 Age:2} 12 | json: {"height":0.4,"age":2} 13 | value: &{Height:1.5 Age:10}`) 14 | } 15 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/src/reflect/swapper.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package reflect 4 | 5 | func Swapper(slice interface{}) func(i, j int) { 6 | v := ValueOf(slice) 7 | if v.Kind() != Slice { 8 | panic(&ValueError{Method: "Swapper", Kind: v.Kind()}) 9 | } 10 | // Fast path for slices of size 0 and 1. Nothing to swap. 11 | switch v.Len() { 12 | case 0: 13 | return func(i, j int) { panic("reflect: slice index out of range") } 14 | case 1: 15 | return func(i, j int) { 16 | if i != 0 || j != 0 { 17 | panic("reflect: slice index out of range") 18 | } 19 | } 20 | } 21 | tmp := New(v.Type().Elem()).Elem() 22 | return func(i, j int) { 23 | v1 := v.Index(i) 24 | v2 := v.Index(j) 25 | tmp.Set(v1) 26 | v1.Set(v2) 27 | v2.Set(tmp) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/src/regexp/regexp_test.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package regexp 4 | 5 | import ( 6 | "testing" 7 | ) 8 | 9 | func TestOnePassCutoff(t *testing.T) { 10 | t.Skip() // "Maximum call stack size exceeded" on V8 11 | } 12 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/src/runtime/debug/debug.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package debug 4 | 5 | func setGCPercent(int32) int32 { 6 | // Not implemented. Return initial setting. 7 | return 100 8 | } 9 | 10 | func setMaxStack(bytes int) int { 11 | // Not implemented. Return initial setting. 12 | // The initial setting is 1 GB on 64-bit systems, 250 MB on 32-bit systems. 13 | return 250000000 14 | } 15 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/src/runtime/pprof/pprof.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package pprof 4 | 5 | import ( 6 | "io" 7 | "sync" 8 | ) 9 | 10 | type Profile struct { 11 | name string 12 | mu sync.Mutex 13 | m map[interface{}][]uintptr 14 | count func() int 15 | write func(io.Writer, int) error 16 | } 17 | 18 | func (p *Profile) WriteTo(w io.Writer, debug int) error { 19 | return nil 20 | } 21 | 22 | func (p *Profile) Count() int { 23 | return 0 24 | } 25 | 26 | func (p *Profile) Name() string { 27 | return "" 28 | } 29 | 30 | func (p *Profile) Add(value interface{}, skip int) { 31 | } 32 | 33 | func (p *Profile) Remove(value interface{}) { 34 | } 35 | 36 | func StartCPUProfile(w io.Writer) error { 37 | return nil 38 | } 39 | 40 | func StopCPUProfile() { 41 | } 42 | 43 | func WriteHeapProfile(w io.Writer) error { 44 | return nil 45 | } 46 | 47 | func Lookup(name string) *Profile { 48 | return nil 49 | } 50 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/src/strings/strings.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package strings 4 | 5 | import ( 6 | "unicode/utf8" 7 | 8 | "github.com/gopherjs/gopherjs/js" 9 | ) 10 | 11 | func IndexByte(s string, c byte) int { 12 | return js.InternalObject(s).Call("indexOf", js.Global.Get("String").Call("fromCharCode", c)).Int() 13 | } 14 | 15 | func Index(s, sep string) int { 16 | return js.InternalObject(s).Call("indexOf", js.InternalObject(sep)).Int() 17 | } 18 | 19 | func LastIndex(s, sep string) int { 20 | return js.InternalObject(s).Call("lastIndexOf", js.InternalObject(sep)).Int() 21 | } 22 | 23 | func Count(s, sep string) int { 24 | n := 0 25 | // special cases 26 | switch { 27 | case len(sep) == 0: 28 | return utf8.RuneCountInString(s) + 1 29 | case len(sep) > len(s): 30 | return 0 31 | case len(sep) == len(s): 32 | if sep == s { 33 | return 1 34 | } 35 | return 0 36 | } 37 | 38 | for { 39 | pos := Index(s, sep) 40 | if pos == -1 { 41 | break 42 | } 43 | n++ 44 | s = s[pos+len(sep):] 45 | } 46 | return n 47 | } 48 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/src/sync/atomic/atomic_test.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package atomic_test 4 | 5 | import "testing" 6 | 7 | func TestHammerStoreLoad(t *testing.T) { 8 | t.Skip("use of unsafe") 9 | } 10 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/src/sync/cond.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package sync 4 | 5 | type Cond struct { 6 | // fields used by vanilla implementation 7 | noCopy noCopy 8 | L Locker 9 | notify notifyList 10 | checker copyChecker 11 | 12 | // fields used by new implementation 13 | n int 14 | ch chan bool 15 | } 16 | 17 | func (c *Cond) Wait() { 18 | c.n++ 19 | if c.ch == nil { 20 | c.ch = make(chan bool) 21 | } 22 | c.L.Unlock() 23 | <-c.ch 24 | c.L.Lock() 25 | } 26 | 27 | func (c *Cond) Signal() { 28 | if c.n == 0 { 29 | return 30 | } 31 | c.n-- 32 | c.ch <- true 33 | } 34 | 35 | func (c *Cond) Broadcast() { 36 | n := c.n 37 | c.n = 0 38 | for i := 0; i < n; i++ { 39 | c.ch <- true 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/src/sync/export_test.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package sync 4 | 5 | // Referenced by tests, need to have no-op implementations. 6 | var Runtime_procPin = func() int { return 0 } 7 | var Runtime_procUnpin = func() {} 8 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/src/sync/pool.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package sync 4 | 5 | import "unsafe" 6 | 7 | type Pool struct { 8 | local unsafe.Pointer 9 | localSize uintptr 10 | 11 | store []interface{} 12 | New func() interface{} 13 | } 14 | 15 | func (p *Pool) Get() interface{} { 16 | if len(p.store) == 0 { 17 | if p.New != nil { 18 | return p.New() 19 | } 20 | return nil 21 | } 22 | x := p.store[len(p.store)-1] 23 | p.store = p.store[:len(p.store)-1] 24 | return x 25 | } 26 | 27 | func (p *Pool) Put(x interface{}) { 28 | if x == nil { 29 | return 30 | } 31 | p.store = append(p.store, x) 32 | } 33 | 34 | func runtime_registerPoolCleanup(cleanup func()) { 35 | } 36 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/src/sync/sync.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package sync 4 | 5 | import "github.com/gopherjs/gopherjs/js" 6 | 7 | var semWaiters = make(map[*uint32][]chan bool) 8 | 9 | func runtime_Semacquire(s *uint32) { 10 | if *s == 0 { 11 | ch := make(chan bool) 12 | semWaiters[s] = append(semWaiters[s], ch) 13 | <-ch 14 | } 15 | *s-- 16 | } 17 | 18 | // SemacquireMutex is like Semacquire, but for profiling contended Mutexes. 19 | // Mutex profiling is not supported, so just use the same implementation as runtime_Semacquire. 20 | // TODO: Investigate this. If it's possible to implement, consider doing so, otherwise remove this comment. 21 | func runtime_SemacquireMutex(s *uint32, lifo bool) { 22 | // TODO: Use lifo if needed/possible. 23 | runtime_Semacquire(s) 24 | } 25 | 26 | func runtime_Semrelease(s *uint32, handoff bool) { 27 | // TODO: Use handoff if needed/possible. 28 | *s++ 29 | 30 | w := semWaiters[s] 31 | if len(w) == 0 { 32 | return 33 | } 34 | 35 | ch := w[0] 36 | w = w[1:] 37 | semWaiters[s] = w 38 | if len(w) == 0 { 39 | delete(semWaiters, s) 40 | } 41 | 42 | ch <- true 43 | } 44 | 45 | func runtime_notifyListCheck(size uintptr) {} 46 | 47 | func runtime_canSpin(i int) bool { 48 | return false 49 | } 50 | 51 | // Copy of time.runtimeNano. 52 | func runtime_nanotime() int64 { 53 | const millisecond = 1000000 54 | return js.Global.Get("Date").New().Call("getTime").Int64() * millisecond 55 | } 56 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/src/sync/sync_test.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package sync_test 4 | 5 | import ( 6 | "testing" 7 | ) 8 | 9 | func TestPool(t *testing.T) { 10 | t.Skip() 11 | } 12 | 13 | func TestPoolGC(t *testing.T) { 14 | t.Skip() 15 | } 16 | 17 | func TestPoolRelease(t *testing.T) { 18 | t.Skip() 19 | } 20 | 21 | func TestCondCopy(t *testing.T) { 22 | t.Skip() 23 | } 24 | 25 | // TODO: Investigate, fix if possible. 26 | // It fails with "can't acquire Mutex in 10 seconds" 27 | // when using Go 1.8 sync.Mutex implementation. 28 | // It panics with "sync: inconsistent mutex state" 29 | // with Go 1.9 sync.Mutex implementation. 30 | func TestMutexFairness(t *testing.T) { 31 | t.Skip("TestMutexFairness fails") 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/src/sync/waitgroup.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package sync 4 | 5 | type WaitGroup struct { 6 | counter int 7 | ch chan struct{} 8 | 9 | state1 [12]byte 10 | sema uint32 11 | } 12 | 13 | func (wg *WaitGroup) Add(delta int) { 14 | wg.counter += delta 15 | if wg.counter < 0 { 16 | panic("sync: negative WaitGroup counter") 17 | } 18 | if wg.counter > 0 && wg.ch == nil { 19 | wg.ch = make(chan struct{}) 20 | } 21 | if wg.counter == 0 && wg.ch != nil { 22 | close(wg.ch) 23 | wg.ch = nil 24 | } 25 | } 26 | 27 | func (wg *WaitGroup) Wait() { 28 | if wg.counter > 0 { 29 | <-wg.ch 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/src/syscall/syscall.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package syscall 4 | 5 | import ( 6 | "unsafe" 7 | 8 | "github.com/gopherjs/gopherjs/js" 9 | ) 10 | 11 | var warningPrinted = false 12 | var lineBuffer []byte 13 | 14 | func init() { 15 | js.Global.Set("$flushConsole", js.InternalObject(func() { 16 | if len(lineBuffer) != 0 { 17 | js.Global.Get("console").Call("log", string(lineBuffer)) 18 | lineBuffer = nil 19 | } 20 | })) 21 | } 22 | 23 | func printWarning() { 24 | if !warningPrinted { 25 | js.Global.Get("console").Call("error", "warning: system calls not available, see https://github.com/gopherjs/gopherjs/blob/master/doc/syscalls.md") 26 | } 27 | warningPrinted = true 28 | } 29 | 30 | func printToConsole(b []byte) { 31 | goPrintToConsole := js.Global.Get("goPrintToConsole") 32 | if goPrintToConsole != js.Undefined { 33 | goPrintToConsole.Invoke(js.InternalObject(b)) 34 | return 35 | } 36 | 37 | lineBuffer = append(lineBuffer, b...) 38 | for { 39 | i := indexByte(lineBuffer, '\n') 40 | if i == -1 { 41 | break 42 | } 43 | js.Global.Get("console").Call("log", string(lineBuffer[:i])) // don't use println, since it does not externalize multibyte characters 44 | lineBuffer = lineBuffer[i+1:] 45 | } 46 | } 47 | 48 | func use(p unsafe.Pointer) { 49 | // no-op 50 | } 51 | 52 | // indexByte is copied from bytes package to avoid importing it (since the real syscall package doesn't). 53 | func indexByte(s []byte, c byte) int { 54 | for i, b := range s { 55 | if b == c { 56 | return i 57 | } 58 | } 59 | return -1 60 | } 61 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/src/testing/example.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package testing 4 | 5 | import ( 6 | "fmt" 7 | "os" 8 | "strings" 9 | "time" 10 | ) 11 | 12 | func runExample(eg InternalExample) (ok bool) { 13 | if *chatty { 14 | fmt.Printf("=== RUN %s\n", eg.Name) 15 | } 16 | 17 | // Capture stdout. 18 | stdout := os.Stdout 19 | w, err := tempFile("." + eg.Name + ".stdout.") 20 | if err != nil { 21 | fmt.Fprintln(os.Stderr, err) 22 | os.Exit(1) 23 | } 24 | os.Stdout = w 25 | 26 | start := time.Now() 27 | ok = true 28 | 29 | // Clean up in a deferred call so we can recover if the example panics. 30 | defer func() { 31 | dstr := fmtDuration(time.Now().Sub(start)) 32 | 33 | // Close file, restore stdout, get output. 34 | w.Close() 35 | os.Stdout = stdout 36 | out, readFileErr := readFile(w.Name()) 37 | _ = os.Remove(w.Name()) 38 | if readFileErr != nil { 39 | fmt.Fprintf(os.Stderr, "testing: reading stdout file: %v\n", readFileErr) 40 | os.Exit(1) 41 | } 42 | 43 | var fail string 44 | err := recover() 45 | got := strings.TrimSpace(out) 46 | want := strings.TrimSpace(eg.Output) 47 | if eg.Unordered { 48 | if sortLines(got) != sortLines(want) && err == nil { 49 | fail = fmt.Sprintf("got:\n%s\nwant (unordered):\n%s\n", out, eg.Output) 50 | } 51 | } else { 52 | if got != want && err == nil { 53 | fail = fmt.Sprintf("got:\n%s\nwant:\n%s\n", got, want) 54 | } 55 | } 56 | if fail != "" || err != nil { 57 | fmt.Printf("--- FAIL: %s (%s)\n%s", eg.Name, dstr, fail) 58 | ok = false 59 | } else if *chatty { 60 | fmt.Printf("--- PASS: %s (%s)\n", eg.Name, dstr) 61 | } 62 | if err != nil { 63 | panic(err) 64 | } 65 | }() 66 | 67 | // Run example. 68 | eg.F() 69 | return 70 | } 71 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/src/testing/ioutil.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package testing 4 | 5 | import ( 6 | "bytes" 7 | "io" 8 | "os" 9 | "strconv" 10 | "sync" 11 | "time" 12 | ) 13 | 14 | var rand uint32 15 | var randmu sync.Mutex 16 | 17 | func reseed() uint32 { 18 | return uint32(time.Now().UnixNano() + int64(os.Getpid())) 19 | } 20 | 21 | func nextSuffix() string { 22 | randmu.Lock() 23 | r := rand 24 | if r == 0 { 25 | r = reseed() 26 | } 27 | r = r*1664525 + 1013904223 // constants from Numerical Recipes 28 | rand = r 29 | randmu.Unlock() 30 | return strconv.Itoa(int(1e9 + r%1e9))[1:] 31 | } 32 | 33 | // A functional copy of ioutil.TempFile, to avoid extra imports. 34 | func tempFile(prefix string) (f *os.File, err error) { 35 | dir := os.TempDir() 36 | 37 | nconflict := 0 38 | for i := 0; i < 10000; i++ { 39 | name := dir + string(os.PathSeparator) + prefix + nextSuffix() 40 | f, err = os.OpenFile(name, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0600) 41 | if os.IsExist(err) { 42 | if nconflict++; nconflict > 10 { 43 | randmu.Lock() 44 | rand = reseed() 45 | randmu.Unlock() 46 | } 47 | continue 48 | } 49 | break 50 | } 51 | return 52 | } 53 | 54 | func readFile(filename string) (string, error) { 55 | f, err := os.Open(filename) 56 | if err != nil { 57 | return "", err 58 | } 59 | defer f.Close() 60 | var buf bytes.Buffer 61 | _, err = io.Copy(&buf, f) 62 | if err != nil { 63 | return "", err 64 | } 65 | return buf.String(), nil 66 | } 67 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/src/testing/testing.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package testing 4 | 5 | func callerName(skip int) string { 6 | // TODO: Implement if possible. 7 | return "" 8 | } 9 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/src/text/template/template.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package template 4 | 5 | const maxExecDepth = 3000 6 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/natives/src/unicode/unicode.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package unicode 4 | 5 | func to(_case int, r rune, caseRange []CaseRange) rune { 6 | if _case < 0 || MaxCase <= _case { 7 | return ReplacementChar 8 | } 9 | lo := 0 10 | hi := len(caseRange) 11 | for lo < hi { 12 | m := lo + (hi-lo)/2 13 | cr := &caseRange[m] // performance critical for GopherJS: get address here instead of copying the CaseRange 14 | if rune(cr.Lo) <= r && r <= rune(cr.Hi) { 15 | delta := rune(cr.Delta[_case]) 16 | if delta > MaxRune { 17 | return rune(cr.Lo) + ((r-rune(cr.Lo))&^1 | rune(_case&1)) 18 | } 19 | return r + delta 20 | } 21 | if r < rune(cr.Lo) { 22 | hi = m 23 | } else { 24 | lo = m + 1 25 | } 26 | } 27 | return r 28 | } 29 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/prelude/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = [ 6 | "goroutines.go", 7 | "jsmapping.go", 8 | "numeric.go", 9 | "prelude.go", 10 | "types.go", 11 | ], 12 | visibility = ["//visibility:public"], 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/typesutil/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["typesutil.go"], 6 | visibility = ["//visibility:public"], 7 | ) 8 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/typesutil/typesutil.go: -------------------------------------------------------------------------------- 1 | package typesutil 2 | 3 | import ( 4 | "go/types" 5 | "strings" 6 | ) 7 | 8 | func IsJsPackage(pkg *types.Package) bool { 9 | return pkg != nil && (pkg.Path() == "github.com/gopherjs/gopherjs/js" || strings.HasSuffix(pkg.Path(), "/vendor/github.com/gopherjs/gopherjs/js")) 10 | } 11 | 12 | func IsJsObject(t types.Type) bool { 13 | ptr, isPtr := t.(*types.Pointer) 14 | if !isPtr { 15 | return false 16 | } 17 | named, isNamed := ptr.Elem().(*types.Named) 18 | return isNamed && IsJsPackage(named.Obj().Pkg()) && named.Obj().Name() == "Object" 19 | } 20 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/compiler/version_check.go: -------------------------------------------------------------------------------- 1 | // +build !go1.10 2 | // +build go1.9 3 | 4 | package compiler 5 | 6 | const ___GOPHERJS_REQUIRES_GO_VERSION_1_9___ = true 7 | 8 | // Version is the GopherJS compiler version string. 9 | const Version = "1.9-1" 10 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/internal/sysutil/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = [ 6 | "sysutil.go", 7 | ] + select({ 8 | "@io_bazel_rules_go//go/platform:windows_amd64": [ 9 | "sysutil_windows.go", 10 | ], 11 | "//conditions:default": [], 12 | }), 13 | visibility = ["//vendor/github.com/gopherjs/gopherjs:__subpackages__"], 14 | deps = ["//vendor/golang.org/x/sys/unix:go_default_library"], 15 | ) 16 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/internal/sysutil/sysutil.go: -------------------------------------------------------------------------------- 1 | // +build !windows 2 | 3 | // Package sysutil contains system-specific utilities. 4 | package sysutil 5 | 6 | import "golang.org/x/sys/unix" 7 | 8 | // RlimitStack reports the current stack size limit in bytes. 9 | func RlimitStack() (cur uint64, err error) { 10 | var r unix.Rlimit 11 | err = unix.Getrlimit(unix.RLIMIT_STACK, &r) 12 | return r.Cur, err 13 | } 14 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/internal/sysutil/sysutil_windows.go: -------------------------------------------------------------------------------- 1 | package sysutil 2 | 3 | import "errors" 4 | 5 | func RlimitStack() (uint64, error) { 6 | return 0, errors.New("RlimitStack is not implemented on Windows") 7 | } 8 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/js/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["js.go"], 6 | visibility = ["//visibility:public"], 7 | ) 8 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/node-syscall/binding.gyp: -------------------------------------------------------------------------------- 1 | { 2 | 'targets': [ 3 | { 4 | 'target_name': 'syscall', 5 | 'sources': [ 'syscall.cc' ] 6 | } 7 | ] 8 | } -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/nosync/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = [ 6 | "map.go", 7 | "mutex.go", 8 | "once.go", 9 | "pool.go", 10 | ], 11 | visibility = ["//visibility:public"], 12 | ) 13 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/nosync/map.go: -------------------------------------------------------------------------------- 1 | package nosync 2 | 3 | // Map is a concurrent map with amortized-constant-time loads, stores, and deletes. 4 | // It is safe for multiple goroutines to call a Map's methods concurrently. 5 | // 6 | // The zero Map is valid and empty. 7 | // 8 | // A Map must not be copied after first use. 9 | type Map struct { 10 | m map[interface{}]interface{} 11 | } 12 | 13 | // Load returns the value stored in the map for a key, or nil if no 14 | // value is present. 15 | // The ok result indicates whether value was found in the map. 16 | func (m *Map) Load(key interface{}) (value interface{}, ok bool) { 17 | value, ok = m.m[key] 18 | return value, ok 19 | } 20 | 21 | // Store sets the value for a key. 22 | func (m *Map) Store(key, value interface{}) { 23 | if m.m == nil { 24 | m.m = make(map[interface{}]interface{}) 25 | } 26 | m.m[key] = value 27 | } 28 | 29 | // LoadOrStore returns the existing value for the key if present. 30 | // Otherwise, it stores and returns the given value. 31 | // The loaded result is true if the value was loaded, false if stored. 32 | func (m *Map) LoadOrStore(key, value interface{}) (actual interface{}, loaded bool) { 33 | if value, ok := m.m[key]; ok { 34 | return value, true 35 | } 36 | if m.m == nil { 37 | m.m = make(map[interface{}]interface{}) 38 | } 39 | m.m[key] = value 40 | return value, false 41 | } 42 | 43 | // Delete deletes the value for a key. 44 | func (m *Map) Delete(key interface{}) { 45 | if m.m == nil { 46 | return 47 | } 48 | delete(m.m, key) 49 | } 50 | 51 | // Range calls f sequentially for each key and value present in the map. 52 | // If f returns false, range stops the iteration. 53 | // 54 | // Range does not necessarily correspond to any consistent snapshot of the Map's 55 | // contents: no key will be visited more than once, but if the value for any key 56 | // is stored or deleted concurrently, Range may reflect any mapping for that key 57 | // from any point during the Range call. 58 | // 59 | // Range may be O(N) with the number of elements in the map even if f returns 60 | // false after a constant number of calls. 61 | func (m *Map) Range(f func(key, value interface{}) bool) { 62 | for k, v := range m.m { 63 | if !f(k, v) { 64 | break 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/nosync/mutex.go: -------------------------------------------------------------------------------- 1 | package nosync 2 | 3 | // Mutex is a dummy which is non-blocking. 4 | type Mutex struct { 5 | locked bool 6 | } 7 | 8 | // Lock locks m. It is a run-time error if m is already locked. 9 | func (m *Mutex) Lock() { 10 | if m.locked { 11 | panic("nosync: mutex is already locked") 12 | } 13 | m.locked = true 14 | } 15 | 16 | // Unlock unlocks m. It is a run-time error if m is not locked. 17 | func (m *Mutex) Unlock() { 18 | if !m.locked { 19 | panic("nosync: unlock of unlocked mutex") 20 | } 21 | m.locked = false 22 | } 23 | 24 | // RWMutex is a dummy which is non-blocking. 25 | type RWMutex struct { 26 | writeLocked bool 27 | readLockCounter int 28 | } 29 | 30 | // Lock locks m for writing. It is a run-time error if rw is already locked for reading or writing. 31 | func (rw *RWMutex) Lock() { 32 | if rw.readLockCounter != 0 || rw.writeLocked { 33 | panic("nosync: mutex is already locked") 34 | } 35 | rw.writeLocked = true 36 | } 37 | 38 | // Unlock unlocks rw for writing. It is a run-time error if rw is not locked for writing. 39 | func (rw *RWMutex) Unlock() { 40 | if !rw.writeLocked { 41 | panic("nosync: unlock of unlocked mutex") 42 | } 43 | rw.writeLocked = false 44 | } 45 | 46 | // RLock locks m for reading. It is a run-time error if rw is already locked for reading or writing. 47 | func (rw *RWMutex) RLock() { 48 | if rw.writeLocked { 49 | panic("nosync: mutex is already locked") 50 | } 51 | rw.readLockCounter++ 52 | } 53 | 54 | // RUnlock undoes a single RLock call; it does not affect other simultaneous readers. It is a run-time error if rw is not locked for reading. 55 | func (rw *RWMutex) RUnlock() { 56 | if rw.readLockCounter == 0 { 57 | panic("nosync: unlock of unlocked mutex") 58 | } 59 | rw.readLockCounter-- 60 | } 61 | 62 | // WaitGroup is a dummy which is non-blocking. 63 | type WaitGroup struct { 64 | counter int 65 | } 66 | 67 | // Add adds delta, which may be negative, to the WaitGroup If the counter goes negative, Add panics. 68 | func (wg *WaitGroup) Add(delta int) { 69 | wg.counter += delta 70 | if wg.counter < 0 { 71 | panic("sync: negative WaitGroup counter") 72 | } 73 | } 74 | 75 | // Done decrements the WaitGroup counter. 76 | func (wg *WaitGroup) Done() { 77 | wg.Add(-1) 78 | } 79 | 80 | // Wait panics if the WaitGroup counter is not zero. 81 | func (wg *WaitGroup) Wait() { 82 | if wg.counter != 0 { 83 | panic("sync: WaitGroup counter not zero") 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/nosync/once.go: -------------------------------------------------------------------------------- 1 | package nosync 2 | 3 | // Once is an object that will perform exactly one action. 4 | type Once struct { 5 | doing bool 6 | done bool 7 | } 8 | 9 | // Do calls the function f if and only if Do is being called for the 10 | // first time for this instance of Once. In other words, given 11 | // var once Once 12 | // if once.Do(f) is called multiple times, only the first call will invoke f, 13 | // even if f has a different value in each invocation. A new instance of 14 | // Once is required for each function to execute. 15 | // 16 | // Do is intended for initialization that must be run exactly once. Since f 17 | // is niladic, it may be necessary to use a function literal to capture the 18 | // arguments to a function to be invoked by Do: 19 | // config.once.Do(func() { config.init(filename) }) 20 | // 21 | // If f causes Do to be called, it will panic. 22 | // 23 | // If f panics, Do considers it to have returned; future calls of Do return 24 | // without calling f. 25 | // 26 | func (o *Once) Do(f func()) { 27 | if o.done { 28 | return 29 | } 30 | if o.doing { 31 | panic("nosync: Do called within f") 32 | } 33 | o.doing = true 34 | defer func() { 35 | o.doing = false 36 | o.done = true 37 | }() 38 | f() 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/nosync/pool.go: -------------------------------------------------------------------------------- 1 | package nosync 2 | 3 | // A Pool is a set of temporary objects that may be individually saved and 4 | // retrieved. 5 | // 6 | // Any item stored in the Pool may be removed automatically at any time without 7 | // notification. If the Pool holds the only reference when this happens, the 8 | // item might be deallocated. 9 | // 10 | // A Pool is safe for use by multiple goroutines simultaneously. 11 | // 12 | // Pool's purpose is to cache allocated but unused items for later reuse, 13 | // relieving pressure on the garbage collector. That is, it makes it easy to 14 | // build efficient, thread-safe free lists. However, it is not suitable for all 15 | // free lists. 16 | // 17 | // An appropriate use of a Pool is to manage a group of temporary items 18 | // silently shared among and potentially reused by concurrent independent 19 | // clients of a package. Pool provides a way to amortize allocation overhead 20 | // across many clients. 21 | // 22 | // An example of good use of a Pool is in the fmt package, which maintains a 23 | // dynamically-sized store of temporary output buffers. The store scales under 24 | // load (when many goroutines are actively printing) and shrinks when 25 | // quiescent. 26 | // 27 | // On the other hand, a free list maintained as part of a short-lived object is 28 | // not a suitable use for a Pool, since the overhead does not amortize well in 29 | // that scenario. It is more efficient to have such objects implement their own 30 | // free list. 31 | // 32 | type Pool struct { 33 | store []interface{} 34 | New func() interface{} 35 | } 36 | 37 | // Get selects an arbitrary item from the Pool, removes it from the 38 | // Pool, and returns it to the caller. 39 | // Get may choose to ignore the pool and treat it as empty. 40 | // Callers should not assume any relation between values passed to Put and 41 | // the values returned by Get. 42 | // 43 | // If Get would otherwise return nil and p.New is non-nil, Get returns 44 | // the result of calling p.New. 45 | func (p *Pool) Get() interface{} { 46 | if len(p.store) == 0 { 47 | if p.New != nil { 48 | return p.New() 49 | } 50 | return nil 51 | } 52 | x := p.store[len(p.store)-1] 53 | p.store = p.store[:len(p.store)-1] 54 | return x 55 | } 56 | 57 | // Put adds x to the pool. 58 | func (p *Pool) Put(x interface{}) { 59 | if x == nil { 60 | return 61 | } 62 | p.store = append(p.store, x) 63 | } 64 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/tests/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["doc.go"], 6 | visibility = ["//visibility:public"], 7 | ) 8 | 9 | go_test( 10 | name = "go_default_test", 11 | srcs = [ 12 | "alias_test.go", 13 | "copy_test.go", 14 | "deferblock_test.go", 15 | "goroutine_test.go", 16 | "misc_test.go", 17 | ], 18 | library = ":go_default_library", 19 | deps = ["//vendor/github.com/gopherjs/gopherjs/tests/otherpkg:go_default_library"], 20 | ) 21 | 22 | go_test( 23 | name = "go_default_xtest", 24 | srcs = [ 25 | "gorepo_test.go", 26 | "lowlevel_test.go", 27 | ], 28 | ) 29 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/tests/alias_test.go: -------------------------------------------------------------------------------- 1 | package tests 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | type foo struct { 8 | a int 9 | } 10 | 11 | func Test1(t *testing.T) { 12 | calls := 0 13 | bar := func() *foo { 14 | calls++ 15 | return &foo{42} 16 | } 17 | q := &bar().a 18 | if calls != 1 { 19 | t.Error("Should've been a call") 20 | } 21 | *q = 40 22 | if calls != 1 { 23 | t.Error("Wrong number of calls: ", calls, ", should be 1") 24 | } 25 | if *q != 40 { 26 | t.Error("*q != 40") 27 | } 28 | } 29 | 30 | func Test2(t *testing.T) { 31 | f := foo{} 32 | p := &f.a 33 | f = foo{} 34 | f.a = 4 35 | if *p != 4 { 36 | t.Error("*p != 4") 37 | } 38 | } 39 | 40 | func Test3(t *testing.T) { 41 | f := foo{} 42 | p := &f 43 | f = foo{4} 44 | if p.a != 4 { 45 | t.Error("p.a != 4") 46 | } 47 | } 48 | 49 | func Test4(t *testing.T) { 50 | f := struct { 51 | a struct { 52 | b int 53 | } 54 | }{} 55 | p := &f.a 56 | q := &p.b 57 | r := &(*p).b 58 | *r = 4 59 | p = nil 60 | if *r != 4 { 61 | t.Error("*r != 4") 62 | } 63 | if *q != 4 { 64 | t.Error("*q != 4") 65 | } 66 | } 67 | 68 | func Test5(t *testing.T) { 69 | f := struct { 70 | a [3]int 71 | }{[3]int{6, 6, 6}} 72 | s := f.a[:] 73 | f.a = [3]int{4, 4, 4} 74 | if s[1] != 4 { 75 | t.Error("s[1] != 4") 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/tests/copy_test.go: -------------------------------------------------------------------------------- 1 | package tests 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | type S struct { 8 | x int 9 | } 10 | 11 | func (a S) test(b S) { 12 | a.x = 0 13 | b.x = 0 14 | } 15 | 16 | type A [1]int 17 | 18 | func (a A) test(b A) { 19 | a[0] = 0 20 | b[0] = 0 21 | } 22 | 23 | func TestCopyOnCall(t *testing.T) { 24 | { 25 | a := S{1} 26 | b := S{2} 27 | 28 | a.test(b) 29 | func() { 30 | defer a.test(b) 31 | }() 32 | 33 | if a.x != 1 { 34 | t.Error("a.x != 1") 35 | } 36 | if b.x != 2 { 37 | t.Error("b.x != 2") 38 | } 39 | } 40 | { 41 | a := A{1} 42 | b := A{2} 43 | 44 | a.test(b) 45 | func() { 46 | defer a.test(b) 47 | }() 48 | 49 | if a[0] != 1 { 50 | t.Error("a[0] != 1") 51 | } 52 | if b[0] != 2 { 53 | t.Error("b[0] != 2") 54 | } 55 | } 56 | } 57 | 58 | func TestSwap(t *testing.T) { 59 | { 60 | a := S{1} 61 | b := S{2} 62 | a, b = b, a 63 | if a.x != 2 || b.x != 1 { 64 | t.Fail() 65 | } 66 | } 67 | { 68 | a := A{1} 69 | b := A{2} 70 | a, b = b, a 71 | if a[0] != 2 || b[0] != 1 { 72 | t.Fail() 73 | } 74 | } 75 | } 76 | 77 | func TestComposite(t *testing.T) { 78 | { 79 | a := S{1} 80 | s := []S{a} 81 | s[0].x = 0 82 | if a.x != 1 { 83 | t.Fail() 84 | } 85 | } 86 | { 87 | a := A{1} 88 | s := []A{a} 89 | s[0][0] = 0 90 | if a[0] != 1 { 91 | t.Fail() 92 | } 93 | } 94 | } 95 | 96 | func TestAppend(t *testing.T) { 97 | { 98 | s := append(make([]S, 3), S{}) // cap(s) == 6 99 | s = s[:6] 100 | if s[5].x != 0 { 101 | t.Fail() 102 | } 103 | } 104 | 105 | { 106 | a := S{1} 107 | b := []S{{2}} 108 | s := append([]S{}, b...) 109 | s[0].x = 0 110 | if a.x != 1 || b[0].x != 2 { 111 | t.Fail() 112 | } 113 | } 114 | } 115 | 116 | type I interface { 117 | M() int 118 | } 119 | 120 | type T S 121 | 122 | func (t T) M() int { 123 | return t.x 124 | } 125 | 126 | func TestExplicitConversion(t *testing.T) { 127 | var coolGuy = S{x: 42} 128 | var i I 129 | i = T(coolGuy) 130 | if i.M() != 42 { 131 | t.Fail() 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/tests/deferblock_test.go: -------------------------------------------------------------------------------- 1 | package tests 2 | 3 | import ( 4 | "testing" 5 | "time" 6 | ) 7 | 8 | func inner(ch chan struct{}, b bool) ([]byte, error) { 9 | // ensure gopherjs thinks that this inner function can block 10 | if b { 11 | <-ch 12 | } 13 | return []byte{}, nil 14 | } 15 | 16 | // this function's call to inner never blocks, but the deferred 17 | // statement does. 18 | func outer(ch chan struct{}, b bool) ([]byte, error) { 19 | defer func() { 20 | <-ch 21 | }() 22 | 23 | return inner(ch, b) 24 | } 25 | 26 | func TestBlockingInDefer(t *testing.T) { 27 | defer func() { 28 | if x := recover(); x != nil { 29 | t.Errorf("run time panic: %v", x) 30 | } 31 | }() 32 | 33 | ch := make(chan struct{}) 34 | b := false 35 | 36 | go func() { 37 | time.Sleep(5 * time.Millisecond) 38 | ch <- struct{}{} 39 | }() 40 | 41 | outer(ch, b) 42 | } 43 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/tests/doc.go: -------------------------------------------------------------------------------- 1 | // Package tests contains tests for GopherJS. 2 | package tests 3 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/tests/gorepo_test.go: -------------------------------------------------------------------------------- 1 | // +build !js 2 | 3 | package tests_test 4 | 5 | import ( 6 | "os" 7 | "os/exec" 8 | "testing" 9 | ) 10 | 11 | // Go repository basic compiler tests, and regression tests for fixed compiler bugs. 12 | func TestGoRepositoryCompilerTests(t *testing.T) { 13 | args := []string{"go", "run", "run.go", "-summary"} 14 | if testing.Verbose() { 15 | args = append(args, "-v") 16 | } 17 | cmd := exec.Command(args[0], args[1:]...) 18 | cmd.Stdout = os.Stdout 19 | cmd.Stderr = os.Stdout 20 | err := cmd.Run() 21 | if err != nil { 22 | t.Fatal(err) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/tests/lowlevel_test.go: -------------------------------------------------------------------------------- 1 | // +build !js 2 | 3 | package tests_test 4 | 5 | import ( 6 | "bytes" 7 | "io/ioutil" 8 | "os/exec" 9 | "path/filepath" 10 | "testing" 11 | ) 12 | 13 | // Test for internalization/externalization of time.Time/Date when time package is imported 14 | // but time.Time is unused, causing it to be DCEed (or time package not imported at all). 15 | // 16 | // See https://github.com/gopherjs/gopherjs/issues/279. 17 | func TestTimeInternalizationExternalization(t *testing.T) { 18 | got, err := exec.Command("gopherjs", "run", filepath.Join("testdata", "time_inexternalization.go")).Output() 19 | if err != nil { 20 | t.Fatalf("%v:\n%s", err, got) 21 | } 22 | 23 | want, err := ioutil.ReadFile(filepath.Join("testdata", "time_inexternalization.out")) 24 | if err != nil { 25 | t.Fatalf("error reading .out file: %v", err) 26 | } 27 | 28 | if !bytes.Equal(got, want) { 29 | t.Fatalf("got != want:\ngot:\n%s\nwant:\n%s", got, want) 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/tests/main/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["main.go"], 6 | visibility = ["//visibility:private"], 7 | ) 8 | 9 | go_binary( 10 | name = "main", 11 | library = ":go_default_library", 12 | visibility = ["//visibility:public"], 13 | ) 14 | 15 | go_test( 16 | name = "go_default_test", 17 | srcs = ["main_test.go"], 18 | library = ":go_default_library", 19 | ) 20 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/tests/main/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | var mainDidRun = false 4 | 5 | func main() { 6 | mainDidRun = true 7 | } 8 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/tests/main/main_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "testing" 4 | 5 | func TestNotRunMain(t *testing.T) { 6 | if mainDidRun { 7 | t.Error("main function did run") 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/tests/otherpkg/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["otherpkg.go"], 6 | visibility = ["//visibility:public"], 7 | ) 8 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/tests/otherpkg/otherpkg.go: -------------------------------------------------------------------------------- 1 | package otherpkg 2 | 3 | var Test float32 4 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/tests/testdata/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["time_inexternalization.go"], 6 | visibility = ["//visibility:private"], 7 | deps = ["//vendor/github.com/gopherjs/gopherjs/js:go_default_library"], 8 | ) 9 | 10 | go_binary( 11 | name = "testdata", 12 | library = ":go_default_library", 13 | visibility = ["//visibility:public"], 14 | ) 15 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/tests/testdata/time_inexternalization.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "time" 5 | 6 | "github.com/gopherjs/gopherjs/js" 7 | ) 8 | 9 | var _ = time.Sleep // Force "time" package to be imported but let time.Time and time.Unix be DCEed since they're not used. 10 | 11 | func main() { 12 | // Excercise externalization of Go struct (with its special handling of time.Time). 13 | js.Global.Get("console").Call("log", struct{ S string }{"externalization ok"}) 14 | 15 | // Excercise internalization of JavaScript Date object (with its special handling of time.Time). 16 | date := js.Global.Get("Date").New("2015-08-29T20:56:00.869Z").Interface() 17 | js.Global.Set("myDate", date) 18 | js.Global.Get("console").Call("log", js.Global.Get("myDate").Call("toUTCString")) 19 | } 20 | -------------------------------------------------------------------------------- /vendor/github.com/gopherjs/gopherjs/tests/testdata/time_inexternalization.out: -------------------------------------------------------------------------------- 1 | { S: 'externalization ok' } 2 | Sat, 29 Aug 2015 20:56:00 GMT 3 | -------------------------------------------------------------------------------- /vendor/github.com/jtolds/gls/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = [ 6 | "context.go", 7 | "gen_sym.go", 8 | "gid.go", 9 | "id_pool.go", 10 | "stack_tags.go", 11 | "stack_tags_main.go", 12 | ], 13 | visibility = ["//visibility:public"], 14 | ) 15 | 16 | go_test( 17 | name = "go_default_xtest", 18 | srcs = ["context_test.go"], 19 | deps = [":go_default_library"], 20 | ) 21 | -------------------------------------------------------------------------------- /vendor/github.com/jtolds/gls/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013, Space Monkey, Inc. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 19 | -------------------------------------------------------------------------------- /vendor/github.com/jtolds/gls/gen_sym.go: -------------------------------------------------------------------------------- 1 | package gls 2 | 3 | import ( 4 | "sync" 5 | ) 6 | 7 | var ( 8 | keyMtx sync.Mutex 9 | keyCounter uint64 10 | ) 11 | 12 | // ContextKey is a throwaway value you can use as a key to a ContextManager 13 | type ContextKey struct{ id uint64 } 14 | 15 | // GenSym will return a brand new, never-before-used ContextKey 16 | func GenSym() ContextKey { 17 | keyMtx.Lock() 18 | defer keyMtx.Unlock() 19 | keyCounter += 1 20 | return ContextKey{id: keyCounter} 21 | } 22 | -------------------------------------------------------------------------------- /vendor/github.com/jtolds/gls/gid.go: -------------------------------------------------------------------------------- 1 | package gls 2 | 3 | var ( 4 | stackTagPool = &idPool{} 5 | ) 6 | 7 | // Will return this goroutine's identifier if set. If you always need a 8 | // goroutine identifier, you should use EnsureGoroutineId which will make one 9 | // if there isn't one already. 10 | func GetGoroutineId() (gid uint, ok bool) { 11 | return readStackTag() 12 | } 13 | 14 | // Will call cb with the current goroutine identifier. If one hasn't already 15 | // been generated, one will be created and set first. The goroutine identifier 16 | // might be invalid after cb returns. 17 | func EnsureGoroutineId(cb func(gid uint)) { 18 | if gid, ok := readStackTag(); ok { 19 | cb(gid) 20 | return 21 | } 22 | gid := stackTagPool.Acquire() 23 | defer stackTagPool.Release(gid) 24 | addStackTag(gid, func() { cb(gid) }) 25 | } 26 | -------------------------------------------------------------------------------- /vendor/github.com/jtolds/gls/id_pool.go: -------------------------------------------------------------------------------- 1 | package gls 2 | 3 | // though this could probably be better at keeping ids smaller, the goal of 4 | // this class is to keep a registry of the smallest unique integer ids 5 | // per-process possible 6 | 7 | import ( 8 | "sync" 9 | ) 10 | 11 | type idPool struct { 12 | mtx sync.Mutex 13 | released []uint 14 | max_id uint 15 | } 16 | 17 | func (p *idPool) Acquire() (id uint) { 18 | p.mtx.Lock() 19 | defer p.mtx.Unlock() 20 | if len(p.released) > 0 { 21 | id = p.released[len(p.released)-1] 22 | p.released = p.released[:len(p.released)-1] 23 | return id 24 | } 25 | id = p.max_id 26 | p.max_id++ 27 | return id 28 | } 29 | 30 | func (p *idPool) Release(id uint) { 31 | p.mtx.Lock() 32 | defer p.mtx.Unlock() 33 | p.released = append(p.released, id) 34 | } 35 | -------------------------------------------------------------------------------- /vendor/github.com/jtolds/gls/stack_tags_js.go: -------------------------------------------------------------------------------- 1 | // +build js 2 | 3 | package gls 4 | 5 | // This file is used for GopherJS builds, which don't have normal runtime 6 | // stack trace support 7 | 8 | import ( 9 | "strconv" 10 | "strings" 11 | 12 | "github.com/gopherjs/gopherjs/js" 13 | ) 14 | 15 | const ( 16 | jsFuncNamePrefix = "github_com_jtolds_gls_mark" 17 | ) 18 | 19 | func jsMarkStack() (f []uintptr) { 20 | lines := strings.Split( 21 | js.Global.Get("Error").New().Get("stack").String(), "\n") 22 | f = make([]uintptr, 0, len(lines)) 23 | for i, line := range lines { 24 | line = strings.TrimSpace(line) 25 | if line == "" { 26 | continue 27 | } 28 | if i == 0 { 29 | if line != "Error" { 30 | panic("didn't understand js stack trace") 31 | } 32 | continue 33 | } 34 | fields := strings.Fields(line) 35 | if len(fields) < 2 || fields[0] != "at" { 36 | panic("didn't understand js stack trace") 37 | } 38 | 39 | pos := strings.Index(fields[1], jsFuncNamePrefix) 40 | if pos < 0 { 41 | continue 42 | } 43 | pos += len(jsFuncNamePrefix) 44 | if pos >= len(fields[1]) { 45 | panic("didn't understand js stack trace") 46 | } 47 | char := string(fields[1][pos]) 48 | switch char { 49 | case "S": 50 | f = append(f, uintptr(0)) 51 | default: 52 | val, err := strconv.ParseUint(char, 16, 8) 53 | if err != nil { 54 | panic("didn't understand js stack trace") 55 | } 56 | f = append(f, uintptr(val)+1) 57 | } 58 | } 59 | return f 60 | } 61 | 62 | // variables to prevent inlining 63 | var ( 64 | findPtr = func() uintptr { 65 | funcs := jsMarkStack() 66 | if len(funcs) == 0 { 67 | panic("failed to find function pointer") 68 | } 69 | return funcs[0] 70 | } 71 | 72 | getStack = func(offset, amount int) (stack []uintptr, next_offset int) { 73 | return jsMarkStack(), 0 74 | } 75 | ) 76 | -------------------------------------------------------------------------------- /vendor/github.com/jtolds/gls/stack_tags_main.go: -------------------------------------------------------------------------------- 1 | // +build !js 2 | 3 | package gls 4 | 5 | // This file is used for standard Go builds, which have the expected runtime 6 | // support 7 | 8 | import ( 9 | "runtime" 10 | ) 11 | 12 | var ( 13 | findPtr = func() uintptr { 14 | var pc [1]uintptr 15 | n := runtime.Callers(4, pc[:]) 16 | if n != 1 { 17 | panic("failed to find function pointer") 18 | } 19 | return pc[0] 20 | } 21 | 22 | getStack = func(offset, amount int) (stack []uintptr, next_offset int) { 23 | stack = make([]uintptr, amount) 24 | stack = stack[:runtime.Callers(offset, stack)] 25 | if len(stack) < amount { 26 | return stack, 0 27 | } 28 | return stack, offset + len(stack) 29 | } 30 | ) 31 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | Thumbs.db 3 | *.iml 4 | /.idea 5 | coverage.out 6 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.x 5 | - master 6 | 7 | install: 8 | - go get -t ./... 9 | 10 | script: go test -v 11 | 12 | sudo: false 13 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = [ 6 | "collections.go", 7 | "doc.go", 8 | "equal_method.go", 9 | "equality.go", 10 | "filter.go", 11 | "messages.go", 12 | "panic.go", 13 | "quantity.go", 14 | "serializer.go", 15 | "strings.go", 16 | "time.go", 17 | "type.go", 18 | ], 19 | visibility = ["//visibility:public"], 20 | deps = [ 21 | "//vendor/github.com/smartystreets/assertions/internal/go-render/render:go_default_library", 22 | "//vendor/github.com/smartystreets/assertions/internal/oglematchers:go_default_library", 23 | ], 24 | ) 25 | 26 | go_test( 27 | name = "go_default_test", 28 | srcs = [ 29 | "collections_test.go", 30 | "doc_test.go", 31 | "equal_method_test.go", 32 | "equality_test.go", 33 | "panic_test.go", 34 | "quantity_test.go", 35 | "serializer_test.go", 36 | "strings_test.go", 37 | "time_test.go", 38 | "type_test.go", 39 | "utilities_for_test.go", 40 | ], 41 | library = ":go_default_library", 42 | deps = ["//vendor/github.com/smartystreets/gunit:go_default_library"], 43 | ) 44 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | In general, the code posted to the [SmartyStreets github organization](https://github.com/smartystreets) is created to solve specific problems at SmartyStreets that are ancillary to our core products in the address verification industry and may or may not be useful to other organizations or developers. Our reason for posting said code isn't necessarily to solicit feedback or contributions from the community but more as a showcase of some of the approaches to solving problems we have adopted. 4 | 5 | Having stated that, we do consider issues raised by other githubbers as well as contributions submitted via pull requests. When submitting such a pull request, please follow these guidelines: 6 | 7 | - _Look before you leap:_ If the changes you plan to make are significant, it's in everyone's best interest for you to discuss them with a SmartyStreets team member prior to opening a pull request. 8 | - _License and ownership:_ If modifying the `LICENSE.md` file, limit your changes to fixing typographical mistakes. Do NOT modify the actual terms in the license or the copyright by **SmartyStreets, LLC**. Code submitted to SmartyStreets projects becomes property of SmartyStreets and must be compatible with the associated license. 9 | - _Testing:_ If the code you are submitting resides in packages/modules covered by automated tests, be sure to add passing tests that cover your changes and assert expected behavior and state. Submit the additional test cases as part of your change set. 10 | - _Style:_ Match your approach to **naming** and **formatting** with the surrounding code. Basically, the code you submit shouldn't stand out. 11 | - "Naming" refers to such constructs as variables, methods, functions, classes, structs, interfaces, packages, modules, directories, files, etc... 12 | - "Formatting" refers to such constructs as whitespace, horizontal line length, vertical function length, vertical file length, indentation, curly braces, etc... 13 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 SmartyStreets, LLC 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | 21 | NOTE: Various optional and subordinate components carry their own licensing 22 | requirements and restrictions. Use of those components is subject to the terms 23 | and conditions outlined the respective license of each component. 24 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/doc_test.go: -------------------------------------------------------------------------------- 1 | package assertions 2 | 3 | import ( 4 | "bytes" 5 | "fmt" 6 | "reflect" 7 | "testing" 8 | ) 9 | 10 | func TestGoConveyModeAffectsSerializer(t *testing.T) { 11 | if reflect.TypeOf(serializer) != reflect.TypeOf(new(noopSerializer)) { 12 | t.Error("Expected noop serializer as default") 13 | } 14 | 15 | GoConveyMode(true) 16 | if reflect.TypeOf(serializer) != reflect.TypeOf(new(failureSerializer)) { 17 | t.Error("Expected failure serializer") 18 | } 19 | 20 | GoConveyMode(false) 21 | if reflect.TypeOf(serializer) != reflect.TypeOf(new(noopSerializer)) { 22 | t.Error("Expected noop serializer") 23 | } 24 | } 25 | 26 | func TestPassingAssertion(t *testing.T) { 27 | fake := &FakeT{buffer: new(bytes.Buffer)} 28 | assertion := New(fake) 29 | passed := assertion.So(1, ShouldEqual, 1) 30 | 31 | if !passed { 32 | t.Error("Assertion failed when it should have passed.") 33 | } 34 | if fake.buffer.Len() > 0 { 35 | t.Error("Unexpected error message was printed.") 36 | } 37 | } 38 | 39 | func TestFailingAssertion(t *testing.T) { 40 | fake := &FakeT{buffer: new(bytes.Buffer)} 41 | assertion := New(fake) 42 | passed := assertion.So(1, ShouldEqual, 2) 43 | 44 | if passed { 45 | t.Error("Assertion passed when it should have failed.") 46 | } 47 | if fake.buffer.Len() == 0 { 48 | t.Error("Expected error message not printed.") 49 | } 50 | } 51 | 52 | func TestFailingGroupsOfAssertions(t *testing.T) { 53 | fake := &FakeT{buffer: new(bytes.Buffer)} 54 | assertion1 := New(fake) 55 | assertion2 := New(fake) 56 | 57 | assertion1.So(1, ShouldEqual, 2) // fail 58 | assertion2.So(1, ShouldEqual, 1) // pass 59 | 60 | if !assertion1.Failed() { 61 | t.Error("Expected the first assertion to have been marked as failed.") 62 | } 63 | if assertion2.Failed() { 64 | t.Error("Expected the second assertion to NOT have been marked as failed.") 65 | } 66 | } 67 | 68 | type FakeT struct { 69 | buffer *bytes.Buffer 70 | } 71 | 72 | func (this *FakeT) Error(args ...interface{}) { 73 | fmt.Fprint(this.buffer, args...) 74 | } 75 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/equal_method.go: -------------------------------------------------------------------------------- 1 | package assertions 2 | 3 | import "reflect" 4 | 5 | type equalityMethodSpecification struct { 6 | a interface{} 7 | b interface{} 8 | 9 | aType reflect.Type 10 | bType reflect.Type 11 | 12 | equalMethod reflect.Value 13 | } 14 | 15 | func newEqualityMethodSpecification(a, b interface{}) *equalityMethodSpecification { 16 | return &equalityMethodSpecification{ 17 | a: a, 18 | b: b, 19 | } 20 | } 21 | 22 | func (this *equalityMethodSpecification) IsSatisfied() bool { 23 | if !this.bothAreSameType() { 24 | return false 25 | } 26 | if !this.typeHasEqualMethod() { 27 | return false 28 | } 29 | if !this.equalMethodReceivesSameTypeForComparison() { 30 | return false 31 | } 32 | if !this.equalMethodReturnsBool() { 33 | return false 34 | } 35 | return true 36 | } 37 | 38 | func (this *equalityMethodSpecification) bothAreSameType() bool { 39 | this.aType = reflect.TypeOf(this.a) 40 | if this.aType == nil { 41 | return false 42 | } 43 | if this.aType.Kind() == reflect.Ptr { 44 | this.aType = this.aType.Elem() 45 | } 46 | this.bType = reflect.TypeOf(this.b) 47 | return this.aType == this.bType 48 | } 49 | func (this *equalityMethodSpecification) typeHasEqualMethod() bool { 50 | aInstance := reflect.ValueOf(this.a) 51 | this.equalMethod = aInstance.MethodByName("Equal") 52 | return this.equalMethod != reflect.Value{} 53 | } 54 | 55 | func (this *equalityMethodSpecification) equalMethodReceivesSameTypeForComparison() bool { 56 | signature := this.equalMethod.Type() 57 | return signature.NumIn() == 1 && signature.In(0) == this.aType 58 | } 59 | 60 | func (this *equalityMethodSpecification) equalMethodReturnsBool() bool { 61 | signature := this.equalMethod.Type() 62 | return signature.NumOut() == 1 && signature.Out(0) == reflect.TypeOf(true) 63 | } 64 | 65 | func (this *equalityMethodSpecification) AreEqual() bool { 66 | a := reflect.ValueOf(this.a) 67 | b := reflect.ValueOf(this.b) 68 | return areEqual(a, b) && areEqual(b, a) 69 | } 70 | func areEqual(receiver reflect.Value, argument reflect.Value) bool { 71 | equalMethod := receiver.MethodByName("Equal") 72 | argumentList := []reflect.Value{argument} 73 | result := equalMethod.Call(argumentList) 74 | return result[0].Bool() 75 | } 76 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/filter.go: -------------------------------------------------------------------------------- 1 | package assertions 2 | 3 | import "fmt" 4 | 5 | const ( 6 | success = "" 7 | needExactValues = "This assertion requires exactly %d comparison values (you provided %d)." 8 | needNonEmptyCollection = "This assertion requires at least 1 comparison value (you provided 0)." 9 | needFewerValues = "This assertion allows %d or fewer comparison values (you provided %d)." 10 | ) 11 | 12 | func need(needed int, expected []interface{}) string { 13 | if len(expected) != needed { 14 | return fmt.Sprintf(needExactValues, needed, len(expected)) 15 | } 16 | return success 17 | } 18 | 19 | func atLeast(minimum int, expected []interface{}) string { 20 | if len(expected) < 1 { 21 | return needNonEmptyCollection 22 | } 23 | return success 24 | } 25 | 26 | func atMost(max int, expected []interface{}) string { 27 | if len(expected) > max { 28 | return fmt.Sprintf(needFewerValues, max, len(expected)) 29 | } 30 | return success 31 | } 32 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/Makefile: -------------------------------------------------------------------------------- 1 | # This Makefile pulls the latest oglematchers (with dependencies), 2 | # rewrites the imports to match this location, 3 | # and ensures that all the tests pass. 4 | # BTW, things used from oglematchers: Contains, Equals, DeepEquals, GreaterThan, LessThan, GreaterOrEqual, LessOrEqual 5 | 6 | test: 7 | go test github.com/smartystreets/assertions/... 8 | 9 | update: clear clone rewrite trim 10 | 11 | clear: 12 | rm -rf ogle* 13 | rm -rf reqtrace 14 | rm -rf go-render 15 | 16 | clone: 17 | git clone https://github.com/jacobsa/oglematchers.git && rm -rf oglematchers/.git 18 | git clone https://github.com/luci/go-render.git && rm -rf go-render/.git 19 | 20 | rewrite: 21 | grep -rl --exclude Makefile 'github.com/jacobsa' . | xargs sed -i '' 's#github.com/jacobsa#github.com/smartystreets/assertions/internal#g' 22 | 23 | trim: 24 | git checkout oglematchers/contains.go # This file diverged at 6acd0337 25 | rm oglematchers/*_test.go 26 | rm oglematchers/any.go 27 | rm oglematchers/all_of.go 28 | rm oglematchers/elements_are.go 29 | rm oglematchers/error.go 30 | rm oglematchers/has_same_type_as.go 31 | rm oglematchers/has_substr.go 32 | rm oglematchers/identical_to.go 33 | rm oglematchers/matches_regexp.go 34 | rm oglematchers/new_matcher.go 35 | rm oglematchers/panics.go 36 | rm oglematchers/pointee.go 37 | rm go-render/render/*_test.go 38 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/go-render/.travis.yml: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2015 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | # {sudo: required, dist: trusty} is the magic incantation to pick the trusty 6 | # beta environment, which is the only environment we can get that has >4GB 7 | # memory. Currently the `go test -race` tests that we run will peak at just 8 | # over 4GB, which results in everything getting OOM-killed. 9 | sudo: required 10 | dist: trusty 11 | 12 | language: go 13 | 14 | go: 15 | - 1.4.2 16 | 17 | before_install: 18 | - go get github.com/maruel/pre-commit-go/cmd/pcg 19 | 20 | script: 21 | - pcg 22 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/go-render/LICENSE: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 The Chromium Authors. All rights reserved. 2 | // 3 | // Redistribution and use in source and binary forms, with or without 4 | // modification, are permitted provided that the following conditions are 5 | // met: 6 | // 7 | // * Redistributions of source code must retain the above copyright 8 | // notice, this list of conditions and the following disclaimer. 9 | // * Redistributions in binary form must reproduce the above 10 | // copyright notice, this list of conditions and the following disclaimer 11 | // in the documentation and/or other materials provided with the 12 | // distribution. 13 | // * Neither the name of Google Inc. nor the names of its 14 | // contributors may be used to endorse or promote products derived from 15 | // this software without specific prior written permission. 16 | // 17 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 18 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 19 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 20 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 21 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/go-render/WATCHLISTS: -------------------------------------------------------------------------------- 1 | # Copyright 2015 The Chromium Authors. All rights reserved. 2 | # Use of this source code is governed by a BSD-style license that can be 3 | # found in the LICENSE file. 4 | 5 | # Watchlist Rules 6 | # Refer: http://dev.chromium.org/developers/contributing-code/watchlists 7 | 8 | { 9 | 10 | 'WATCHLIST_DEFINITIONS': { 11 | 'all': { 12 | 'filepath': '.+', 13 | }, 14 | }, 15 | 16 | 'WATCHLISTS': { 17 | 'all': [ 18 | # Add yourself here to get explicitly spammed. 19 | 'maruel@chromium.org', 20 | 'tandrii+luci-go@chromium.org', 21 | 'todd@cloudera.com', 22 | 'andrew.wang@cloudera.com', 23 | ], 24 | }, 25 | 26 | } 27 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/go-render/pre-commit-go.yml: -------------------------------------------------------------------------------- 1 | # https://github.com/maruel/pre-commit-go configuration file to run checks 2 | # automatically on commit, on push and on continuous integration service after 3 | # a push or on merge of a pull request. 4 | # 5 | # See https://godoc.org/github.com/maruel/pre-commit-go/checks for more 6 | # information. 7 | 8 | min_version: 0.4.7 9 | modes: 10 | continuous-integration: 11 | checks: 12 | build: 13 | - build_all: false 14 | extra_args: [] 15 | coverage: 16 | - use_global_inference: false 17 | use_coveralls: true 18 | global: 19 | min_coverage: 50 20 | max_coverage: 100 21 | per_dir_default: 22 | min_coverage: 1 23 | max_coverage: 100 24 | per_dir: {} 25 | gofmt: 26 | - {} 27 | goimports: 28 | - {} 29 | test: 30 | - extra_args: 31 | - -v 32 | - -race 33 | max_duration: 600 34 | lint: 35 | checks: 36 | golint: 37 | - blacklist: [] 38 | govet: 39 | - blacklist: 40 | - ' composite literal uses unkeyed fields' 41 | max_duration: 15 42 | pre-commit: 43 | checks: 44 | build: 45 | - build_all: false 46 | extra_args: [] 47 | gofmt: 48 | - {} 49 | test: 50 | - extra_args: 51 | - -short 52 | max_duration: 35 53 | pre-push: 54 | checks: 55 | coverage: 56 | - use_global_inference: false 57 | use_coveralls: false 58 | global: 59 | min_coverage: 50 60 | max_coverage: 100 61 | per_dir_default: 62 | min_coverage: 1 63 | max_coverage: 100 64 | per_dir: {} 65 | goimports: 66 | - {} 67 | test: 68 | - extra_args: 69 | - -v 70 | - -race 71 | max_duration: 35 72 | 73 | ignore_patterns: 74 | - .* 75 | - _* 76 | - '*.pb.go' 77 | - '*_string.go' 78 | - '*-gen.go' 79 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/go-render/render/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["render.go"], 6 | visibility = ["//vendor/github.com/smartystreets/assertions:__subpackages__"], 7 | ) 8 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/.gitignore: -------------------------------------------------------------------------------- 1 | *.6 2 | 6.out 3 | _obj/ 4 | _test/ 5 | _testmain.go 6 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/.travis.yml: -------------------------------------------------------------------------------- 1 | # Cf. http://docs.travis-ci.com/user/getting-started/ 2 | # Cf. http://docs.travis-ci.com/user/languages/go/ 3 | 4 | language: go 5 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = [ 6 | "any_of.go", 7 | "contains.go", 8 | "deep_equals.go", 9 | "equals.go", 10 | "greater_or_equal.go", 11 | "greater_than.go", 12 | "less_or_equal.go", 13 | "less_than.go", 14 | "matcher.go", 15 | "not.go", 16 | "transform_description.go", 17 | ], 18 | visibility = ["//vendor/github.com/smartystreets/assertions:__subpackages__"], 19 | ) 20 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/README.md: -------------------------------------------------------------------------------- 1 | [![GoDoc](https://godoc.org/github.com/smartystreets/assertions/internal/oglematchers?status.svg)](https://godoc.org/github.com/smartystreets/assertions/internal/oglematchers) 2 | 3 | `oglematchers` is a package for the Go programming language containing a set of 4 | matchers, useful in a testing or mocking framework, inspired by and mostly 5 | compatible with [Google Test][googletest] for C++ and 6 | [Google JS Test][google-js-test]. The package is used by the 7 | [ogletest][ogletest] testing framework and [oglemock][oglemock] mocking 8 | framework, which may be more directly useful to you, but can be generically used 9 | elsewhere as well. 10 | 11 | A "matcher" is simply an object with a `Matches` method defining a set of golang 12 | values matched by the matcher, and a `Description` method describing that set. 13 | For example, here are some matchers: 14 | 15 | ```go 16 | // Numbers 17 | Equals(17.13) 18 | LessThan(19) 19 | 20 | // Strings 21 | Equals("taco") 22 | HasSubstr("burrito") 23 | MatchesRegex("t.*o") 24 | 25 | // Combining matchers 26 | AnyOf(LessThan(17), GreaterThan(19)) 27 | ``` 28 | 29 | There are lots more; see [here][reference] for a reference. You can also add 30 | your own simply by implementing the `oglematchers.Matcher` interface. 31 | 32 | 33 | Installation 34 | ------------ 35 | 36 | First, make sure you have installed Go 1.0.2 or newer. See 37 | [here][golang-install] for instructions. 38 | 39 | Use the following command to install `oglematchers` and keep it up to date: 40 | 41 | go get -u github.com/smartystreets/assertions/internal/oglematchers 42 | 43 | 44 | Documentation 45 | ------------- 46 | 47 | See [here][reference] for documentation. Alternatively, you can install the 48 | package and then use `godoc`: 49 | 50 | godoc github.com/smartystreets/assertions/internal/oglematchers 51 | 52 | 53 | [reference]: http://godoc.org/github.com/smartystreets/assertions/internal/oglematchers 54 | [golang-install]: http://golang.org/doc/install.html 55 | [googletest]: http://code.google.com/p/googletest/ 56 | [google-js-test]: http://code.google.com/p/google-js-test/ 57 | [ogletest]: http://github.com/smartystreets/assertions/internal/ogletest 58 | [oglemock]: http://github.com/smartystreets/assertions/internal/oglemock 59 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/contains.go: -------------------------------------------------------------------------------- 1 | // Copyright 2012 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | import ( 19 | "fmt" 20 | "reflect" 21 | ) 22 | 23 | // Return a matcher that matches arrays slices with at least one element that 24 | // matches the supplied argument. If the argument x is not itself a Matcher, 25 | // this is equivalent to Contains(Equals(x)). 26 | func Contains(x interface{}) Matcher { 27 | var result containsMatcher 28 | var ok bool 29 | 30 | if result.elementMatcher, ok = x.(Matcher); !ok { 31 | result.elementMatcher = DeepEquals(x) 32 | } 33 | 34 | return &result 35 | } 36 | 37 | type containsMatcher struct { 38 | elementMatcher Matcher 39 | } 40 | 41 | func (m *containsMatcher) Description() string { 42 | return fmt.Sprintf("contains: %s", m.elementMatcher.Description()) 43 | } 44 | 45 | func (m *containsMatcher) Matches(candidate interface{}) error { 46 | // The candidate must be a slice or an array. 47 | v := reflect.ValueOf(candidate) 48 | if v.Kind() != reflect.Slice && v.Kind() != reflect.Array { 49 | return NewFatalError("which is not a slice or array") 50 | } 51 | 52 | // Check each element. 53 | for i := 0; i < v.Len(); i++ { 54 | elem := v.Index(i) 55 | if matchErr := m.elementMatcher.Matches(elem.Interface()); matchErr == nil { 56 | return nil 57 | } 58 | } 59 | 60 | return fmt.Errorf("") 61 | } 62 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/greater_or_equal.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | import ( 19 | "fmt" 20 | "reflect" 21 | ) 22 | 23 | // GreaterOrEqual returns a matcher that matches integer, floating point, or 24 | // strings values v such that v >= x. Comparison is not defined between numeric 25 | // and string types, but is defined between all integer and floating point 26 | // types. 27 | // 28 | // x must itself be an integer, floating point, or string type; otherwise, 29 | // GreaterOrEqual will panic. 30 | func GreaterOrEqual(x interface{}) Matcher { 31 | desc := fmt.Sprintf("greater than or equal to %v", x) 32 | 33 | // Special case: make it clear that strings are strings. 34 | if reflect.TypeOf(x).Kind() == reflect.String { 35 | desc = fmt.Sprintf("greater than or equal to \"%s\"", x) 36 | } 37 | 38 | return transformDescription(Not(LessThan(x)), desc) 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/greater_than.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | import ( 19 | "fmt" 20 | "reflect" 21 | ) 22 | 23 | // GreaterThan returns a matcher that matches integer, floating point, or 24 | // strings values v such that v > x. Comparison is not defined between numeric 25 | // and string types, but is defined between all integer and floating point 26 | // types. 27 | // 28 | // x must itself be an integer, floating point, or string type; otherwise, 29 | // GreaterThan will panic. 30 | func GreaterThan(x interface{}) Matcher { 31 | desc := fmt.Sprintf("greater than %v", x) 32 | 33 | // Special case: make it clear that strings are strings. 34 | if reflect.TypeOf(x).Kind() == reflect.String { 35 | desc = fmt.Sprintf("greater than \"%s\"", x) 36 | } 37 | 38 | return transformDescription(Not(LessOrEqual(x)), desc) 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/less_or_equal.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | import ( 19 | "fmt" 20 | "reflect" 21 | ) 22 | 23 | // LessOrEqual returns a matcher that matches integer, floating point, or 24 | // strings values v such that v <= x. Comparison is not defined between numeric 25 | // and string types, but is defined between all integer and floating point 26 | // types. 27 | // 28 | // x must itself be an integer, floating point, or string type; otherwise, 29 | // LessOrEqual will panic. 30 | func LessOrEqual(x interface{}) Matcher { 31 | desc := fmt.Sprintf("less than or equal to %v", x) 32 | 33 | // Special case: make it clear that strings are strings. 34 | if reflect.TypeOf(x).Kind() == reflect.String { 35 | desc = fmt.Sprintf("less than or equal to \"%s\"", x) 36 | } 37 | 38 | // Put LessThan last so that its error messages will be used in the event of 39 | // failure. 40 | return transformDescription(AnyOf(Equals(x), LessThan(x)), desc) 41 | } 42 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/not.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | import ( 19 | "errors" 20 | "fmt" 21 | ) 22 | 23 | // Not returns a matcher that inverts the set of values matched by the wrapped 24 | // matcher. It does not transform the result for values for which the wrapped 25 | // matcher returns a fatal error. 26 | func Not(m Matcher) Matcher { 27 | return ¬Matcher{m} 28 | } 29 | 30 | type notMatcher struct { 31 | wrapped Matcher 32 | } 33 | 34 | func (m *notMatcher) Matches(c interface{}) (err error) { 35 | err = m.wrapped.Matches(c) 36 | 37 | // Did the wrapped matcher say yes? 38 | if err == nil { 39 | return errors.New("") 40 | } 41 | 42 | // Did the wrapped matcher return a fatal error? 43 | if _, isFatal := err.(*FatalError); isFatal { 44 | return err 45 | } 46 | 47 | // The wrapped matcher returned a non-fatal error. 48 | return nil 49 | } 50 | 51 | func (m *notMatcher) Description() string { 52 | return fmt.Sprintf("not(%s)", m.wrapped.Description()) 53 | } 54 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/internal/oglematchers/transform_description.go: -------------------------------------------------------------------------------- 1 | // Copyright 2011 Aaron Jacobs. All Rights Reserved. 2 | // Author: aaronjjacobs@gmail.com (Aaron Jacobs) 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | package oglematchers 17 | 18 | // transformDescription returns a matcher that is equivalent to the supplied 19 | // one, except that it has the supplied description instead of the one attached 20 | // to the existing matcher. 21 | func transformDescription(m Matcher, newDesc string) Matcher { 22 | return &transformDescriptionMatcher{newDesc, m} 23 | } 24 | 25 | type transformDescriptionMatcher struct { 26 | desc string 27 | wrappedMatcher Matcher 28 | } 29 | 30 | func (m *transformDescriptionMatcher) Description() string { 31 | return m.desc 32 | } 33 | 34 | func (m *transformDescriptionMatcher) Matches(c interface{}) error { 35 | return m.wrappedMatcher.Matches(c) 36 | } 37 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/serializer.go: -------------------------------------------------------------------------------- 1 | package assertions 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | 7 | "github.com/smartystreets/assertions/internal/go-render/render" 8 | ) 9 | 10 | type Serializer interface { 11 | serialize(expected, actual interface{}, message string) string 12 | serializeDetailed(expected, actual interface{}, message string) string 13 | } 14 | 15 | type failureSerializer struct{} 16 | 17 | func (self *failureSerializer) serializeDetailed(expected, actual interface{}, message string) string { 18 | view := FailureView{ 19 | Message: message, 20 | Expected: render.Render(expected), 21 | Actual: render.Render(actual), 22 | } 23 | serialized, _ := json.Marshal(view) 24 | return string(serialized) 25 | } 26 | 27 | func (self *failureSerializer) serialize(expected, actual interface{}, message string) string { 28 | view := FailureView{ 29 | Message: message, 30 | Expected: fmt.Sprintf("%+v", expected), 31 | Actual: fmt.Sprintf("%+v", actual), 32 | } 33 | serialized, _ := json.Marshal(view) 34 | return string(serialized) 35 | } 36 | 37 | func newSerializer() *failureSerializer { 38 | return &failureSerializer{} 39 | } 40 | 41 | /////////////////////////////////////////////////////////////////////////////// 42 | 43 | // This struct is also declared in github.com/smartystreets/goconvey/convey/reporting. 44 | // The json struct tags should be equal in both declarations. 45 | type FailureView struct { 46 | Message string `json:"Message"` 47 | Expected string `json:"Expected"` 48 | Actual string `json:"Actual"` 49 | } 50 | 51 | /////////////////////////////////////////////////////// 52 | 53 | // noopSerializer just gives back the original message. This is useful when we are using 54 | // the assertions from a context other than the GoConvey Web UI, that requires the JSON 55 | // structure provided by the failureSerializer. 56 | type noopSerializer struct{} 57 | 58 | func (self *noopSerializer) serialize(expected, actual interface{}, message string) string { 59 | return message 60 | } 61 | func (self *noopSerializer) serializeDetailed(expected, actual interface{}, message string) string { 62 | return message 63 | } 64 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/serializer_test.go: -------------------------------------------------------------------------------- 1 | package assertions 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "testing" 7 | ) 8 | 9 | func TestFailureSerializerCreatesSerializedVersionOfAssertionResult(t *testing.T) { 10 | thing1 := Thing1{"Hi"} 11 | thing2 := Thing2{"Bye"} 12 | message := "Super-hip failure message." 13 | serializer := newSerializer() 14 | 15 | actualResult := serializer.serialize(thing1, thing2, message) 16 | 17 | expectedResult, _ := json.Marshal(FailureView{ 18 | Message: message, 19 | Expected: fmt.Sprintf("%+v", thing1), 20 | Actual: fmt.Sprintf("%+v", thing2), 21 | }) 22 | 23 | if actualResult != string(expectedResult) { 24 | t.Errorf("\nExpected: %s\nActual: %s", string(expectedResult), actualResult) 25 | } 26 | 27 | actualResult = serializer.serializeDetailed(thing1, thing2, message) 28 | expectedResult, _ = json.Marshal(FailureView{ 29 | Message: message, 30 | Expected: fmt.Sprintf("%#v", thing1), 31 | Actual: fmt.Sprintf("%#v", thing2), 32 | }) 33 | if actualResult != string(expectedResult) { 34 | t.Errorf("\nExpected: %s\nActual: %s", string(expectedResult), actualResult) 35 | } 36 | } 37 | 38 | func TestNoopSerializerJustReturnsTheMessageInAllCases(t *testing.T) { 39 | thing1 := Thing1{"Hi"} 40 | thing2 := Thing2{"Bye"} 41 | expected := "Super-hip failure message." 42 | serializer := &noopSerializer{} 43 | actual := serializer.serialize(thing1, thing2, expected) 44 | if actual != expected { 45 | t.Errorf("\nExpected: %s\nActual: %s", string(expected), actual) 46 | } 47 | 48 | actual = serializer.serializeDetailed(thing1, thing2, expected) 49 | if actual != expected { 50 | t.Errorf("\nExpected: %s\nActual: %s", string(expected), actual) 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/should/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["should.go"], 6 | visibility = ["//visibility:public"], 7 | deps = ["//vendor/github.com/smartystreets/assertions:go_default_library"], 8 | ) 9 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/assertions/utilities_for_test.go: -------------------------------------------------------------------------------- 1 | package assertions 2 | 3 | import ( 4 | "fmt" 5 | "strings" 6 | "testing" 7 | 8 | "github.com/smartystreets/gunit" 9 | ) 10 | 11 | /**************************************************************************/ 12 | 13 | func TestAssertionsFixture(t *testing.T) { 14 | gunit.Run(new(AssertionsFixture), t) 15 | } 16 | 17 | type AssertionsFixture struct { 18 | *gunit.Fixture 19 | } 20 | 21 | func (this *AssertionsFixture) Setup() { 22 | serializer = this 23 | } 24 | 25 | func (self *AssertionsFixture) serialize(expected, actual interface{}, message string) string { 26 | return fmt.Sprintf("%v|%v|%s", expected, actual, message) 27 | } 28 | 29 | func (self *AssertionsFixture) serializeDetailed(expected, actual interface{}, message string) string { 30 | return fmt.Sprintf("%v|%v|%s", expected, actual, message) 31 | } 32 | 33 | func (this *AssertionsFixture) pass(result string) { 34 | this.Assert(result == success, result) 35 | } 36 | 37 | func (this *AssertionsFixture) fail(actual string, expected string) { 38 | actual = format(actual) 39 | expected = format(expected) 40 | 41 | if actual != expected { 42 | if actual == "" { 43 | actual = "(empty)" 44 | } 45 | this.Errorf("Expected: %s\nActual: %s\n", expected, actual) 46 | } 47 | } 48 | func format(message string) string { 49 | message = strings.Replace(message, "\n", " ", -1) 50 | for strings.Contains(message, " ") { 51 | message = strings.Replace(message, " ", " ", -1) 52 | } 53 | return message 54 | } 55 | 56 | /**************************************************************************/ 57 | 58 | type Thing1 struct { 59 | a string 60 | } 61 | type Thing2 struct { 62 | a string 63 | } 64 | 65 | type ThingInterface interface { 66 | Hi() 67 | } 68 | 69 | type ThingImplementation struct{} 70 | 71 | func (self *ThingImplementation) Hi() {} 72 | 73 | type IntAlias int 74 | type StringAlias string 75 | type StringSliceAlias []string 76 | type StringStringMapAlias map[string]string 77 | 78 | /**************************************************************************/ 79 | 80 | type ThingWithEqualMethod struct { 81 | a string 82 | } 83 | 84 | func (this ThingWithEqualMethod) Equal(that ThingWithEqualMethod) bool { 85 | return this.a == that.a 86 | } 87 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/.gitattributes: -------------------------------------------------------------------------------- 1 | web/client/resources/js/lib/* linguist-vendored 2 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | Thumbs.db 3 | examples/output.json 4 | web/client/reports/ 5 | /.idea -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/.travis.yml: -------------------------------------------------------------------------------- 1 | language: go 2 | 3 | go: 4 | - 1.2.x 5 | - 1.3.x 6 | - 1.4.x 7 | - 1.5.x 8 | - 1.6.x 9 | - 1.7.x 10 | - 1.8.x 11 | - tip 12 | 13 | install: 14 | - go get -t ./... 15 | 16 | script: go test -short -v ./... 17 | 18 | sudo: false 19 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = [ 6 | "dependencies.go", 7 | "goconvey.go", 8 | ], 9 | visibility = ["//visibility:private"], 10 | deps = [ 11 | "//vendor/github.com/jtolds/gls:go_default_library", 12 | "//vendor/github.com/smartystreets/assertions:go_default_library", 13 | "//vendor/github.com/smartystreets/goconvey/web/server/api:go_default_library", 14 | "//vendor/github.com/smartystreets/goconvey/web/server/contract:go_default_library", 15 | "//vendor/github.com/smartystreets/goconvey/web/server/executor:go_default_library", 16 | "//vendor/github.com/smartystreets/goconvey/web/server/messaging:go_default_library", 17 | "//vendor/github.com/smartystreets/goconvey/web/server/parser:go_default_library", 18 | "//vendor/github.com/smartystreets/goconvey/web/server/system:go_default_library", 19 | "//vendor/github.com/smartystreets/goconvey/web/server/watch:go_default_library", 20 | ], 21 | ) 22 | 23 | go_binary( 24 | name = "goconvey", 25 | library = ":go_default_library", 26 | visibility = ["//visibility:public"], 27 | ) 28 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 SmartyStreets, LLC 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19 | SOFTWARE. 20 | 21 | NOTE: Various optional and subordinate components carry their own licensing 22 | requirements and restrictions. Use of those components is subject to the terms 23 | and conditions outlined the respective license of each component. 24 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = [ 6 | "assertions.go", 7 | "context.go", 8 | "discovery.go", 9 | "doc.go", 10 | "init.go", 11 | "nilReporter.go", 12 | ], 13 | visibility = ["//visibility:public"], 14 | deps = [ 15 | "//vendor/github.com/jtolds/gls:go_default_library", 16 | "//vendor/github.com/smartystreets/assertions:go_default_library", 17 | "//vendor/github.com/smartystreets/goconvey/convey/reporting:go_default_library", 18 | ], 19 | ) 20 | 21 | go_test( 22 | name = "go_default_test", 23 | srcs = [ 24 | "focused_execution_test.go", 25 | "isolated_execution_test.go", 26 | "reporting_hooks_test.go", 27 | "story_conventions_test.go", 28 | ], 29 | library = ":go_default_library", 30 | deps = ["//vendor/github.com/smartystreets/goconvey/convey/reporting:go_default_library"], 31 | ) 32 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/convey.goconvey: -------------------------------------------------------------------------------- 1 | #ignore 2 | -timeout=1s 3 | #-covermode=count 4 | #-coverpkg=github.com/smartystreets/goconvey/convey,github.com/smartystreets/goconvey/convey/gotest,github.com/smartystreets/goconvey/convey/reporting -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/focused_execution_test.go: -------------------------------------------------------------------------------- 1 | package convey 2 | 3 | import "testing" 4 | 5 | func TestFocusOnlyAtTopLevel(t *testing.T) { 6 | output := prepare() 7 | 8 | FocusConvey("hi", t, func() { 9 | output += "done" 10 | }) 11 | 12 | expectEqual(t, "done", output) 13 | } 14 | 15 | func TestFocus(t *testing.T) { 16 | output := prepare() 17 | 18 | FocusConvey("hi", t, func() { 19 | output += "1" 20 | 21 | Convey("bye", func() { 22 | output += "2" 23 | }) 24 | }) 25 | 26 | expectEqual(t, "1", output) 27 | } 28 | 29 | func TestNestedFocus(t *testing.T) { 30 | output := prepare() 31 | 32 | FocusConvey("hi", t, func() { 33 | output += "1" 34 | 35 | Convey("This shouldn't run", func() { 36 | output += "boink!" 37 | }) 38 | 39 | FocusConvey("This should run", func() { 40 | output += "2" 41 | 42 | FocusConvey("The should run too", func() { 43 | output += "3" 44 | 45 | }) 46 | 47 | Convey("The should NOT run", func() { 48 | output += "blah blah blah!" 49 | }) 50 | }) 51 | }) 52 | 53 | expectEqual(t, "123", output) 54 | } 55 | 56 | func TestForgotTopLevelFocus(t *testing.T) { 57 | output := prepare() 58 | 59 | Convey("1", t, func() { 60 | output += "1" 61 | 62 | FocusConvey("This will be run because the top-level lacks Focus", func() { 63 | output += "2" 64 | }) 65 | 66 | Convey("3", func() { 67 | output += "3" 68 | }) 69 | }) 70 | 71 | expectEqual(t, "1213", output) 72 | } 73 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/gotest/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["utils.go"], 6 | visibility = ["//visibility:public"], 7 | ) 8 | 9 | go_test( 10 | name = "go_default_test", 11 | srcs = ["doc_test.go"], 12 | library = ":go_default_library", 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/gotest/doc_test.go: -------------------------------------------------------------------------------- 1 | package gotest 2 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/gotest/utils.go: -------------------------------------------------------------------------------- 1 | // Package gotest contains internal functionality. Although this package 2 | // contains one or more exported names it is not intended for public 3 | // consumption. See the examples package for how to use this project. 4 | package gotest 5 | 6 | import ( 7 | "runtime" 8 | "strings" 9 | ) 10 | 11 | func ResolveExternalCaller() (file string, line int, name string) { 12 | var caller_id uintptr 13 | callers := runtime.Callers(0, callStack) 14 | 15 | for x := 0; x < callers; x++ { 16 | caller_id, file, line, _ = runtime.Caller(x) 17 | if strings.HasSuffix(file, "_test.go") || strings.HasSuffix(file, "_tests.go") { 18 | name = runtime.FuncForPC(caller_id).Name() 19 | return 20 | } 21 | } 22 | file, line, name = "", -1, "" 23 | return // panic? 24 | } 25 | 26 | const maxStackDepth = 100 // This had better be enough... 27 | 28 | var callStack []uintptr = make([]uintptr, maxStackDepth, maxStackDepth) 29 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/init.go: -------------------------------------------------------------------------------- 1 | package convey 2 | 3 | import ( 4 | "flag" 5 | "os" 6 | 7 | "github.com/jtolds/gls" 8 | "github.com/smartystreets/assertions" 9 | "github.com/smartystreets/goconvey/convey/reporting" 10 | ) 11 | 12 | func init() { 13 | assertions.GoConveyMode(true) 14 | 15 | declareFlags() 16 | 17 | ctxMgr = gls.NewContextManager() 18 | } 19 | 20 | func declareFlags() { 21 | flag.BoolVar(&json, "convey-json", false, "When true, emits results in JSON blocks. Default: 'false'") 22 | flag.BoolVar(&silent, "convey-silent", false, "When true, all output from GoConvey is suppressed.") 23 | flag.BoolVar(&story, "convey-story", false, "When true, emits story output, otherwise emits dot output. When not provided, this flag mirros the value of the '-test.v' flag") 24 | 25 | if noStoryFlagProvided() { 26 | story = verboseEnabled 27 | } 28 | 29 | // FYI: flag.Parse() is called from the testing package. 30 | } 31 | 32 | func noStoryFlagProvided() bool { 33 | return !story && !storyDisabled 34 | } 35 | 36 | func buildReporter() reporting.Reporter { 37 | selectReporter := os.Getenv("GOCONVEY_REPORTER") 38 | 39 | switch { 40 | case testReporter != nil: 41 | return testReporter 42 | case json || selectReporter == "json": 43 | return reporting.BuildJsonReporter() 44 | case silent || selectReporter == "silent": 45 | return reporting.BuildSilentReporter() 46 | case selectReporter == "dot": 47 | // Story is turned on when verbose is set, so we need to check for dot reporter first. 48 | return reporting.BuildDotReporter() 49 | case story || selectReporter == "story": 50 | return reporting.BuildStoryReporter() 51 | default: 52 | return reporting.BuildDotReporter() 53 | } 54 | } 55 | 56 | var ( 57 | ctxMgr *gls.ContextManager 58 | 59 | // only set by internal tests 60 | testReporter reporting.Reporter 61 | ) 62 | 63 | var ( 64 | json bool 65 | silent bool 66 | story bool 67 | 68 | verboseEnabled = flagFound("-test.v=true") 69 | storyDisabled = flagFound("-story=false") 70 | ) 71 | 72 | // flagFound parses the command line args manually for flags defined in other 73 | // packages. Like the '-v' flag from the "testing" package, for instance. 74 | func flagFound(flagValue string) bool { 75 | for _, arg := range os.Args { 76 | if arg == flagValue { 77 | return true 78 | } 79 | } 80 | return false 81 | } 82 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/nilReporter.go: -------------------------------------------------------------------------------- 1 | package convey 2 | 3 | import ( 4 | "github.com/smartystreets/goconvey/convey/reporting" 5 | ) 6 | 7 | type nilReporter struct{} 8 | 9 | func (self *nilReporter) BeginStory(story *reporting.StoryReport) {} 10 | func (self *nilReporter) Enter(scope *reporting.ScopeReport) {} 11 | func (self *nilReporter) Report(report *reporting.AssertionResult) {} 12 | func (self *nilReporter) Exit() {} 13 | func (self *nilReporter) EndStory() {} 14 | func (self *nilReporter) Write(p []byte) (int, error) { return len(p), nil } 15 | func newNilReporter() *nilReporter { return &nilReporter{} } 16 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = [ 6 | "console.go", 7 | "doc.go", 8 | "dot.go", 9 | "gotest.go", 10 | "init.go", 11 | "json.go", 12 | "printer.go", 13 | "problems.go", 14 | "reporter.go", 15 | "reports.go", 16 | "statistics.go", 17 | "story.go", 18 | ], 19 | visibility = ["//visibility:public"], 20 | deps = ["//vendor/github.com/smartystreets/goconvey/convey/gotest:go_default_library"], 21 | ) 22 | 23 | go_test( 24 | name = "go_default_test", 25 | srcs = [ 26 | "dot_test.go", 27 | "gotest_test.go", 28 | "printer_test.go", 29 | "problems_test.go", 30 | "reporter_test.go", 31 | ], 32 | library = ":go_default_library", 33 | ) 34 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/console.go: -------------------------------------------------------------------------------- 1 | package reporting 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | ) 7 | 8 | type console struct{} 9 | 10 | func (self *console) Write(p []byte) (n int, err error) { 11 | return fmt.Print(string(p)) 12 | } 13 | 14 | func NewConsole() io.Writer { 15 | return new(console) 16 | } 17 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/doc.go: -------------------------------------------------------------------------------- 1 | // Package reporting contains internal functionality related 2 | // to console reporting and output. Although this package has 3 | // exported names is not intended for public consumption. See the 4 | // examples package for how to use this project. 5 | package reporting 6 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/dot.go: -------------------------------------------------------------------------------- 1 | package reporting 2 | 3 | import "fmt" 4 | 5 | type dot struct{ out *Printer } 6 | 7 | func (self *dot) BeginStory(story *StoryReport) {} 8 | 9 | func (self *dot) Enter(scope *ScopeReport) {} 10 | 11 | func (self *dot) Report(report *AssertionResult) { 12 | if report.Error != nil { 13 | fmt.Print(redColor) 14 | self.out.Insert(dotError) 15 | } else if report.Failure != "" { 16 | fmt.Print(yellowColor) 17 | self.out.Insert(dotFailure) 18 | } else if report.Skipped { 19 | fmt.Print(yellowColor) 20 | self.out.Insert(dotSkip) 21 | } else { 22 | fmt.Print(greenColor) 23 | self.out.Insert(dotSuccess) 24 | } 25 | fmt.Print(resetColor) 26 | } 27 | 28 | func (self *dot) Exit() {} 29 | 30 | func (self *dot) EndStory() {} 31 | 32 | func (self *dot) Write(content []byte) (written int, err error) { 33 | return len(content), nil // no-op 34 | } 35 | 36 | func NewDotReporter(out *Printer) *dot { 37 | self := new(dot) 38 | self.out = out 39 | return self 40 | } 41 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/dot_test.go: -------------------------------------------------------------------------------- 1 | package reporting 2 | 3 | import ( 4 | "errors" 5 | "testing" 6 | ) 7 | 8 | func TestDotReporterAssertionPrinting(t *testing.T) { 9 | monochrome() 10 | file := newMemoryFile() 11 | printer := NewPrinter(file) 12 | reporter := NewDotReporter(printer) 13 | 14 | reporter.Report(NewSuccessReport()) 15 | reporter.Report(NewFailureReport("failed")) 16 | reporter.Report(NewErrorReport(errors.New("error"))) 17 | reporter.Report(NewSkipReport()) 18 | 19 | expected := dotSuccess + dotFailure + dotError + dotSkip 20 | 21 | if file.buffer != expected { 22 | t.Errorf("\nExpected: '%s'\nActual: '%s'", expected, file.buffer) 23 | } 24 | } 25 | 26 | func TestDotReporterOnlyReportsAssertions(t *testing.T) { 27 | monochrome() 28 | file := newMemoryFile() 29 | printer := NewPrinter(file) 30 | reporter := NewDotReporter(printer) 31 | 32 | reporter.BeginStory(nil) 33 | reporter.Enter(nil) 34 | reporter.Exit() 35 | reporter.EndStory() 36 | 37 | if file.buffer != "" { 38 | t.Errorf("\nExpected: '(blank)'\nActual: '%s'", file.buffer) 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/gotest.go: -------------------------------------------------------------------------------- 1 | package reporting 2 | 3 | type gotestReporter struct{ test T } 4 | 5 | func (self *gotestReporter) BeginStory(story *StoryReport) { 6 | self.test = story.Test 7 | } 8 | 9 | func (self *gotestReporter) Enter(scope *ScopeReport) {} 10 | 11 | func (self *gotestReporter) Report(r *AssertionResult) { 12 | if !passed(r) { 13 | self.test.Fail() 14 | } 15 | } 16 | 17 | func (self *gotestReporter) Exit() {} 18 | 19 | func (self *gotestReporter) EndStory() { 20 | self.test = nil 21 | } 22 | 23 | func (self *gotestReporter) Write(content []byte) (written int, err error) { 24 | return len(content), nil // no-op 25 | } 26 | 27 | func NewGoTestReporter() *gotestReporter { 28 | return new(gotestReporter) 29 | } 30 | 31 | func passed(r *AssertionResult) bool { 32 | return r.Error == nil && r.Failure == "" 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/gotest_test.go: -------------------------------------------------------------------------------- 1 | package reporting 2 | 3 | import "testing" 4 | 5 | func TestReporterReceivesSuccessfulReport(t *testing.T) { 6 | reporter := NewGoTestReporter() 7 | test := new(fakeTest) 8 | reporter.BeginStory(NewStoryReport(test)) 9 | reporter.Report(NewSuccessReport()) 10 | 11 | if test.failed { 12 | t.Errorf("Should have have marked test as failed--the report reflected success.") 13 | } 14 | } 15 | 16 | func TestReporterReceivesFailureReport(t *testing.T) { 17 | reporter := NewGoTestReporter() 18 | test := new(fakeTest) 19 | reporter.BeginStory(NewStoryReport(test)) 20 | reporter.Report(NewFailureReport("This is a failure.")) 21 | 22 | if !test.failed { 23 | t.Errorf("Test should have been marked as failed (but it wasn't).") 24 | } 25 | } 26 | 27 | func TestReporterReceivesErrorReport(t *testing.T) { 28 | reporter := NewGoTestReporter() 29 | test := new(fakeTest) 30 | reporter.BeginStory(NewStoryReport(test)) 31 | reporter.Report(NewErrorReport("This is an error.")) 32 | 33 | if !test.failed { 34 | t.Errorf("Test should have been marked as failed (but it wasn't).") 35 | } 36 | } 37 | 38 | func TestReporterIsResetAtTheEndOfTheStory(t *testing.T) { 39 | defer catch(t) 40 | reporter := NewGoTestReporter() 41 | test := new(fakeTest) 42 | reporter.BeginStory(NewStoryReport(test)) 43 | reporter.EndStory() 44 | 45 | reporter.Report(NewSuccessReport()) 46 | } 47 | 48 | func TestReporterNoopMethods(t *testing.T) { 49 | reporter := NewGoTestReporter() 50 | reporter.Enter(NewScopeReport("title")) 51 | reporter.Exit() 52 | } 53 | 54 | func catch(t *testing.T) { 55 | if r := recover(); r != nil { 56 | t.Log("Getting to this point means we've passed (because we caught a panic appropriately).") 57 | } 58 | } 59 | 60 | type fakeTest struct { 61 | failed bool 62 | } 63 | 64 | func (self *fakeTest) Fail() { 65 | self.failed = true 66 | } 67 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/printer.go: -------------------------------------------------------------------------------- 1 | package reporting 2 | 3 | import ( 4 | "fmt" 5 | "io" 6 | "strings" 7 | ) 8 | 9 | type Printer struct { 10 | out io.Writer 11 | prefix string 12 | } 13 | 14 | func (self *Printer) Println(message string, values ...interface{}) { 15 | formatted := self.format(message, values...) + newline 16 | self.out.Write([]byte(formatted)) 17 | } 18 | 19 | func (self *Printer) Print(message string, values ...interface{}) { 20 | formatted := self.format(message, values...) 21 | self.out.Write([]byte(formatted)) 22 | } 23 | 24 | func (self *Printer) Insert(text string) { 25 | self.out.Write([]byte(text)) 26 | } 27 | 28 | func (self *Printer) format(message string, values ...interface{}) string { 29 | var formatted string 30 | if len(values) == 0 { 31 | formatted = self.prefix + message 32 | } else { 33 | formatted = self.prefix + fmt.Sprintf(message, values...) 34 | } 35 | indented := strings.Replace(formatted, newline, newline+self.prefix, -1) 36 | return strings.TrimRight(indented, space) 37 | } 38 | 39 | func (self *Printer) Indent() { 40 | self.prefix += pad 41 | } 42 | 43 | func (self *Printer) Dedent() { 44 | if len(self.prefix) >= padLength { 45 | self.prefix = self.prefix[:len(self.prefix)-padLength] 46 | } 47 | } 48 | 49 | func NewPrinter(out io.Writer) *Printer { 50 | self := new(Printer) 51 | self.out = out 52 | return self 53 | } 54 | 55 | const space = " " 56 | const pad = space + space 57 | const padLength = len(pad) 58 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/problems.go: -------------------------------------------------------------------------------- 1 | package reporting 2 | 3 | import "fmt" 4 | 5 | type problem struct { 6 | silent bool 7 | out *Printer 8 | errors []*AssertionResult 9 | failures []*AssertionResult 10 | } 11 | 12 | func (self *problem) BeginStory(story *StoryReport) {} 13 | 14 | func (self *problem) Enter(scope *ScopeReport) {} 15 | 16 | func (self *problem) Report(report *AssertionResult) { 17 | if report.Error != nil { 18 | self.errors = append(self.errors, report) 19 | } else if report.Failure != "" { 20 | self.failures = append(self.failures, report) 21 | } 22 | } 23 | 24 | func (self *problem) Exit() {} 25 | 26 | func (self *problem) EndStory() { 27 | self.show(self.showErrors, redColor) 28 | self.show(self.showFailures, yellowColor) 29 | self.prepareForNextStory() 30 | } 31 | func (self *problem) show(display func(), color string) { 32 | if !self.silent { 33 | fmt.Print(color) 34 | } 35 | display() 36 | if !self.silent { 37 | fmt.Print(resetColor) 38 | } 39 | self.out.Dedent() 40 | } 41 | func (self *problem) showErrors() { 42 | for i, e := range self.errors { 43 | if i == 0 { 44 | self.out.Println("\nErrors:\n") 45 | self.out.Indent() 46 | } 47 | self.out.Println(errorTemplate, e.File, e.Line, e.Error, e.StackTrace) 48 | } 49 | } 50 | func (self *problem) showFailures() { 51 | for i, f := range self.failures { 52 | if i == 0 { 53 | self.out.Println("\nFailures:\n") 54 | self.out.Indent() 55 | } 56 | self.out.Println(failureTemplate, f.File, f.Line, f.Failure) 57 | } 58 | } 59 | 60 | func (self *problem) Write(content []byte) (written int, err error) { 61 | return len(content), nil // no-op 62 | } 63 | 64 | func NewProblemReporter(out *Printer) *problem { 65 | self := new(problem) 66 | self.out = out 67 | self.prepareForNextStory() 68 | return self 69 | } 70 | 71 | func NewSilentProblemReporter(out *Printer) *problem { 72 | self := NewProblemReporter(out) 73 | self.silent = true 74 | return self 75 | } 76 | 77 | func (self *problem) prepareForNextStory() { 78 | self.errors = []*AssertionResult{} 79 | self.failures = []*AssertionResult{} 80 | } 81 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/problems_test.go: -------------------------------------------------------------------------------- 1 | package reporting 2 | 3 | import ( 4 | "strings" 5 | "testing" 6 | ) 7 | 8 | func TestNoopProblemReporterActions(t *testing.T) { 9 | file, reporter := setup() 10 | reporter.BeginStory(nil) 11 | reporter.Enter(nil) 12 | reporter.Exit() 13 | expected := "" 14 | actual := file.String() 15 | if expected != actual { 16 | t.Errorf("Expected: '(blank)'\nActual: '%s'", actual) 17 | } 18 | } 19 | 20 | func TestReporterPrintsFailuresAndErrorsAtTheEndOfTheStory(t *testing.T) { 21 | file, reporter := setup() 22 | reporter.Report(NewFailureReport("failed")) 23 | reporter.Report(NewErrorReport("error")) 24 | reporter.Report(NewSuccessReport()) 25 | reporter.EndStory() 26 | 27 | result := file.String() 28 | if !strings.Contains(result, "Errors:\n") { 29 | t.Errorf("Expected errors, found none.") 30 | } 31 | if !strings.Contains(result, "Failures:\n") { 32 | t.Errorf("Expected failures, found none.") 33 | } 34 | 35 | // Each stack trace looks like: `* /path/to/file.go`, so look for `* `. 36 | // With go 1.4+ there is a line in some stack traces that looks like this: 37 | // `testing.(*M).Run(0x2082d60a0, 0x25b7c0)` 38 | // So we can't just look for "*" anymore. 39 | problemCount := strings.Count(result, "* ") 40 | if problemCount != 2 { 41 | t.Errorf("Expected one failure and one error (total of 2 '*' characters). Got %d", problemCount) 42 | } 43 | } 44 | 45 | func setup() (file *memoryFile, reporter *problem) { 46 | monochrome() 47 | file = newMemoryFile() 48 | printer := NewPrinter(file) 49 | reporter = NewProblemReporter(printer) 50 | return 51 | } 52 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/reporter.go: -------------------------------------------------------------------------------- 1 | package reporting 2 | 3 | import "io" 4 | 5 | type Reporter interface { 6 | BeginStory(story *StoryReport) 7 | Enter(scope *ScopeReport) 8 | Report(r *AssertionResult) 9 | Exit() 10 | EndStory() 11 | io.Writer 12 | } 13 | 14 | type reporters struct{ collection []Reporter } 15 | 16 | func (self *reporters) BeginStory(s *StoryReport) { self.foreach(func(r Reporter) { r.BeginStory(s) }) } 17 | func (self *reporters) Enter(s *ScopeReport) { self.foreach(func(r Reporter) { r.Enter(s) }) } 18 | func (self *reporters) Report(a *AssertionResult) { self.foreach(func(r Reporter) { r.Report(a) }) } 19 | func (self *reporters) Exit() { self.foreach(func(r Reporter) { r.Exit() }) } 20 | func (self *reporters) EndStory() { self.foreach(func(r Reporter) { r.EndStory() }) } 21 | 22 | func (self *reporters) Write(contents []byte) (written int, err error) { 23 | self.foreach(func(r Reporter) { 24 | written, err = r.Write(contents) 25 | }) 26 | return written, err 27 | } 28 | 29 | func (self *reporters) foreach(action func(Reporter)) { 30 | for _, r := range self.collection { 31 | action(r) 32 | } 33 | } 34 | 35 | func NewReporters(collection ...Reporter) *reporters { 36 | self := new(reporters) 37 | self.collection = collection 38 | return self 39 | } 40 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/reporter_test.go: -------------------------------------------------------------------------------- 1 | package reporting 2 | 3 | import ( 4 | "runtime" 5 | "testing" 6 | ) 7 | 8 | func TestEachNestedReporterReceivesTheCallFromTheContainingReporter(t *testing.T) { 9 | fake1 := newFakeReporter() 10 | fake2 := newFakeReporter() 11 | reporter := NewReporters(fake1, fake2) 12 | 13 | reporter.BeginStory(nil) 14 | assertTrue(t, fake1.begun) 15 | assertTrue(t, fake2.begun) 16 | 17 | reporter.Enter(NewScopeReport("scope")) 18 | assertTrue(t, fake1.entered) 19 | assertTrue(t, fake2.entered) 20 | 21 | reporter.Report(NewSuccessReport()) 22 | assertTrue(t, fake1.reported) 23 | assertTrue(t, fake2.reported) 24 | 25 | reporter.Exit() 26 | assertTrue(t, fake1.exited) 27 | assertTrue(t, fake2.exited) 28 | 29 | reporter.EndStory() 30 | assertTrue(t, fake1.ended) 31 | assertTrue(t, fake2.ended) 32 | 33 | content := []byte("hi") 34 | written, err := reporter.Write(content) 35 | assertTrue(t, fake1.written) 36 | assertTrue(t, fake2.written) 37 | assertEqual(t, written, len(content)) 38 | assertNil(t, err) 39 | 40 | } 41 | 42 | func assertTrue(t *testing.T, value bool) { 43 | if !value { 44 | _, _, line, _ := runtime.Caller(1) 45 | t.Errorf("Value should have been true (but was false). See line %d", line) 46 | } 47 | } 48 | 49 | func assertEqual(t *testing.T, expected, actual int) { 50 | if actual != expected { 51 | _, _, line, _ := runtime.Caller(1) 52 | t.Errorf("Value should have been %d (but was %d). See line %d", expected, actual, line) 53 | } 54 | } 55 | 56 | func assertNil(t *testing.T, err error) { 57 | if err != nil { 58 | _, _, line, _ := runtime.Caller(1) 59 | t.Errorf("Error should have been (but wasn't). See line %d", err, line) 60 | } 61 | } 62 | 63 | type fakeReporter struct { 64 | begun bool 65 | entered bool 66 | reported bool 67 | exited bool 68 | ended bool 69 | written bool 70 | } 71 | 72 | func newFakeReporter() *fakeReporter { 73 | return &fakeReporter{} 74 | } 75 | 76 | func (self *fakeReporter) BeginStory(story *StoryReport) { 77 | self.begun = true 78 | } 79 | func (self *fakeReporter) Enter(scope *ScopeReport) { 80 | self.entered = true 81 | } 82 | func (self *fakeReporter) Report(report *AssertionResult) { 83 | self.reported = true 84 | } 85 | func (self *fakeReporter) Exit() { 86 | self.exited = true 87 | } 88 | func (self *fakeReporter) EndStory() { 89 | self.ended = true 90 | } 91 | func (self *fakeReporter) Write(content []byte) (int, error) { 92 | self.written = true 93 | return len(content), nil 94 | } 95 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/reporting.goconvey: -------------------------------------------------------------------------------- 1 | #ignore 2 | -timeout=1s 3 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/convey/reporting/story.go: -------------------------------------------------------------------------------- 1 | // TODO: in order for this reporter to be completely honest 2 | // we need to retrofit to be more like the json reporter such that: 3 | // 1. it maintains ScopeResult collections, which count assertions 4 | // 2. it reports only after EndStory(), so that all tick marks 5 | // are placed near the appropriate title. 6 | // 3. Under unit test 7 | 8 | package reporting 9 | 10 | import ( 11 | "fmt" 12 | "strings" 13 | ) 14 | 15 | type story struct { 16 | out *Printer 17 | titlesById map[string]string 18 | currentKey []string 19 | } 20 | 21 | func (self *story) BeginStory(story *StoryReport) {} 22 | 23 | func (self *story) Enter(scope *ScopeReport) { 24 | self.out.Indent() 25 | 26 | self.currentKey = append(self.currentKey, scope.Title) 27 | ID := strings.Join(self.currentKey, "|") 28 | 29 | if _, found := self.titlesById[ID]; !found { 30 | self.out.Println("") 31 | self.out.Print(scope.Title) 32 | self.out.Insert(" ") 33 | self.titlesById[ID] = scope.Title 34 | } 35 | } 36 | 37 | func (self *story) Report(report *AssertionResult) { 38 | if report.Error != nil { 39 | fmt.Print(redColor) 40 | self.out.Insert(error_) 41 | } else if report.Failure != "" { 42 | fmt.Print(yellowColor) 43 | self.out.Insert(failure) 44 | } else if report.Skipped { 45 | fmt.Print(yellowColor) 46 | self.out.Insert(skip) 47 | } else { 48 | fmt.Print(greenColor) 49 | self.out.Insert(success) 50 | } 51 | fmt.Print(resetColor) 52 | } 53 | 54 | func (self *story) Exit() { 55 | self.out.Dedent() 56 | self.currentKey = self.currentKey[:len(self.currentKey)-1] 57 | } 58 | 59 | func (self *story) EndStory() { 60 | self.titlesById = make(map[string]string) 61 | self.out.Println("\n") 62 | } 63 | 64 | func (self *story) Write(content []byte) (written int, err error) { 65 | return len(content), nil // no-op 66 | } 67 | 68 | func NewStoryReporter(out *Printer) *story { 69 | self := new(story) 70 | self.out = out 71 | self.titlesById = make(map[string]string) 72 | return self 73 | } 74 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/dependencies.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import _ "github.com/jtolds/gls" 4 | import _ "github.com/smartystreets/assertions" 5 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/examples/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = [ 6 | "bowling_game.go", 7 | "doc.go", 8 | ], 9 | visibility = ["//visibility:public"], 10 | ) 11 | 12 | go_test( 13 | name = "go_default_test", 14 | srcs = [ 15 | "assertion_examples_test.go", 16 | "bowling_game_test.go", 17 | "simple_example_test.go", 18 | ], 19 | library = ":go_default_library", 20 | deps = ["//vendor/github.com/smartystreets/goconvey/convey:go_default_library"], 21 | ) 22 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/examples/bowling_game.go: -------------------------------------------------------------------------------- 1 | package examples 2 | 3 | // Game contains the state of a bowling game. 4 | type Game struct { 5 | rolls []int 6 | current int 7 | } 8 | 9 | // NewGame allocates and starts a new game of bowling. 10 | func NewGame() *Game { 11 | game := new(Game) 12 | game.rolls = make([]int, maxThrowsPerGame) 13 | return game 14 | } 15 | 16 | // Roll rolls the ball and knocks down the number of pins specified by pins. 17 | func (self *Game) Roll(pins int) { 18 | self.rolls[self.current] = pins 19 | self.current++ 20 | } 21 | 22 | // Score calculates and returns the player's current score. 23 | func (self *Game) Score() (sum int) { 24 | for throw, frame := 0, 0; frame < framesPerGame; frame++ { 25 | if self.isStrike(throw) { 26 | sum += self.strikeBonusFor(throw) 27 | throw += 1 28 | } else if self.isSpare(throw) { 29 | sum += self.spareBonusFor(throw) 30 | throw += 2 31 | } else { 32 | sum += self.framePointsAt(throw) 33 | throw += 2 34 | } 35 | } 36 | return sum 37 | } 38 | 39 | // isStrike determines if a given throw is a strike or not. A strike is knocking 40 | // down all pins in one throw. 41 | func (self *Game) isStrike(throw int) bool { 42 | return self.rolls[throw] == allPins 43 | } 44 | 45 | // strikeBonusFor calculates and returns the strike bonus for a throw. 46 | func (self *Game) strikeBonusFor(throw int) int { 47 | return allPins + self.framePointsAt(throw+1) 48 | } 49 | 50 | // isSpare determines if a given frame is a spare or not. A spare is knocking 51 | // down all pins in one frame with two throws. 52 | func (self *Game) isSpare(throw int) bool { 53 | return self.framePointsAt(throw) == allPins 54 | } 55 | 56 | // spareBonusFor calculates and returns the spare bonus for a throw. 57 | func (self *Game) spareBonusFor(throw int) int { 58 | return allPins + self.rolls[throw+2] 59 | } 60 | 61 | // framePointsAt computes and returns the score in a frame specified by throw. 62 | func (self *Game) framePointsAt(throw int) int { 63 | return self.rolls[throw] + self.rolls[throw+1] 64 | } 65 | 66 | const ( 67 | // allPins is the number of pins allocated per fresh throw. 68 | allPins = 10 69 | 70 | // framesPerGame is the number of frames per bowling game. 71 | framesPerGame = 10 72 | 73 | // maxThrowsPerGame is the maximum number of throws possible in a single game. 74 | maxThrowsPerGame = 21 75 | ) 76 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/examples/bowling_game_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Reference: http://butunclebob.com/ArticleS.UncleBob.TheBowlingGameKata 4 | 5 | See the very first link (which happens to be the very first word of 6 | the first paragraph) on the page for a tutorial. 7 | 8 | */ 9 | 10 | package examples 11 | 12 | import ( 13 | "testing" 14 | 15 | . "github.com/smartystreets/goconvey/convey" 16 | ) 17 | 18 | func TestBowlingGameScoring(t *testing.T) { 19 | Convey("Given a fresh score card", t, func() { 20 | game := NewGame() 21 | 22 | Convey("When all gutter balls are thrown", func() { 23 | game.rollMany(20, 0) 24 | 25 | Convey("The score should be zero", func() { 26 | So(game.Score(), ShouldEqual, 0) 27 | }) 28 | }) 29 | 30 | Convey("When all throws knock down only one pin", func() { 31 | game.rollMany(20, 1) 32 | 33 | Convey("The score should be 20", func() { 34 | So(game.Score(), ShouldEqual, 20) 35 | }) 36 | }) 37 | 38 | Convey("When a spare is thrown", func() { 39 | game.rollSpare() 40 | game.Roll(3) 41 | game.rollMany(17, 0) 42 | 43 | Convey("The score should include a spare bonus.", func() { 44 | So(game.Score(), ShouldEqual, 16) 45 | }) 46 | }) 47 | 48 | Convey("When a strike is thrown", func() { 49 | game.rollStrike() 50 | game.Roll(3) 51 | game.Roll(4) 52 | game.rollMany(16, 0) 53 | 54 | Convey("The score should include a strike bonus.", func() { 55 | So(game.Score(), ShouldEqual, 24) 56 | }) 57 | }) 58 | 59 | Convey("When all strikes are thrown", func() { 60 | game.rollMany(21, 10) 61 | 62 | Convey("The score should be 300.", func() { 63 | So(game.Score(), ShouldEqual, 300) 64 | }) 65 | }) 66 | }) 67 | } 68 | 69 | func (self *Game) rollMany(times, pins int) { 70 | for x := 0; x < times; x++ { 71 | self.Roll(pins) 72 | } 73 | } 74 | func (self *Game) rollSpare() { 75 | self.Roll(5) 76 | self.Roll(5) 77 | } 78 | func (self *Game) rollStrike() { 79 | self.Roll(10) 80 | } 81 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/examples/doc.go: -------------------------------------------------------------------------------- 1 | // Package examples contains, well, examples of how to use goconvey to 2 | // specify behavior of a system under test. It contains a well-known example 3 | // by Robert C. Martin called "Bowling Game Kata" as well as another very 4 | // trivial example that demonstrates Reset() and some of the assertions. 5 | package examples 6 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/examples/examples.goconvey: -------------------------------------------------------------------------------- 1 | // Uncomment the next line to disable the package when running the GoConvey UI: 2 | //IGNORE 3 | 4 | // Uncomment the next line to limit testing to the specified test function name pattern: 5 | //-run=TestAssertionsAreAvailableFromConveyPackage 6 | 7 | // Uncomment the next line to limit testing to those tests that don't bail when testing.Short() is true: 8 | //-short 9 | 10 | // include any additional `go test` flags or application-specific flags below: 11 | 12 | -timeout=1s 13 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/examples/simple_example_test.go: -------------------------------------------------------------------------------- 1 | package examples 2 | 3 | import ( 4 | "testing" 5 | 6 | . "github.com/smartystreets/goconvey/convey" 7 | ) 8 | 9 | func TestIntegerManipulation(t *testing.T) { 10 | t.Parallel() 11 | 12 | Convey("Given a starting integer value", t, func() { 13 | x := 42 14 | 15 | Convey("When incremented", func() { 16 | x++ 17 | 18 | Convey("The value should be greater by one", func() { 19 | So(x, ShouldEqual, 43) 20 | }) 21 | Convey("The value should NOT be what it used to be", func() { 22 | So(x, ShouldNotEqual, 42) 23 | }) 24 | }) 25 | Convey("When decremented", func() { 26 | x-- 27 | 28 | Convey("The value should be lesser by one", func() { 29 | So(x, ShouldEqual, 41) 30 | }) 31 | Convey("The value should NOT be what it used to be", func() { 32 | So(x, ShouldNotEqual, 42) 33 | }) 34 | }) 35 | }) 36 | } 37 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/client/composer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | GoConvey Composer 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 |

15 | 16 | 17 |

18 |
19 |
20 | 21 |
22 |
23 | 24 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/client/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/euphoria-io/scope/33b185f2244afb5d8210936504ebab57accaf75c/vendor/github.com/smartystreets/goconvey/web/client/favicon.ico -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/client/resources/css/composer.css: -------------------------------------------------------------------------------- 1 | /* Eric Meyer's Reset CSS v2.0 */ 2 | html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{border:0;font-size:100%;font:inherit;vertical-align:baseline;margin:0;padding:0}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:none}table{border-collapse:collapse;border-spacing:0} 3 | 4 | @font-face { 5 | font-family: 'Open Sans'; 6 | src: local("Open Sans"), url("../fonts/Open_Sans/OpenSans-Regular.ttf"); 7 | } 8 | @font-face { 9 | font-family: 'Oswald'; 10 | src: local("Oswald"), url("../fonts/Oswald/Oswald-Regular.ttf"); 11 | } 12 | 13 | body { 14 | font-family: 'Open Sans', 'Helvetica Neue', sans-serif; 15 | font-size: 16px; 16 | } 17 | 18 | header { 19 | background: #2C3F49; 20 | padding: 10px; 21 | } 22 | 23 | .logo { 24 | font-family: Oswald, sans-serif; 25 | font-size: 24px; 26 | margin-right: 5px; 27 | color: #DDD; 28 | } 29 | 30 | .afterlogo { 31 | font-size: 12px; 32 | text-transform: uppercase; 33 | position: relative; 34 | top: -3px; 35 | color: #999; 36 | } 37 | 38 | #input, 39 | #output { 40 | -webkit-box-sizing: border-box; 41 | -moz-box-sizing: border-box; 42 | box-sizing: border-box; 43 | 44 | padding: 15px; 45 | height: 80%; 46 | float: left; 47 | overflow: auto; 48 | } 49 | 50 | #input { 51 | border: 0; 52 | font: 300 18px/1.5em 'Open Sans'; 53 | resize: none; 54 | outline: none; 55 | width: 50%; 56 | } 57 | 58 | #output { 59 | width: 50%; 60 | display: inline-block; 61 | background: #F0F0F0; 62 | font: 14px/1.25em 'Menlo', 'Monaco', 'Courier New', monospace; 63 | border-left: 1px solid #CCC; 64 | white-space: pre-wrap; 65 | } -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/client/resources/css/tipsy.css: -------------------------------------------------------------------------------- 1 | .tipsy { 2 | font-size: 12px; 3 | position: absolute; 4 | padding: 8px; 5 | z-index: 100000; 6 | font-family: 'Open Sans'; 7 | line-height: 1.25em; 8 | } 9 | 10 | .tipsy-inner { 11 | max-width: 200px; 12 | padding: 5px 7px; 13 | text-align: center; 14 | } 15 | 16 | /* Rounded corners */ 17 | /*.tipsy-inner { border-radius: 3px; -moz-border-radius: 3px; -webkit-border-radius: 3px; }*/ 18 | 19 | /* Shadow */ 20 | /*.tipsy-inner { box-shadow: 0 0 5px #000000; -webkit-box-shadow: 0 0 5px #000000; -moz-box-shadow: 0 0 5px #000000; }*/ 21 | 22 | .tipsy-arrow { 23 | position: absolute; 24 | width: 0; 25 | height: 0; 26 | line-height: 0; 27 | } 28 | 29 | .tipsy-n .tipsy-arrow, 30 | .tipsy-nw .tipsy-arrow, 31 | .tipsy-ne .tipsy-arrow { 32 | border-bottom-style: solid; 33 | border-top: none; 34 | border-left-color: transparent; 35 | border-right-color: transparent; 36 | } 37 | 38 | 39 | .tipsy-n .tipsy-arrow { 40 | top: 0px; 41 | left: 50%; 42 | margin-left: -7px; 43 | } 44 | .tipsy-nw .tipsy-arrow { 45 | top: 0; 46 | left: 10px; 47 | } 48 | .tipsy-ne .tipsy-arrow { 49 | top: 0; 50 | right: 10px; 51 | } 52 | 53 | .tipsy-s .tipsy-arrow, 54 | .tipsy-sw .tipsy-arrow, 55 | .tipsy-se .tipsy-arrow { 56 | border-top-style: solid; 57 | border-bottom: none; 58 | border-left-color: transparent; 59 | border-right-color: transparent; 60 | } 61 | 62 | 63 | .tipsy-s .tipsy-arrow { 64 | bottom: 0; 65 | left: 50%; 66 | margin-left: -7px; 67 | } 68 | 69 | .tipsy-sw .tipsy-arrow { 70 | bottom: 0; 71 | left: 10px; 72 | } 73 | 74 | .tipsy-se .tipsy-arrow { 75 | bottom: 0; 76 | right: 10px; 77 | } 78 | 79 | .tipsy-e .tipsy-arrow { 80 | right: 0; 81 | top: 50%; 82 | margin-top: -7px; 83 | border-left-style: solid; 84 | border-right: none; 85 | border-top-color: transparent; 86 | border-bottom-color: transparent; 87 | } 88 | 89 | .tipsy-w .tipsy-arrow { 90 | left: 0; 91 | top: 50%; 92 | margin-top: -7px; 93 | border-right-style: solid; 94 | border-left: none; 95 | border-top-color: transparent; 96 | border-bottom-color: transparent; 97 | } -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/FontAwesome/fonts/FontAwesome.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/euphoria-io/scope/33b185f2244afb5d8210936504ebab57accaf75c/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/FontAwesome/fonts/FontAwesome.otf -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/FontAwesome/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/euphoria-io/scope/33b185f2244afb5d8210936504ebab57accaf75c/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/FontAwesome/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/FontAwesome/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/euphoria-io/scope/33b185f2244afb5d8210936504ebab57accaf75c/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/FontAwesome/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/FontAwesome/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/euphoria-io/scope/33b185f2244afb5d8210936504ebab57accaf75c/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/FontAwesome/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/FontAwesome/fonts/fontawesome-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/euphoria-io/scope/33b185f2244afb5d8210936504ebab57accaf75c/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/FontAwesome/fonts/fontawesome-webfont.woff2 -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Open_Sans/OpenSans-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/euphoria-io/scope/33b185f2244afb5d8210936504ebab57accaf75c/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Open_Sans/OpenSans-Bold.ttf -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Open_Sans/OpenSans-Italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/euphoria-io/scope/33b185f2244afb5d8210936504ebab57accaf75c/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Open_Sans/OpenSans-Italic.ttf -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Open_Sans/OpenSans-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/euphoria-io/scope/33b185f2244afb5d8210936504ebab57accaf75c/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Open_Sans/OpenSans-Light.ttf -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Open_Sans/OpenSans-LightItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/euphoria-io/scope/33b185f2244afb5d8210936504ebab57accaf75c/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Open_Sans/OpenSans-LightItalic.ttf -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Open_Sans/OpenSans-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/euphoria-io/scope/33b185f2244afb5d8210936504ebab57accaf75c/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Open_Sans/OpenSans-Regular.ttf -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Orbitron/Orbitron-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/euphoria-io/scope/33b185f2244afb5d8210936504ebab57accaf75c/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Orbitron/Orbitron-Regular.ttf -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Oswald/Oswald-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/euphoria-io/scope/33b185f2244afb5d8210936504ebab57accaf75c/vendor/github.com/smartystreets/goconvey/web/client/resources/fonts/Oswald/Oswald-Regular.ttf -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/client/resources/ico/goconvey-buildfail.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/euphoria-io/scope/33b185f2244afb5d8210936504ebab57accaf75c/vendor/github.com/smartystreets/goconvey/web/client/resources/ico/goconvey-buildfail.ico -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/client/resources/ico/goconvey-fail.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/euphoria-io/scope/33b185f2244afb5d8210936504ebab57accaf75c/vendor/github.com/smartystreets/goconvey/web/client/resources/ico/goconvey-fail.ico -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/client/resources/ico/goconvey-ok.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/euphoria-io/scope/33b185f2244afb5d8210936504ebab57accaf75c/vendor/github.com/smartystreets/goconvey/web/client/resources/ico/goconvey-ok.ico -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/client/resources/ico/goconvey-panic.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/euphoria-io/scope/33b185f2244afb5d8210936504ebab57accaf75c/vendor/github.com/smartystreets/goconvey/web/client/resources/ico/goconvey-panic.ico -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/client/resources/js/config.js: -------------------------------------------------------------------------------- 1 | // Configure the GoConvey web UI client in here 2 | 3 | convey.config = { 4 | 5 | // Install new themes by adding them here; the first one will be default 6 | themes: { 7 | "dark": { name: "Dark", filename: "dark.css", coverage: "hsla({{hue}}, 75%, 30%, .5)" }, 8 | "dark-bigtext": { name: "Dark-BigText", filename: "dark-bigtext.css", coverage: "hsla({{hue}}, 75%, 30%, .5)" }, 9 | "light": { name: "Light", filename: "light.css", coverage: "hsla({{hue}}, 62%, 75%, 1)" } 10 | }, 11 | 12 | // Path to the themes (end with forward-slash) 13 | themePath: "/resources/css/themes/" 14 | 15 | }; 16 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/client/resources/js/convey.js: -------------------------------------------------------------------------------- 1 | var convey = { 2 | 3 | // *** Don't edit in here unless you're brave *** 4 | 5 | statuses: { // contains some constants related to overall test status 6 | pass: { class: 'ok', text: "Pass" }, // class name must also be that in the favicon file name 7 | fail: { class: 'fail', text: "Fail" }, 8 | panic: { class: 'panic', text: "Panic" }, 9 | buildfail: { class: 'buildfail', text: "Build Failure" } 10 | }, 11 | frameCounter: 0, // gives each frame a unique ID 12 | maxHistory: 20, // how many tests to keep in the history 13 | notif: undefined, // the notification currently being displayed 14 | notifTimer: undefined, // the timer that clears the notifications automatically 15 | poller: new Poller(), // the server poller 16 | status: "", // what the _server_ is currently doing (not overall test results) 17 | overallClass: "", // class name of the "overall" status banner 18 | theme: "", // theme currently being used 19 | packageStates: {}, // packages manually collapsed or expanded during this page's lifetime 20 | uiEffects: true, // whether visual effects are enabled 21 | framesOnSamePath: 0, // number of consecutive frames on this same watch path 22 | layout: { 23 | selClass: "sel", // CSS class when an element is "selected" 24 | header: undefined, // container element of the header area (overall, controls) 25 | frame: undefined, // container element of the main body area (above footer) 26 | footer: undefined // container element of the footer (stuck to bottom) 27 | }, 28 | history: [], // complete history of states (test results and aggregated data), including the current one 29 | moments: {}, // elements that display time relative to the current time, keyed by ID, with the moment() as a value 30 | intervals: {}, // ntervals that execute periodically 31 | intervalFuncs: { // functions executed by each interval in convey.intervals 32 | time: function() 33 | { 34 | var t = new Date(); 35 | var h = zerofill(t.getHours(), 2); 36 | var m = zerofill(t.getMinutes(), 2); 37 | var s = zerofill(t.getSeconds(), 2); 38 | $('#time').text(h + ":" + m + ":" + s); 39 | }, 40 | momentjs: function() 41 | { 42 | for (var id in convey.moments) 43 | $('#'+id).html(convey.moments[id].fromNow()); 44 | } 45 | } 46 | }; 47 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/client/resources/js/lib/ansispan.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2011 by Maciej Małecki 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | */ 22 | 23 | var ansispan = function (str) { 24 | Object.keys(ansispan.foregroundColors).forEach(function (ansi) { 25 | var span = ''; 26 | 27 | // 28 | // `\033[Xm` == `\033[0;Xm` sets foreground color to `X`. 29 | // 30 | 31 | str = str.replace( 32 | new RegExp('\033\\[' + ansi + 'm', 'g'), 33 | span 34 | ).replace( 35 | new RegExp('\033\\[0;' + ansi + 'm', 'g'), 36 | span 37 | ); 38 | }); 39 | // 40 | // `\033[1m` enables bold font, `\033[22m` disables it 41 | // 42 | str = str.replace(/\033\[1m/g, '').replace(/\033\[22m/g, ''); 43 | 44 | // 45 | // `\033[3m` enables italics font, `\033[23m` disables it 46 | // 47 | str = str.replace(/\033\[3m/g, '').replace(/\033\[23m/g, ''); 48 | 49 | str = str.replace(/\033\[m/g, ''); 50 | str = str.replace(/\033\[0m/g, ''); 51 | return str.replace(/\033\[39m/g, ''); 52 | }; 53 | 54 | ansispan.foregroundColors = { 55 | '30': 'black', 56 | '31': 'red', 57 | '32': 'green', 58 | '33': 'yellow', 59 | '34': 'blue', 60 | '35': 'purple', 61 | '36': 'cyan', 62 | '37': 'white' 63 | }; 64 | 65 | if (typeof module !== 'undefined' && module.exports) { 66 | module.exports = ansispan; 67 | } 68 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/client/resources/js/lib/jquery-ui.js.url: -------------------------------------------------------------------------------- 1 | https://code.jquery.com/ui/1.10.4/jquery-ui.js 2 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/client/resources/js/lib/jquery.js.url: -------------------------------------------------------------------------------- 1 | https://code.jquery.com/jquery-2.1.0.js 2 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/client/resources/js/lib/jquery.pretty-text-diff.js: -------------------------------------------------------------------------------- 1 | // Generated by CoffeeScript 1.4.0 2 | 3 | /* 4 | @preserve jQuery.PrettyTextDiff 1.0.2 5 | See https://github.com/arnab/jQuery.PrettyTextDiff/ 6 | */ 7 | 8 | 9 | (function() { 10 | var $; 11 | 12 | $ = jQuery; 13 | 14 | $.fn.extend({ 15 | prettyTextDiff: function(options) { 16 | var dmp, settings; 17 | settings = { 18 | originalContainer: ".original", 19 | changedContainer: ".changed", 20 | diffContainer: ".diff", 21 | cleanup: true, 22 | debug: false 23 | }; 24 | settings = $.extend(settings, options); 25 | $.fn.prettyTextDiff.debug("Options: ", settings, settings); 26 | dmp = new diff_match_patch(); 27 | return this.each(function() { 28 | var changed, diff_as_html, diffs, original; 29 | original = $(settings.originalContainer, this).text(); 30 | $.fn.prettyTextDiff.debug("Original text found: ", original, settings); 31 | changed = $(settings.changedContainer, this).text(); 32 | $.fn.prettyTextDiff.debug("Changed text found: ", changed, settings); 33 | diffs = dmp.diff_main(original, changed); 34 | if (settings.cleanup) { 35 | dmp.diff_cleanupSemantic(diffs); 36 | } 37 | $.fn.prettyTextDiff.debug("Diffs: ", diffs, settings); 38 | diff_as_html = diffs.map(function(diff) { 39 | return $.fn.prettyTextDiff.createHTML(diff); 40 | }); 41 | $(settings.diffContainer, this).html(diff_as_html.join('')); 42 | return this; 43 | }); 44 | } 45 | }); 46 | 47 | $.fn.prettyTextDiff.debug = function(message, object, settings) { 48 | if (settings.debug) { 49 | return console.log(message, object); 50 | } 51 | }; 52 | 53 | $.fn.prettyTextDiff.createHTML = function(diff) { 54 | var data, html, operation, pattern_amp, pattern_gt, pattern_lt, pattern_para, text; 55 | html = []; 56 | pattern_amp = /&/g; 57 | pattern_lt = //g; 59 | pattern_para = /\n/g; 60 | operation = diff[0], data = diff[1]; 61 | text = data.replace(pattern_amp, '&').replace(pattern_lt, '<').replace(pattern_gt, '>').replace(pattern_para, '
'); 62 | switch (operation) { 63 | case DIFF_INSERT: 64 | return '' + text + ''; 65 | case DIFF_DELETE: 66 | return '' + text + ''; 67 | case DIFF_EQUAL: 68 | return '' + text + ''; 69 | } 70 | }; 71 | 72 | }).call(this); 73 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/client/resources/js/lib/jquery.pretty-text-diff.js.url: -------------------------------------------------------------------------------- 1 | https://raw.githubusercontent.com/arnab/jQuery.PrettyTextDiff/1.0.2/jquery.pretty-text-diff.js 2 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/client/resources/js/lib/jquery.tipsy.js.url: -------------------------------------------------------------------------------- 1 | https://raw.githubusercontent.com/jaz303/tipsy/v1.0.0a/src/javascripts/jquery.tipsy.js 2 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/client/resources/js/lib/markup.js.url: -------------------------------------------------------------------------------- 1 | https://raw.githubusercontent.com/adammark/Markup.js/master/src/markup.js 2 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/client/resources/js/lib/moment.js.url: -------------------------------------------------------------------------------- 1 | https://raw.githubusercontent.com/moment/moment/2.10.2/moment.js 2 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/client/resources/js/lib/taboverride.js.url: -------------------------------------------------------------------------------- 1 | https://raw.githubusercontent.com/wjbryant/taboverride/4.0.3/build/output/taboverride.js 2 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/server/api/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["server.go"], 6 | visibility = ["//visibility:public"], 7 | deps = [ 8 | "//vendor/github.com/smartystreets/goconvey/web/server/contract:go_default_library", 9 | "//vendor/github.com/smartystreets/goconvey/web/server/messaging:go_default_library", 10 | ], 11 | ) 12 | 13 | go_test( 14 | name = "go_default_test", 15 | srcs = ["server_test.go"], 16 | library = ":go_default_library", 17 | deps = [ 18 | "//vendor/github.com/smartystreets/goconvey/convey:go_default_library", 19 | "//vendor/github.com/smartystreets/goconvey/web/server/contract:go_default_library", 20 | "//vendor/github.com/smartystreets/goconvey/web/server/messaging:go_default_library", 21 | ], 22 | ) 23 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/server/api/api.goconvey: -------------------------------------------------------------------------------- 1 | #ignore 2 | -timeout=1s 3 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/server/contract/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = [ 6 | "contracts.go", 7 | "result.go", 8 | ], 9 | visibility = ["//visibility:public"], 10 | deps = [ 11 | "//vendor/github.com/smartystreets/goconvey/convey/reporting:go_default_library", 12 | "//vendor/github.com/smartystreets/goconvey/web/server/messaging:go_default_library", 13 | ], 14 | ) 15 | 16 | go_test( 17 | name = "go_default_test", 18 | srcs = ["doc_test.go"], 19 | library = ":go_default_library", 20 | ) 21 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/server/contract/contracts.go: -------------------------------------------------------------------------------- 1 | package contract 2 | 3 | import "net/http" 4 | 5 | type ( 6 | Server interface { 7 | ReceiveUpdate(root string, update *CompleteOutput) 8 | Watch(writer http.ResponseWriter, request *http.Request) 9 | Ignore(writer http.ResponseWriter, request *http.Request) 10 | Reinstate(writer http.ResponseWriter, request *http.Request) 11 | Status(writer http.ResponseWriter, request *http.Request) 12 | LongPollStatus(writer http.ResponseWriter, request *http.Request) 13 | Results(writer http.ResponseWriter, request *http.Request) 14 | Execute(writer http.ResponseWriter, request *http.Request) 15 | TogglePause(writer http.ResponseWriter, request *http.Request) 16 | } 17 | 18 | Executor interface { 19 | ExecuteTests([]*Package) *CompleteOutput 20 | Status() string 21 | ClearStatusFlag() bool 22 | } 23 | 24 | Shell interface { 25 | GoTest(directory, packageName string, tags, arguments []string) (output string, err error) 26 | } 27 | ) 28 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/server/contract/doc_test.go: -------------------------------------------------------------------------------- 1 | package contract 2 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/server/executor/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = [ 6 | "contract.go", 7 | "coordinator.go", 8 | "executor.go", 9 | "tester.go", 10 | ], 11 | visibility = ["//visibility:public"], 12 | deps = ["//vendor/github.com/smartystreets/goconvey/web/server/contract:go_default_library"], 13 | ) 14 | 15 | go_test( 16 | name = "go_default_test", 17 | srcs = [ 18 | "executor_test.go", 19 | "tester_test.go", 20 | ], 21 | library = ":go_default_library", 22 | deps = [ 23 | "//vendor/github.com/smartystreets/goconvey/convey:go_default_library", 24 | "//vendor/github.com/smartystreets/goconvey/web/server/contract:go_default_library", 25 | ], 26 | ) 27 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/server/executor/contract.go: -------------------------------------------------------------------------------- 1 | package executor 2 | 3 | import "github.com/smartystreets/goconvey/web/server/contract" 4 | 5 | type Parser interface { 6 | Parse([]*contract.Package) 7 | } 8 | 9 | type Tester interface { 10 | SetBatchSize(batchSize int) 11 | TestAll(folders []*contract.Package) 12 | } 13 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/server/executor/coordinator.go: -------------------------------------------------------------------------------- 1 | package executor 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "log" 7 | "strings" 8 | "sync" 9 | 10 | "github.com/smartystreets/goconvey/web/server/contract" 11 | ) 12 | 13 | type concurrentCoordinator struct { 14 | batchSize int 15 | queue chan *contract.Package 16 | folders []*contract.Package 17 | shell contract.Shell 18 | waiter sync.WaitGroup 19 | } 20 | 21 | func (self *concurrentCoordinator) ExecuteConcurrently() { 22 | self.enlistWorkers() 23 | self.scheduleTasks() 24 | self.awaitCompletion() 25 | } 26 | 27 | func (self *concurrentCoordinator) enlistWorkers() { 28 | for i := 0; i < self.batchSize; i++ { 29 | self.waiter.Add(1) 30 | go self.worker(i) 31 | } 32 | } 33 | func (self *concurrentCoordinator) worker(id int) { 34 | for folder := range self.queue { 35 | packageName := strings.Replace(folder.Name, "\\", "/", -1) 36 | if !folder.Active() { 37 | log.Printf("Skipping concurrent execution: %s\n", packageName) 38 | continue 39 | } 40 | 41 | if folder.HasImportCycle { 42 | message := fmt.Sprintf("can't load package: import cycle not allowed\npackage %s\n\timports %s", packageName, packageName) 43 | log.Println(message) 44 | folder.Output, folder.Error = message, errors.New(message) 45 | } else { 46 | log.Printf("Executing concurrent tests: %s\n", packageName) 47 | folder.Output, folder.Error = self.shell.GoTest(folder.Path, packageName, folder.BuildTags, folder.TestArguments) 48 | } 49 | } 50 | self.waiter.Done() 51 | } 52 | 53 | func (self *concurrentCoordinator) scheduleTasks() { 54 | for _, folder := range self.folders { 55 | self.queue <- folder 56 | } 57 | } 58 | 59 | func (self *concurrentCoordinator) awaitCompletion() { 60 | close(self.queue) 61 | self.waiter.Wait() 62 | } 63 | 64 | func newConcurrentCoordinator(folders []*contract.Package, batchSize int, shell contract.Shell) *concurrentCoordinator { 65 | self := new(concurrentCoordinator) 66 | self.queue = make(chan *contract.Package) 67 | self.folders = folders 68 | self.batchSize = batchSize 69 | self.shell = shell 70 | return self 71 | } 72 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/server/executor/executor.go: -------------------------------------------------------------------------------- 1 | package executor 2 | 3 | import ( 4 | "log" 5 | "time" 6 | 7 | "github.com/smartystreets/goconvey/web/server/contract" 8 | ) 9 | 10 | const ( 11 | Idle = "idle" 12 | Executing = "executing" 13 | ) 14 | 15 | type Executor struct { 16 | tester Tester 17 | parser Parser 18 | status string 19 | statusChan chan chan string 20 | statusFlag bool 21 | } 22 | 23 | func (self *Executor) Status() string { 24 | return self.status 25 | } 26 | 27 | func (self *Executor) ClearStatusFlag() bool { 28 | hasNewStatus := self.statusFlag 29 | self.statusFlag = false 30 | return hasNewStatus 31 | } 32 | 33 | func (self *Executor) ExecuteTests(folders []*contract.Package) *contract.CompleteOutput { 34 | defer func() { self.setStatus(Idle) }() 35 | self.execute(folders) 36 | result := self.parse(folders) 37 | return result 38 | } 39 | 40 | func (self *Executor) execute(folders []*contract.Package) { 41 | self.setStatus(Executing) 42 | self.tester.TestAll(folders) 43 | } 44 | 45 | func (self *Executor) parse(folders []*contract.Package) *contract.CompleteOutput { 46 | result := &contract.CompleteOutput{Revision: now().String()} 47 | self.parser.Parse(folders) 48 | for _, folder := range folders { 49 | result.Packages = append(result.Packages, folder.Result) 50 | } 51 | return result 52 | } 53 | 54 | func (self *Executor) setStatus(status string) { 55 | self.status = status 56 | self.statusFlag = true 57 | 58 | Loop: 59 | for { 60 | select { 61 | case c := <-self.statusChan: 62 | self.statusFlag = false 63 | c <- status 64 | default: 65 | break Loop 66 | } 67 | } 68 | 69 | log.Printf("Executor status: '%s'\n", self.status) 70 | } 71 | 72 | func NewExecutor(tester Tester, parser Parser, ch chan chan string) *Executor { 73 | return &Executor{ 74 | tester: tester, 75 | parser: parser, 76 | status: Idle, 77 | statusChan: ch, 78 | statusFlag: false, 79 | } 80 | } 81 | 82 | var now = func() time.Time { 83 | return time.Now() 84 | } 85 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/server/executor/executor.goconvey: -------------------------------------------------------------------------------- 1 | #ignore 2 | -timeout=1s 3 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/server/executor/tester.go: -------------------------------------------------------------------------------- 1 | package executor 2 | 3 | import ( 4 | "errors" 5 | "fmt" 6 | "log" 7 | "strings" 8 | 9 | "github.com/smartystreets/goconvey/web/server/contract" 10 | ) 11 | 12 | type ConcurrentTester struct { 13 | shell contract.Shell 14 | batchSize int 15 | } 16 | 17 | func (self *ConcurrentTester) SetBatchSize(batchSize int) { 18 | self.batchSize = batchSize 19 | log.Printf("Now configured to test %d packages concurrently.\n", self.batchSize) 20 | } 21 | 22 | func (self *ConcurrentTester) TestAll(folders []*contract.Package) { 23 | if self.batchSize == 1 { 24 | self.executeSynchronously(folders) 25 | } else { 26 | newConcurrentCoordinator(folders, self.batchSize, self.shell).ExecuteConcurrently() 27 | } 28 | return 29 | } 30 | 31 | func (self *ConcurrentTester) executeSynchronously(folders []*contract.Package) { 32 | for _, folder := range folders { 33 | packageName := strings.Replace(folder.Name, "\\", "/", -1) 34 | if !folder.Active() { 35 | log.Printf("Skipping execution: %s\n", packageName) 36 | continue 37 | } 38 | if folder.HasImportCycle { 39 | message := fmt.Sprintf("can't load package: import cycle not allowed\npackage %s\n\timports %s", packageName, packageName) 40 | log.Println(message) 41 | folder.Output, folder.Error = message, errors.New(message) 42 | } else { 43 | log.Printf("Executing tests: %s\n", packageName) 44 | folder.Output, folder.Error = self.shell.GoTest(folder.Path, packageName, folder.BuildTags, folder.TestArguments) 45 | } 46 | } 47 | } 48 | 49 | func NewConcurrentTester(shell contract.Shell) *ConcurrentTester { 50 | self := new(ConcurrentTester) 51 | self.shell = shell 52 | self.batchSize = defaultBatchSize 53 | return self 54 | } 55 | 56 | const defaultBatchSize = 10 57 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/server/messaging/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["messages.go"], 6 | visibility = ["//visibility:public"], 7 | ) 8 | 9 | go_test( 10 | name = "go_default_test", 11 | srcs = ["doc_test.go"], 12 | library = ":go_default_library", 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/server/messaging/doc_test.go: -------------------------------------------------------------------------------- 1 | package messaging 2 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/server/messaging/messages.go: -------------------------------------------------------------------------------- 1 | package messaging 2 | 3 | /////////////////////////////////////////////////////////////////////////////// 4 | 5 | type WatcherCommand struct { 6 | Instruction WatcherInstruction 7 | Details string 8 | } 9 | 10 | type WatcherInstruction int 11 | 12 | func (this WatcherInstruction) String() string { 13 | switch this { 14 | case WatcherPause: 15 | return "Pause" 16 | case WatcherResume: 17 | return "Resume" 18 | case WatcherIgnore: 19 | return "Ignore" 20 | case WatcherReinstate: 21 | return "Reinstate" 22 | case WatcherAdjustRoot: 23 | return "AdjustRoot" 24 | case WatcherExecute: 25 | return "Execute" 26 | case WatcherStop: 27 | return "Stop" 28 | default: 29 | return "UNKNOWN INSTRUCTION" 30 | } 31 | } 32 | 33 | const ( 34 | WatcherPause WatcherInstruction = iota 35 | WatcherResume 36 | WatcherIgnore 37 | WatcherReinstate 38 | WatcherAdjustRoot 39 | WatcherExecute 40 | WatcherStop 41 | ) 42 | 43 | /////////////////////////////////////////////////////////////////////////////// 44 | 45 | type Folders map[string]*Folder 46 | 47 | type Folder struct { 48 | Path string // key 49 | Root string 50 | Ignored bool 51 | Disabled bool 52 | BuildTags []string 53 | TestArguments []string 54 | } 55 | 56 | /////////////////////////////////////////////////////////////////////////////// 57 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/server/parser/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = [ 6 | "packageParser.go", 7 | "parser.go", 8 | "rules.go", 9 | "testParser.go", 10 | "util.go", 11 | ], 12 | visibility = ["//visibility:public"], 13 | deps = [ 14 | "//vendor/github.com/smartystreets/goconvey/convey/reporting:go_default_library", 15 | "//vendor/github.com/smartystreets/goconvey/web/server/contract:go_default_library", 16 | ], 17 | ) 18 | 19 | go_test( 20 | name = "go_default_test", 21 | srcs = [ 22 | "package_parser_test.go", 23 | "parser_test.go", 24 | ], 25 | library = ":go_default_library", 26 | deps = [ 27 | "//vendor/github.com/smartystreets/goconvey/convey:go_default_library", 28 | "//vendor/github.com/smartystreets/goconvey/convey/reporting:go_default_library", 29 | "//vendor/github.com/smartystreets/goconvey/web/server/contract:go_default_library", 30 | ], 31 | ) 32 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/server/parser/parser.go: -------------------------------------------------------------------------------- 1 | package parser 2 | 3 | import ( 4 | "log" 5 | 6 | "github.com/smartystreets/goconvey/web/server/contract" 7 | ) 8 | 9 | type Parser struct { 10 | parser func(*contract.PackageResult, string) 11 | } 12 | 13 | func (self *Parser) Parse(packages []*contract.Package) { 14 | for _, p := range packages { 15 | if p.Active() && p.HasUsableResult() { 16 | self.parser(p.Result, p.Output) 17 | } else if p.Ignored { 18 | p.Result.Outcome = contract.Ignored 19 | } else if p.Disabled { 20 | p.Result.Outcome = contract.Disabled 21 | } else { 22 | p.Result.Outcome = contract.TestRunAbortedUnexpectedly 23 | } 24 | log.Printf("[%s]: %s\n", p.Result.Outcome, p.Name) 25 | } 26 | } 27 | 28 | func NewParser(helper func(*contract.PackageResult, string)) *Parser { 29 | self := new(Parser) 30 | self.parser = helper 31 | return self 32 | } 33 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/server/parser/parser.goconvey: -------------------------------------------------------------------------------- 1 | #ignore 2 | -timeout=1s 3 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/server/parser/parser_test.go: -------------------------------------------------------------------------------- 1 | package parser 2 | 3 | import ( 4 | "errors" 5 | "testing" 6 | 7 | . "github.com/smartystreets/goconvey/convey" 8 | "github.com/smartystreets/goconvey/web/server/contract" 9 | ) 10 | 11 | func TestParser(t *testing.T) { 12 | 13 | Convey("Subject: Parser parses test output for active packages", t, func() { 14 | packages := []*contract.Package{ 15 | &contract.Package{Ignored: false, Output: "Active", Result: contract.NewPackageResult("asdf")}, 16 | &contract.Package{Ignored: true, Output: "Inactive", Result: contract.NewPackageResult("qwer")}, 17 | } 18 | parser := NewParser(fakeParserImplementation) 19 | 20 | Convey("When given a collection of packages", func() { 21 | parser.Parse(packages) 22 | 23 | Convey("The parser uses its internal parsing mechanism to parse the output of only the active packages", func() { 24 | So(packages[0].Result.Outcome, ShouldEqual, packages[0].Output) 25 | }) 26 | 27 | Convey("The parser should mark inactive packages as ignored", func() { 28 | So(packages[1].Result.Outcome, ShouldEqual, contract.Ignored) 29 | }) 30 | }) 31 | 32 | Convey("When a package could not be tested (maybe it was deleted between scanning and execution?)", func() { 33 | packages[0].Output = "" 34 | packages[0].Error = errors.New("Directory does not exist") 35 | 36 | parser.Parse(packages) 37 | 38 | Convey("The package result should not be parsed and the outcome should actually resemble the problem", func() { 39 | So(packages[0].Result.Outcome, ShouldEqual, contract.TestRunAbortedUnexpectedly) 40 | }) 41 | }) 42 | }) 43 | } 44 | 45 | func fakeParserImplementation(result *contract.PackageResult, rawOutput string) { 46 | result.Outcome = rawOutput 47 | } 48 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/server/parser/rules.go: -------------------------------------------------------------------------------- 1 | package parser 2 | 3 | import "strings" 4 | 5 | func noGoFiles(line string) bool { 6 | return strings.HasPrefix(line, "can't load package: ") && 7 | strings.Contains(line, ": no buildable Go source files in ") 8 | } 9 | func buildFailed(line string) bool { 10 | return strings.HasPrefix(line, "# ") || 11 | strings.Contains(line, "cannot find package") || 12 | (strings.HasPrefix(line, "can't load package: ") && !strings.Contains(line, ": no Go source files in ")) || 13 | (strings.Contains(line, ": found packages ") && strings.Contains(line, ".go) and ") && strings.Contains(line, ".go) in ")) 14 | } 15 | func noTestFunctions(line string) bool { 16 | return line == "testing: warning: no tests to run" 17 | } 18 | func noTestFiles(line string) bool { 19 | return strings.HasPrefix(line, "?") && strings.Contains(line, "[no test files]") 20 | } 21 | func isNewTest(line string) bool { 22 | return strings.HasPrefix(line, "=== ") 23 | } 24 | func isTestResult(line string) bool { 25 | return strings.HasPrefix(line, "--- ") 26 | } 27 | func isPackageReport(line string) bool { 28 | return (strings.HasPrefix(line, "FAIL") || 29 | strings.HasPrefix(line, "exit status") || 30 | strings.HasPrefix(line, "PASS") || 31 | isCoverageSummary(line) || 32 | packagePassed(line)) 33 | } 34 | 35 | func packageFailed(line string) bool { 36 | return strings.HasPrefix(line, "FAIL\t") 37 | } 38 | func packagePassed(line string) bool { 39 | return strings.HasPrefix(line, "ok \t") 40 | } 41 | func isCoverageSummary(line string) bool { 42 | return strings.HasPrefix(line, "coverage: ") && strings.Contains(line, "% of statements") 43 | } 44 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/server/parser/util.go: -------------------------------------------------------------------------------- 1 | package parser 2 | 3 | import ( 4 | "math" 5 | "strings" 6 | "time" 7 | ) 8 | 9 | // parseTestFunctionDuration parses the duration in seconds as a float64 10 | // from a line of go test output that looks something like this: 11 | // --- PASS: TestOldSchool_PassesWithMessage (0.03 seconds) 12 | func parseTestFunctionDuration(line string) float64 { 13 | line = strings.Replace(line, "(", "", 1) 14 | fields := strings.Split(line, " ") 15 | return parseDurationInSeconds(fields[3]+"s", 2) 16 | } 17 | 18 | func parseDurationInSeconds(raw string, precision int) float64 { 19 | elapsed, _ := time.ParseDuration(raw) 20 | return round(elapsed.Seconds(), precision) 21 | } 22 | 23 | // round returns the rounded version of x with precision. 24 | // 25 | // Special cases are: 26 | // round(±0) = ±0 27 | // round(±Inf) = ±Inf 28 | // round(NaN) = NaN 29 | // 30 | // Why, oh why doesn't the math package come with a round function? 31 | // Inspiration: http://play.golang.org/p/ZmFfr07oHp 32 | func round(x float64, precision int) float64 { 33 | var rounder float64 34 | pow := math.Pow(10, float64(precision)) 35 | intermediate := x * pow 36 | 37 | if intermediate < 0.0 { 38 | intermediate -= 0.5 39 | } else { 40 | intermediate += 0.5 41 | } 42 | rounder = float64(int64(intermediate)) 43 | 44 | return rounder / float64(pow) 45 | } 46 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/server/system/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["shell.go"], 6 | visibility = ["//visibility:public"], 7 | ) 8 | 9 | go_test( 10 | name = "go_default_test", 11 | srcs = [ 12 | "shell_integration_test.go", 13 | "shell_test.go", 14 | ], 15 | library = ":go_default_library", 16 | deps = ["//vendor/github.com/smartystreets/goconvey/convey:go_default_library"], 17 | ) 18 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/server/system/shell_integration_test.go: -------------------------------------------------------------------------------- 1 | package system 2 | 3 | import ( 4 | "log" 5 | "path/filepath" 6 | "runtime" 7 | "strings" 8 | 9 | "testing" 10 | ) 11 | 12 | func TestShellIntegration(t *testing.T) { 13 | if testing.Short() { 14 | t.Skip("Skipping potentially long-running integration test...") 15 | return 16 | } 17 | 18 | log.SetFlags(log.LstdFlags | log.Lshortfile | log.Lmicroseconds) 19 | 20 | _, filename, _, _ := runtime.Caller(0) 21 | directory := filepath.Join(filepath.Dir(filename), "..", "watch", "integration_testing", "sub") 22 | packageName := "github.com/smartystreets/goconvey/web/server/watch/integration_testing/sub" 23 | 24 | shell := NewShell("go", "", true, "5s") 25 | output, err := shell.GoTest(directory, packageName, []string{}, []string{"-short"}) 26 | 27 | if !strings.Contains(output, "PASS\n") || !strings.Contains(output, "ok") { 28 | t.Errorf("Expected output that resembed tests passing but got this instead: [%s]", output) 29 | } 30 | if err != nil { 31 | t.Error("Test run resulted in the following error:", err) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/server/system/system.goconvey: -------------------------------------------------------------------------------- 1 | #ignore 2 | -timeout=1s 3 | -short -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/server/watch/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = [ 6 | "functional_core.go", 7 | "imperative_shell.go", 8 | "integration.go", 9 | ], 10 | visibility = ["//visibility:public"], 11 | deps = ["//vendor/github.com/smartystreets/goconvey/web/server/messaging:go_default_library"], 12 | ) 13 | 14 | go_test( 15 | name = "go_default_test", 16 | srcs = [ 17 | "functional_core_test.go", 18 | "integration_test.go", 19 | "util_test.go", 20 | ], 21 | library = ":go_default_library", 22 | deps = [ 23 | "//vendor/github.com/smartystreets/goconvey/convey:go_default_library", 24 | "//vendor/github.com/smartystreets/goconvey/web/server/messaging:go_default_library", 25 | ], 26 | ) 27 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/server/watch/imperative_shell.go: -------------------------------------------------------------------------------- 1 | package watch 2 | 3 | import ( 4 | "io" 5 | "io/ioutil" 6 | "os" 7 | "path/filepath" 8 | "strings" 9 | ) 10 | 11 | /////////////////////////////////////////////////////////////////////////////// 12 | 13 | type FileSystemItem struct { 14 | Root string 15 | Path string 16 | Name string 17 | Size int64 18 | Modified int64 19 | IsFolder bool 20 | 21 | ProfileDisabled bool 22 | ProfileTags []string 23 | ProfileArguments []string 24 | } 25 | 26 | /////////////////////////////////////////////////////////////////////////////// 27 | 28 | func YieldFileSystemItems(root string, excludedDirs []string) chan *FileSystemItem { 29 | items := make(chan *FileSystemItem) 30 | 31 | go func() { 32 | filepath.Walk(root, func(path string, info os.FileInfo, err error) error { 33 | if err != nil { 34 | return filepath.SkipDir 35 | } 36 | 37 | if info.IsDir() && strings.HasPrefix(info.Name(), ".") { 38 | return filepath.SkipDir 39 | } 40 | 41 | basePath := filepath.Base(path) 42 | for _, item := range excludedDirs { 43 | if item == basePath && info.IsDir() && item != "" && basePath != "" { 44 | return filepath.SkipDir 45 | } 46 | } 47 | 48 | items <- &FileSystemItem{ 49 | Root: root, 50 | Path: path, 51 | Name: info.Name(), 52 | Size: info.Size(), 53 | Modified: info.ModTime().Unix(), 54 | IsFolder: info.IsDir(), 55 | } 56 | 57 | return nil 58 | }) 59 | close(items) 60 | }() 61 | 62 | return items 63 | } 64 | 65 | /////////////////////////////////////////////////////////////////////////////// 66 | 67 | // ReadContents reads files wholesale. This function is only called on files 68 | // that end in '.goconvey'. These files should be very small, probably not 69 | // ever more than a few hundred bytes. The ignored errors are ok because in 70 | // the event of an IO error all that need be returned is an empty string. 71 | func ReadContents(path string) string { 72 | file, err := os.Open(path) 73 | if err != nil { 74 | return "" 75 | } 76 | defer file.Close() 77 | reader := io.LimitReader(file, 1024*4) 78 | content, _ := ioutil.ReadAll(reader) 79 | return string(content) 80 | } 81 | 82 | /////////////////////////////////////////////////////////////////////////////// 83 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/server/watch/integration_testing/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["main.go"], 6 | visibility = ["//visibility:private"], 7 | ) 8 | 9 | go_binary( 10 | name = "integration_testing", 11 | library = ":go_default_library", 12 | visibility = ["//visibility:public"], 13 | ) 14 | 15 | go_test( 16 | name = "go_default_test", 17 | srcs = ["doc_test.go"], 18 | library = ":go_default_library", 19 | ) 20 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/server/watch/integration_testing/doc_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/server/watch/integration_testing/main.go: -------------------------------------------------------------------------------- 1 | // This file's only purpose is to provide a realistic 2 | // environment from which to run integration tests 3 | // against the Watcher. 4 | package main 5 | 6 | import "fmt" 7 | 8 | func main() { 9 | fmt.Println("Hello, World!") 10 | } 11 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/server/watch/integration_testing/sub/.gitignore: -------------------------------------------------------------------------------- 1 | github.com-smartystreets-goconvey-web-server-integration_testing-sub.html 2 | github.com-smartystreets-goconvey-web-server-integration_testing-sub.txt -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/server/watch/integration_testing/sub/BUILD.bazel: -------------------------------------------------------------------------------- 1 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 2 | 3 | go_library( 4 | name = "go_default_library", 5 | srcs = ["stuff.go"], 6 | visibility = ["//visibility:public"], 7 | ) 8 | 9 | go_test( 10 | name = "go_default_test", 11 | srcs = ["stuff_test.go"], 12 | library = ":go_default_library", 13 | ) 14 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/server/watch/integration_testing/sub/stuff.go: -------------------------------------------------------------------------------- 1 | // This file's only purpose is to provide a realistic 2 | // environment from which to run integration tests 3 | // against the Watcher. 4 | package sub 5 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/server/watch/integration_testing/sub/stuff_test.go: -------------------------------------------------------------------------------- 1 | // This file's only purpose is to provide a realistic 2 | // environment from which to run integration tests 3 | // against the Watcher. 4 | package sub 5 | 6 | import ( 7 | "fmt" 8 | "testing" 9 | ) 10 | 11 | func TestStuff(t *testing.T) { 12 | if testing.Short() { 13 | return 14 | } 15 | 16 | fmt.Println() 17 | } 18 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/server/watch/integration_testing/sub/sub.goconvey: -------------------------------------------------------------------------------- 1 | IGNORE 2 | -short 3 | -run=TestStuff 4 | 5 | // This file's only purpose is to provide a realistic 6 | // environment from which to run integration tests 7 | // against the Watcher. 8 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/server/watch/util_test.go: -------------------------------------------------------------------------------- 1 | // Credits: https://gist.github.com/jaybill/2876519 2 | package watch 3 | 4 | import "os" 5 | import "io" 6 | import "io/ioutil" 7 | import "log" 8 | 9 | // Copies original source to destination destination. 10 | func CopyFile(source string, destination string) (err error) { 11 | originalFile, err := os.Open(source) 12 | if err != nil { 13 | return err 14 | } 15 | defer originalFile.Close() 16 | destinationFile, err := os.Create(destination) 17 | if err != nil { 18 | return err 19 | } 20 | defer destinationFile.Close() 21 | _, err = io.Copy(destinationFile, originalFile) 22 | if err == nil { 23 | info, err := os.Stat(source) 24 | if err != nil { 25 | err = os.Chmod(destination, info.Mode()) 26 | } 27 | 28 | } 29 | 30 | return 31 | } 32 | 33 | // Recursively copies a directory tree, attempting to preserve permissions. 34 | // Source directory must exist, destination directory must *not* exist. 35 | func CopyDir(source string, destination string) (err error) { 36 | 37 | // get properties of source dir 38 | sourceFile, err := os.Stat(source) 39 | if err != nil { 40 | return err 41 | } 42 | 43 | if !sourceFile.IsDir() { 44 | return &CustomError{Message: "Source is not a directory"} 45 | } 46 | 47 | // ensure destination dir does not already exist 48 | 49 | _, err = os.Open(destination) 50 | if !os.IsNotExist(err) { 51 | return &CustomError{Message: "Destination already exists"} 52 | } 53 | 54 | // create destination dir 55 | 56 | err = os.MkdirAll(destination, sourceFile.Mode()) 57 | if err != nil { 58 | return err 59 | } 60 | 61 | entries, err := ioutil.ReadDir(source) 62 | 63 | for _, entry := range entries { 64 | 65 | sourcePath := source + "/" + entry.Name() 66 | destinationPath := destination + "/" + entry.Name() 67 | if entry.IsDir() { 68 | err = CopyDir(sourcePath, destinationPath) 69 | if err != nil { 70 | log.Println(err) 71 | } 72 | } else { 73 | // perform copy 74 | err = CopyFile(sourcePath, destinationPath) 75 | if err != nil { 76 | log.Println(err) 77 | } 78 | } 79 | 80 | } 81 | return 82 | } 83 | 84 | // A struct for returning custom error messages 85 | type CustomError struct { 86 | Message string 87 | } 88 | 89 | // Returns the error message defined in Message as a string 90 | func (this *CustomError) Error() string { 91 | return this.Message 92 | } 93 | -------------------------------------------------------------------------------- /vendor/github.com/smartystreets/goconvey/web/server/watch/watch.goconvey: -------------------------------------------------------------------------------- 1 | #ignore 2 | -timeout=1s 3 | -short --------------------------------------------------------------------------------