This change adds two types of tests:
1. First some regular Test* tests that functionally
ensure the test cases are correct.
2. A few Benchmark* tests that then allow us to
measure Otto's performance under various functional scenarios.
The basic tests are just sorting, but I'm planning over time
to bring in more advanced tests (like the CryptoAES) from
popular benchmarking suites (JetStream for instance.)
I intend to run profiler on these tests to find any
ottlenecks or low-hanging fruit that can help speed up
Otto for real-world use-cases.
Next up after this is to add some heavy underscorejs
benchmarks.
Responding to PR comments
* (#257) Change Walk/Visit to follow an explicit Enter/Exit pattern
* (#257) Convert walk example into test.
* (#257) restore walk/visitor example
* (#257) Fix godoc comment in the Visitor interface
... typo referred to `End` method instead of `Exit`
Background:
When methods are attached on a map type like so:
type Foo map[string]string
func (f Foo) Bar() {
fmt.Printf("Hello World");
}
vm := otto.New();
vm.Set("foo", Foo{});
vm.Run(`
foo.Bar();
`);
You get:
Error in Run: TypeError: 'Bar' is not a function
The Fix:
I looked into how/why the same works for arrays. After
all array properties are tested (such as length, and any integer-based members),
the code then looks for any methods attached to that type.
This change literally copies that code over into
maps.
This is very useful when working with the http.Request object which
has the http.Header type that is a map[string][]string, with a lot
of useful methods attached to it.
Added unit test to support/guard the change (and map had no test before)
Responded to PR comments
An upstream change (http://golang.org/cl/30371) makes the Go encoder
to be more compliant with the ES6 standard. Ironically, this change
causes Test_issue80 to fail on the larger number ranges.
To make this test work on both Go 1.7 and Go 1.8, we delete the larger
value tests, which are arguably locking in the wrong behavior.
* add benchmarks and tests for native function calls
* improve conversion of various native function parameters
* add support for more types of native function parameters
* improve performance of most parameter types