mirror of
https://github.com/rails/execjs
synced 2023-03-27 23:21:20 -04:00
commit
4f613fed79
1 changed files with 14 additions and 1 deletions
|
@ -101,7 +101,8 @@ class TestExecJS < Test
|
|||
"\\",
|
||||
"café",
|
||||
"☃",
|
||||
["0ff98948"].pack("h*").force_encoding("UTF-8"), # Smiling emoji
|
||||
"\u{1f604}".encode("UTF-8"), # Smiling emoji
|
||||
"\u{1f1fa}\u{1f1f8}".encode("UTF-8"), # US flag
|
||||
[1, 2, 3],
|
||||
[1, [2, 3]],
|
||||
[1, [2, [3]]],
|
||||
|
@ -160,6 +161,18 @@ class TestExecJS < Test
|
|||
end
|
||||
end
|
||||
|
||||
def test_surrogate_pairs
|
||||
# Smiling emoji
|
||||
str = "\u{1f604}".encode("UTF-8")
|
||||
assert_equal 2, ExecJS.eval("'#{str}'.length")
|
||||
assert_equal str, ExecJS.eval("'#{str}'")
|
||||
|
||||
# US flag emoji
|
||||
str = "\u{1f1fa}\u{1f1f8}".encode("UTF-8")
|
||||
assert_equal 4, ExecJS.eval("'#{str}'.length")
|
||||
assert_equal str, ExecJS.eval("'#{str}'")
|
||||
end
|
||||
|
||||
def test_compile_anonymous_function
|
||||
context = ExecJS.compile("foo = function() { return \"bar\"; }")
|
||||
assert_equal "bar", context.exec("return foo()")
|
||||
|
|
Loading…
Reference in a new issue