1
0
mirror of https://github.com/robertkrimen/otto synced 2025-10-26 20:28:49 +08:00
Commit Graph

33 Commits

Author SHA1 Message Date
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
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
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
Steven Hartland
7ad419ed2b Merge pull request #86 from sdgoij/issue86
Fix panic: in.value.(Value) != true
2015-12-01 13:20:00 +00:00
Robert Krimen
47082f4308 Look for less than 0, not just -1
This fixes #116
2015-06-10 22:48:44 -07:00
Tim Jurcka
f7dbb7c5b3 Merge branch 'master' into issue86
Conflicts:
	bug_test.go
2014-07-03 10:43:52 +02:00
Robert Krimen
dea31a3d39 Fix behavior when breaking a loop into an outer block
This fixes #87
2014-07-02 21:33:53 -07:00
Tim Jurcka
c65402d4bf Fix panic: in.value.(Value) != true
When copying a runtime which contains objects with property accessors ({g,s}etters)

—
	$ go test -v -run=Test_issue86
	=== RUN Test_issue86
	~~~ FAIL: (Terst)
	--- FAIL: Test_issue86 (0.00 seconds)
	panic: in.value.(Value) != true [recovered]
		panic: in.value.(Value) != true [recovered]
		panic: in.value.(Value) != true

	goroutine 20 [running]:
	runtime.panic(0x2f5400, 0x2086ed7e0)
		/usr/local/go/src/pkg/runtime/panic.c:279 +0xf5
	testing.func·006()
		/usr/local/go/src/pkg/testing/testing.go:416 +0x176
	runtime.panic(0x2f5400, 0x2086ed7e0)
		/usr/local/go/src/pkg/runtime/panic.c:248 +0x18d
	_/Users/tim/repositories/github.com/sdgoij/otto/terst.func·001()
		/Users/tim/repositories/github.com/sdgoij/otto/terst/terst.go:475 +0xf5
	runtime.panic(0x2f5400, 0x2086ed7e0)
		/usr/local/go/src/pkg/runtime/panic.c:248 +0x18d
	_/Users/tim/repositories/github.com/sdgoij/otto.(*_clone).property(0x2087a6030, 0x2a0360, 0x2086ed5d0, 0x92, 0x0, 0x0, 0x0)
		/Users/tim/repositories/github.com/sdgoij/otto/clone.go:146 +0x186
	_/Users/tim/repositories/github.com/sdgoij/otto.objectClone(0x208779b60, 0x2087a8ba0, 0x2087a6030, 0x20878f4a0)
		/Users/tim/repositories/github.com/sdgoij/otto/object_class.go:471 +0x279
	_/Users/tim/repositories/github.com/sdgoij/otto.(*_clone).object(0x2087a6030, 0x208779b60, 0x208779b60)
		/Users/tim/repositories/github.com/sdgoij/otto/clone.go:87 +0xf1
	_/Users/tim/repositories/github.com/sdgoij/otto.(*_clone).value(0x2087a6030, 0x5, 0x336680, 0x208779b60, 0x0, 0x0, 0x0)
		/Users/tim/repositories/github.com/sdgoij/otto/clone.go:121 +0xb6
	_/Users/tim/repositories/github.com/sdgoij/otto.(*_clone).property(0x2087a6030, 0x341ea0, 0x2087a40a0, 0x48, 0x0, 0x0, 0x0)
		/Users/tim/repositories/github.com/sdgoij/otto/clone.go:144 +0xbc
	_/Users/tim/repositories/github.com/sdgoij/otto.objectClone(0x2086f0c00, 0x208779c80, 0x2087a6030, 0x20878f8e0)
		/Users/tim/repositories/github.com/sdgoij/otto/object_class.go:471 +0x279
	_/Users/tim/repositories/github.com/sdgoij/otto.(*_clone).object(0x2087a6030, 0x2086f0c00, 0x2087a60f0)
		/Users/tim/repositories/github.com/sdgoij/otto/clone.go:87 +0xf1
	_/Users/tim/repositories/github.com/sdgoij/otto.(*_runtime).clone(0x20873c000, 0x0)
		/Users/tim/repositories/github.com/sdgoij/otto/clone.go:29 +0x1b9
	_/Users/tim/repositories/github.com/sdgoij/otto.(*Otto).Copy(0x2086ed3c0, 0x75)
		/Users/tim/repositories/github.com/sdgoij/otto/otto.go:471 +0x2b
	_/Users/tim/repositories/github.com/sdgoij/otto.func·098()
		/Users/tim/repositories/github.com/sdgoij/otto/bug_test.go:592 +0xf5
	_/Users/tim/repositories/github.com/sdgoij/otto/terst.func·002()
		/Users/tim/repositories/github.com/sdgoij/otto/terst/terst.go:479 +0x21a
	_/Users/tim/repositories/github.com/sdgoij/otto/terst.Terst(0x20873a1b0, 0x20878ff40, 0x1, 0x1)
		/Users/tim/repositories/github.com/sdgoij/otto/terst/terst.go:480 +0x196
	_/Users/tim/repositories/github.com/sdgoij/otto.tt(0x20873a1b0, 0x20878ff40, 0x1, 0x1)
		/Users/tim/repositories/github.com/sdgoij/otto/testing_test.go:19 +0x16a
	_/Users/tim/repositories/github.com/sdgoij/otto.Test_issue86(0x20873a1b0)
		/Users/tim/repositories/github.com/sdgoij/otto/bug_test.go:594 +0x72
	testing.tRunner(0x20873a1b0, 0x6277f0)
		/usr/local/go/src/pkg/testing/testing.go:422 +0x8b
	created by testing.RunTests
		/usr/local/go/src/pkg/testing/testing.go:504 +0x8db

	goroutine 16 [chan receive]:
	testing.RunTests(0x4baf48, 0x6273a0, 0x172, 0x172, 0x1)
		/usr/local/go/src/pkg/testing/testing.go:505 +0x923
	testing.Main(0x4baf48, 0x6273a0, 0x172, 0x172, 0x6219e0, 0x3, 0x3, 0x621aa0, 0x2, 0x2)
		/usr/local/go/src/pkg/testing/testing.go:435 +0x84
	main.main()
		_/Users/tim/repositories/github.com/sdgoij/otto/_test/_testmain.go:795 +0x9c

	goroutine 19 [finalizer wait]:
	runtime.park(0x157e0, 0x629838, 0x626809)
		/usr/local/go/src/pkg/runtime/proc.c:1369 +0x89
	runtime.parkunlock(0x629838, 0x626809)
		/usr/local/go/src/pkg/runtime/proc.c:1385 +0x3b
	runfinq()
		/usr/local/go/src/pkg/runtime/mgc0.c:2644 +0xcf
	runtime.goexit()
		/usr/local/go/src/pkg/runtime/proc.c:1445
	exit status 2
	FAIL	_/Users/tim/repositories/github.com/sdgoij/otto	0.029s
2014-06-28 12:40:49 +02:00
Robert Krimen
709a0aa7ff Value.string(), .float64(), .bool(), etc. 2014-06-06 21:29:40 -07:00
Robert Krimen
b813fe3676 Fix JSON.stringify treating large integers as float64
This fixes #80
2014-06-06 21:08:59 -07:00
Robert Krimen
6c7c425424 Fix toReflectValue to handle Struct, Map, Slice, etc.
This fixes #79
2014-06-04 18:08:42 -07:00
Robert Krimen
9cd045ef04 Simplification & refactor of (parts of) the runtime
* Proper lowercasing for internal stuff
* *Environment => *_stash
* ExecutionContext => _scope
* Simpler & shallower call/construct mechanics
* Remove unnecessary fields & methods
* Better scoping (no more stack): []*_scope => _scope.outer
* Some speed improvements

In preparation for #66
2014-05-27 22:05:35 -07:00
Robert Krimen
b7dd9df181 Fix array-like handling in JSON.stringify
This fixes #73
2014-05-24 10:05:10 -07:00
Robert Krimen
ba678bc782 Use _runtime.toValue() instead of func toValue()
This fixes #72
2014-05-22 20:39:27 -07:00
Robert Krimen
470b8c3b73 terst
* Update to latest github.com/robertkrimen/terst
* Clean up testing
2014-04-25 22:48:25 -07:00
Robert Krimen
bf7b16f4a3 Add internal compilation step
* Streamline what we get from "otto/parser"
* Get rid of some "otto/parser" cruft
* FunctionExpression => FunctionLiteral
* The debugger statement (debugger) should do nothing (not panic)
* Fix aspects of function expression call evaluation
2014-04-19 14:05:51 -07:00
Robert Krimen
7163cd7841 Skip unexported fields, begin json.Marshaler support
* The "reflect" package is willing to expose unexported fields in structs (a little suprising).
* Skip unexported fields when enumerating or trying to access (pretend they don't exist).
* Allow structs that implement json.Marshaler to work as expected in a JSON.stringify call.

If we let the runtime try to access unexported fields, it'll cause a panic.

This fixes #64
2014-04-12 11:53:04 -07:00
Robert Krimen
6e3ed1b99d Tighten test comparisons instead of squashing everything to a string 2014-04-11 18:06:18 -07:00
Robert Krimen
ad8a97c028 New parser
* Faster, more straightforward, etc.
* More advanced object literals (get ..., set ...)
* More tests using JavaScript from the wild (http://cdnjs.com/)
2014-04-10 20:42:25 -07:00
Tim Jurcka
805a4c27b1 Fix redundant evaluation of test in "for" (sdgoij/MatrixFrog)
This fixes #39
2014-01-19 09:08:47 -08:00
Robert Krimen
42d674a81b Embiggen test for #24
Make sure we get back out what we put in.
2013-06-09 18:58:35 -07:00
Robert Krimen
30e4c4b96d Fix .ToValue([]string{...}).Export() to return []string{...}
This fixes #24
2013-06-06 20:18:37 -07:00
Robert Krimen
04ea4a2729 Prevent otto.Value from becoming a _goStructObject
Fix #21, this would happen during .Set(...)
2013-06-05 21:52:59 -07:00
Robert Krimen
7e2b4f2063 Rewrite of property handling to be more robust and compliant
* No more _stash
* Now using a "virtual table" system via _objectClass
* Make Array.concat GoArray compatible (via .isArray())

Fix #16
2013-05-12 14:14:51 -07:00
Robert Krimen
149f94f9fb Fix that we were using a non-runtime toValue method with go_array, go_map, and go_struct
This will fix #13
2013-04-30 00:36:46 +02:00
Robert Krimen
9184233705 Bundle terst dependency (github.com/robertkrimen/terst) 2013-04-15 10:20:34 -07:00
Robert Krimen
260b2a48bf Fix (band-aid) Go/JavaScript cross-boundary error transformation 2013-03-06 12:07:26 -08:00
Robert Krimen
d0132833fb SyntaxError => ReferenceError 2013-03-06 11:58:39 -08:00
Robert Krimen
20d2e8bba6 gofmt
Ugh.
2013-01-25 09:59:42 -08:00
Robert Krimen
7982fa0fac Fix scanning \r, \b, \f, \v as \t
Copy and paste error of epic proportions?

This will fix #5
2012-10-17 18:57:48 -07:00