biops.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 write(v) {
  6. v = (v + "").replace(/\(PST\)/g, "(Pacific Standard Time)")
  7. .replace(/\(PDT\)/g, "(Pacific Daylight Time)");
  8. WScript.Echo(v);
  9. }
  10. function foo() {}
  11. var d = new Date("Thu Aug 5 05:30:00 PDT 2010");
  12. var all = [ undefined, null,
  13. true, false,
  14. Boolean(true), Boolean(false),
  15. new Boolean(true), new Boolean(false),
  16. NaN, +0, -0, 0, 0.0, -0.0, +0.0,
  17. 1, 10, 10.0, 10.1, -1,
  18. -10, -10.0, -10.1,
  19. Number.MAX_VALUE, Number.MIN_VALUE, Number.NaN, Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY,
  20. new Number(NaN), new Number(+0), new Number(-0), new Number(0),
  21. new Number(0.0), new Number(-0.0), new Number(+0.0),
  22. new Number(1), new Number(10), new Number(10.0), new Number(10.1), new Number(-1),
  23. new Number(-10), new Number(-10.0), new Number(-10.1),
  24. new Number(Number.MAX_VALUE), new Number(Number.MIN_VALUE), new Number(Number.NaN),
  25. new Number(Number.POSITIVE_INFINITY), new Number(Number.NEGATIVE_INFINITY),
  26. "", "0xa", "04", "hello", "hel" + "lo",
  27. String(""), String("hello"), String("h" + "ello"),
  28. new String(""), new String("hello"), new String("he" + "llo"),
  29. new Object(), new Object(),
  30. [1,2,3], [1,2,3],
  31. new Array(3), Array(3), new Array(1, 2, 3), Array(1),
  32. foo, d, 1281011400000 , d.getVarDate()
  33. ];
  34. var biops = [
  35. "*", "/", "%", // 11.5 Multiplicative operators
  36. "+", "-", // 11.6 Addtitive operators
  37. "<<", ">>", ">>>", // 11.7 Bitwise shift operators
  38. "<", ">", "<=", ">=", // 11.8 Relational operators
  39. "==", "!=", "===", "!==", // 11.9 Equality operators
  40. "&", "^", "|", // 11.10 Binary bitwise operators
  41. "&&", "||" // 11.11 Binary logical operators
  42. ];
  43. for (var op in biops) {
  44. for (var i=0; i<all.length; ++i) {
  45. for (var j=0; j<all.length; ++j) {
  46. write("a["+i+"]("+all[i]+") "+biops[op]+" a["+j+"]("+all[j]+") = " + eval("all[i] " + biops[op] + " all[j];"));
  47. }
  48. }
  49. }