From: Zhiyi Zhang <zzhang@codeweavers.com> --- dlls/jscript/tests/lang.js | 122 +++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) diff --git a/dlls/jscript/tests/lang.js b/dlls/jscript/tests/lang.js index 89f52298fb3..73fe0a06d57 100644 --- a/dlls/jscript/tests/lang.js +++ b/dlls/jscript/tests/lang.js @@ -2162,3 +2162,125 @@ function test_es5_keywords() { ok(tmp === true, "Expected exception for 'const c1 = 1;'"); } test_es5_keywords(); + +function test_identifers() { + valid_tests = ['$', + '_', + 'a$', + 'a_', + // Unicode categories + 'A', // Lu: Letter, Uppercase + '_A', + 'a', // Ll: Letter, Lowercase + '_a', + '\\u01c5', // Lt: Letter, Titlecase + '_\\u01c5', + '_\\u0300', // Mn: Mark, Non-Spacing + '_\\u20dd', // Me: Mark, Enclosing + '_1', // Nd: Number, Decimal Digit + '\\u2160', // Nl: Number, Letter + '_\\u2160', + '\\u02b0', // Lm: Letter, Modifier + '_\\u02b0', + '\\u04c0', // Lo: Letter, Other + '_\\u04c0', + '_\\u203f', // Pc: Punctuation, Connector + '_\\u301c', // Pd: Punctuation, Dash + '_\\u0f3a', // Ps: Punctuation, Open + '_\\u0f3b', // Pe: Punctuation, Close + '_\\u00ab', // Pi: Punctuation, Initial quote + '_\\u2e02', + '_\\u00bb', // Pf: Punctuation, Final quote + '_\\u2e0a', + '_\\u00a1', // Po: Punctuation, Other + '_\\u3001', + '_\\u00ac', // Sm: Symbol, Math + '_\\u2044', + '_\\u00a2', // Sc: Symbol, Currency + '_\\u20a0', + '_\\u00a8', // Sk: Symbol, Modifier + '_\\u02c2', + '_\\u00a6', // So: Symbol, Other + '_\\u0482']; + invalid_tests = ['v\\u0061r', + // Unicode categories + '\\u0300', // Mn: Mark, Non-Spacing + '\\u093e', // Mc: Mark, Spacing Combining + '\\u20dd', // Me: Mark, Enclosing + '1', // Nd: Number, Decimal Digit + '\\u00b2', // No: Number, Other + '\\u2460', + '\\u009f', // Cc: Other, Control + '_\\u009f', + '\\u200c', // Cf: Other, Format + '_\\u200c', + '\\ud800', // Cs: Other, Surrogate + '_\\ud800', + '\\ue000', // Co: Other, Private Use + '_\\ue000', + '\\u203f', // Pc: Punctuation, Connector + '\\u301c', // Pd: Punctuation, Dash + '\\u0f3a', // Ps: Punctuation, Open + '\\u0f3b', // Pe: Punctuation, Close + '\\u00ab', // Pi: Punctuation, Initial quote + '\\u2e02', + '\\u00bb', // Pf: Punctuation, Final quote + '\\u2e0a', + '\\u00a1', // Po: Punctuation, Other + '\\u3001', + '\\u00ac', // Sm: Symbol, Math + '\\u2044', + '\\u00a2', // Sc: Symbol, Currency + '\\u20a0', + '\\u00a8', // Sk: Symbol, Modifier + '\\u02c2', + '\\u00a6', // So: Symbol, Other + '\\u0482']; + + var \u0061 = 1; + ok(\u0061 === 1, "\u0061 != 1"); + ok(a === 1, "a != 1"); + + var b = 1; + ok(b === 1, "b != 1"); + ok(\u0062 === 1, "\u0062 != 1"); + + var m\u0079 = 1; + ok(m\u0079 === 1, "m\u0079 != 1"); + ok(my === 1, "my != 1"); + + tmp = false + try { + eval('\\u0076ar c = 1;'); + } + catch(e) { + tmp = true + } + ok(tmp === true, 'Expected exception for \\u0076ar c = 1;'); + + tmp = false + try { + eval('v\\u0061r d = 1;'); + } + catch(e) { + tmp = true + } + ok(tmp === true, 'Expected exception for v\\u0061r d = 1;'); + + for(i=0; i<valid_tests.length; i++) { + eval('var ' + valid_tests[i] + ' = 1;'); + eval('ok(' + valid_tests[i] + ' === 1, "' + valid_tests[i] + ' != 1");'); + } + + for(i=0; i<invalid_tests.length; i++) { + tmp = false + try { + eval('var ' + invalid_tests[i] + ' = 1;'); + } + catch(e) { + tmp = true + } + ok(tmp === true, 'Expected exception for var ' + invalid_tests[i] + ' = 1;'); + } +} +test_identifers(); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/11452