blue_102584_1.js 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. function test1() { WScript.Echo(/A/.exec({})); };
  6. function test2() { WScript.Echo("".match({})); };
  7. function test2() { WScript.Echo("".indexOf({})); };
  8. function test3() { WScript.Echo("".match()); };
  9. function test4() { WScript.Echo("a".match(/a/g)); };
  10. function test5() { WScript.Echo("A".replace("C", {})); };
  11. function test6() { WScript.Echo("A".replace("C")); };
  12. function test7() { WScript.Echo("A".replace()); };
  13. function test8() { "A".replace({}, "C"); };
  14. function test9() { WScript.Echo("ABCDEF".replace({}, "DEF")); };
  15. function test10() { WScript.Echo('fafafa'.replace({}, "X")); };
  16. function test11() { var a = {}; WScript.Echo("Aundefined".replace(a.x, Array.isArray)); };
  17. function test12() { WScript.Echo("Aundefined".replace("undefined", function (a) { return a == "Aundefined"; })); };
  18. function test13() { var o = {}; WScript.Echo(/A/.exec(o.x)); };
  19. function test14() { var strvar7 = 'a'; WScript.Echo(strvar7.replace(1, 1).replace(1, 1)); };
  20. function test15() { var o = {}; WScript.Echo("".match(o.x)); };
  21. function test16() { try { WScript.Echo(String.prototype.match.call(null, o)); } catch(ex) {WScript.Echo('expected : ' + ex.message);}};
  22. function test17() { try { WScript.Echo(String.prototype.match.apply(Array.a, "a")); } catch(ex) {WScript.Echo('expected : ' + ex.message);}};
  23. function test18() { try { WScript.Echo(String.prototype.match.call("a")); } catch(ex) {WScript.Echo('expected : ' + ex.message);}};
  24. function test19() { try { var o = {}; WScript.Echo(String.prototype.replace.call(null, o)); } catch(ex) {WScript.Echo('expected : ' + ex.message);}};
  25. function test20() { try { WScript.Echo(String.prototype.replace.call(Array.a, "a")); } catch(ex) {WScript.Echo('expected : ' + ex.message);}};
  26. function test21() { WScript.Echo(String.prototype.replace.call("a", String.foo)); };
  27. function test22() { try { var o = {}; WScript.Echo(RegExp.prototype.exec.call(null, o.x)); } catch(ex) {WScript.Echo('expected : ' + ex.message);}};
  28. function test23() { try { WScript.Echo(RegExp.prototype.exec.apply(Array.a, "a")); } catch(ex) {WScript.Echo('expected : ' + ex.message);}};
  29. function test24() { try {WScript.Echo(RegExp.prototype.exec.call("a")); } catch(ex) {WScript.Echo('expected : ' + ex.message);}};
  30. test1(); test1();
  31. test2(); test2();
  32. test3(); test3();
  33. test4(); test4();
  34. test5(); test5();
  35. test6(); test6();
  36. test7(); test7();
  37. test8(); test8();
  38. test9(); test9();
  39. test10(); test10();
  40. test11(); test11();
  41. test12(); test12();
  42. test13(); test13();
  43. test14(); test14();
  44. test15(); test15();
  45. test16(); test16();
  46. test17(); test17();
  47. test18(); test18();
  48. test19(); test19();
  49. test20(); test20();
  50. test21(); test21();
  51. test22(); test22();
  52. test23(); test23();
  53. test24(); test24();
  54. String.prototype.match = function(x) { WScript.Echo(x instanceof RegExp); return []; }
  55. test2();
  56. String.prototype.replace = function(x) { WScript.Echo(x instanceof Object); return []; }
  57. test9();