1
0
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:
Robert Krimen
2012-10-17 11:54:04 -07:00
parent 474a473e36
commit ed98144c35
5 changed files with 40 additions and 0 deletions

View File

@@ -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"))))
}
}