mirror of
https://github.com/robertkrimen/otto
synced 2025-10-26 20:28:49 +08:00
Remarks on UTF-8/16
This commit is contained in:
18
otto_test.go
18
otto_test.go
@@ -6,6 +6,8 @@ import (
|
||||
. "github.com/robertkrimen/terst"
|
||||
"math"
|
||||
"strings"
|
||||
"unicode/utf16"
|
||||
"unicode/utf8"
|
||||
)
|
||||
|
||||
func runTestWithOtto() (*Otto, func(string, ... interface{}) Value) {
|
||||
@@ -2004,3 +2006,19 @@ func TestAPI(t *testing.T) {
|
||||
Is(result, "30")
|
||||
}
|
||||
|
||||
func TestUnicode(t *testing.T) {
|
||||
Terst(t)
|
||||
|
||||
if false {
|
||||
// TODO This test will fail because we handle strings internally the
|
||||
// same way Go does, UTF-8
|
||||
test := runTest()
|
||||
test(`var abc = eval("\"a\uFFFFa\"");`)
|
||||
test(`abc.length`, "3")
|
||||
test(`abc != "aa"`, "true")
|
||||
test("abc[1] === \"\uFFFF\"", "true")
|
||||
dbg(utf8.RuneLen('\u000a'))
|
||||
dbg(len(utf16.Encode([]rune("a\uFFFFa"))))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user