1
0
mirror of https://github.com/robertkrimen/otto synced 2025-10-12 20:27:30 +08:00
Commit Graph

711 Commits

Author SHA1 Message Date
Conrad Pankoff
9fa7c0c0f8 support converting to json.RawMessage 2019-12-15 13:36:24 +11:00
Conrad Pankoff
b839e7b8bb support methods on go array values 2019-12-15 13:18:22 +11:00
Conrad Pankoff
3ef5863438 allow conversion from [u]int* to float 2019-12-15 13:18:22 +11:00
Conrad Pankoff
0f57984957 use consistent field access rules across read/write and argument conversion 2019-12-15 13:18:22 +11:00
ia
15f95af6e7 all: gofmt (#307)
Run standard gofmt command on project root.

- go version go1.10.3 darwin/amd64

Signed-off-by: ia <isaac.ardis@gmail.com>
2018-06-17 14:11:54 +01:00
deoxxa
03d472dc43 extend convertCallParameter passthrough behaviour to _goArrayObject 2018-05-06 18:43:58 +10:00
deoxxa
e335b9a887 implement TextUnmarshaller function parameter conversion 2018-05-06 18:12:42 +10:00
deoxxa
09c2169283 implement and test basic [object Object] -> struct conversion 2018-05-06 17:43:12 +10:00
deoxxa
e177400a34 fix a bug related to converting Value objects to specific interfaces 2018-05-06 14:28:05 +10:00
carterjones
6c383dd335 fix whitespace issues (#297) 2018-03-05 04:20:45 +00:00
Steven Hartland
58e9cfdd5d
Revert "Update sourcemaps to v2 (#293)" (#296)
This reverts commit 67b2826a26.
2018-03-03 15:22:00 +00:00
Eric Reis Figueiredo
67b2826a26 Update sourcemaps to v2 (#293)
Update sourcemaps to gopkg.in/sourcemap.v2 in order to avoid possible golang error discussed in #291
2018-03-03 10:15:14 +00:00
Tao Wen
3b44b4dcb6 fix idx of throw and if (#286)
* fix idx of throw and if

* add test to cover if/throw statement idx
2017-11-30 10:32:05 +00:00
deoxxa
68a29f5e29 add test for issue #269 2017-10-11 17:07:14 +11:00
Conrad Pankoff
c284572e9b Merge pull request #275 from deoxxa/implement-function-caller
implement Function.caller
2017-10-03 09:47:08 +11:00
deoxxa
eb255cd1e9 implemet Function.caller 2017-10-03 09:46:37 +11:00
Conrad Pankoff
26777b428a Merge pull request #273 from deoxxa/implement-function-name-property
implement Function.name
2017-10-03 09:45:34 +11:00
deoxxa
a4fda0adbc implement Function.name 2017-10-02 19:01:12 +11:00
Conrad Pankoff
5ff469b965 Merge pull request #274 from deoxxa/test-function-length
test Function.length
2017-10-02 18:59:00 +11:00
deoxxa
46dbeab683 test Function.length 2017-10-02 18:52:13 +11:00
leromarinvit
a813c59b1b Fix Array.splice(n) with single argument (#268) 2017-08-18 09:51:46 +01:00
Archis
fc2eb1bbf1 Added functional benchmarks (#255)
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
2017-07-21 20:43:36 +01:00
Eddy Reyes
50ed21f88e Walk/Visitor should follow Enter/Exit Pattern (#258)
* (#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`
2017-07-21 20:42:34 +01:00
Olivier Poitrey
49fee9c1c0 Add a an ast.Walk utility function (#250) 2017-06-04 11:36:02 +01:00
Archis
e1afcee0b0 Other methods callable on Maps (#254)
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
2017-06-02 10:05:44 +01:00
Wael Nasreddine
bc4cd51799 ast: ThisExpression.Idx1() should point to the end of this (#251) 2017-06-02 10:04:14 +01:00
Vincent Vanackere
21ec96599b Fix bug in runtime when exporting null|undefined to interface{} (#244) 2017-04-24 11:46:44 +01:00
Steven Hartland
1861f2408b Merge pull request #238 from veonik/no-rel-imports
Replaced './terst' relative import with qualified name.
2017-03-08 08:57:57 +00:00
Tyler Sommer
9c716adcc8 Replaced './terst' relative import with qualified name. 2017-03-07 11:15:29 -07:00
Steven Hartland
6a77b7cbc3 Merge pull request #228 from dsnet/master
Fix Test_issue80 on Go 1.8
2017-02-05 01:36:59 +00:00
Steven Hartland
20a18bbe27 Merge pull request #235 from k2wanko/fix-typo-readme
Fix typo in README
2017-02-05 01:35:47 +00:00
Robert Krimen
1c73769694 -gxc 2017-01-21 16:43:39 -08:00
Robert Krimen
c28cc513ff Merge pull request #233 from sstone1/master
Handle []uint16 to boolean conversion (resolves #232)
2017-01-21 16:34:08 -08:00
Kazuhiro Kubota
5caa170cde Fix typo 2017-01-18 17:37:52 +09:00
Robert Krimen
284b08b295 Restore .split returning a proper Array (fix #234) 2017-01-13 18:35:26 -08:00
Robert Krimen
87e059e861 Fix for S15.1.2.3_A2_T10 2017-01-12 16:21:41 -08:00
Robert Krimen
e314343b47 Fix for S15.1.2.2_A2_T10 2017-01-12 16:15:58 -08:00
Robert Krimen
54e1705423 Fix for S9.3.1_A2 2017-01-12 15:54:54 -08:00
Simon Stone
7a965dd45d Handle []uint16 to boolean conversion (resolves #232) 2016-11-24 16:28:05 +00:00
Joe Tsai
41bb429a2c Fix Test_issue80 on Go 1.8
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.
2016-11-08 13:23:43 -08:00
Conrad Pankoff
bf1c3795ba Merge pull request #219 from budadcabrion/master
fix for casting GoArrays on in convertCallParameter
2016-10-04 23:49:59 +11:00
Conrad Pankoff
bda76a056f Merge pull request #218 from dhiltonp/fastsplit
made string splits *much* faster
2016-10-04 23:46:47 +11:00
Conrad Pankoff
d5ddea59ff Merge pull request #211 from yohanbelleguic/fix-example
readme: fix "twoPlus" example function
2016-10-04 23:45:46 +11:00
jan-karl
d93f9dce58 test illustrating the issue 2016-10-01 02:50:38 -04:00
jan-karl
ea095c6386 fix for casting GoArrays on in convertCallParameter 2016-10-01 02:31:40 -04:00
David P Hilton
8b169d526d adjusted benchmark style to match call_test.go, added benchmarks for all regex-related functions. 2016-09-24 15:29:50 -06:00
David P Hilton
5bc6a83c93 added string split benchmark 2016-09-22 15:50:54 -06:00
David P Hilton
7427d59429 made string splits *much* faster 2016-09-22 14:52:38 -06:00
Conrad Pankoff
3e7ca9f192 Merge pull request #216 from hochhaus/master
Document that otto targets ES5
2016-09-19 11:00:42 +10:00
Andy Hochhaus
29f673c4d2 Document that otto targets ES5 2016-09-18 17:59:18 -07:00