mirror of
https://github.com/rails/execjs
synced 2023-03-27 23:21:20 -04:00
Test surrogate pairs
This commit is contained in:
parent
6c7d9f4818
commit
9ef1cd4a99
1 changed files with 12 additions and 0 deletions
|
@ -160,6 +160,18 @@ class TestExecJS < Test
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_surrogate_pairs
|
||||||
|
# Smiling emoji
|
||||||
|
str = ["0ff98948"].pack("h*").force_encoding("UTF-8")
|
||||||
|
assert_equal 2, ExecJS.eval("'#{str}'.length")
|
||||||
|
assert_equal str, ExecJS.eval("'#{str}'")
|
||||||
|
|
||||||
|
# US flag emoji
|
||||||
|
str = ["0ff978ab0ff9788b"].pack("h*").force_encoding("UTF-8")
|
||||||
|
assert_equal 4, ExecJS.eval("'#{str}'.length")
|
||||||
|
assert_equal str, ExecJS.eval("'#{str}'")
|
||||||
|
end
|
||||||
|
|
||||||
def test_compile_anonymous_function
|
def test_compile_anonymous_function
|
||||||
context = ExecJS.compile("foo = function() { return \"bar\"; }")
|
context = ExecJS.compile("foo = function() { return \"bar\"; }")
|
||||||
assert_equal "bar", context.exec("return foo()")
|
assert_equal "bar", context.exec("return foo()")
|
||||||
|
|
Loading…
Reference in a new issue