biops.js 2.5 KB

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