eyes-test.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. var util = require('util');
  2. var eyes = require('../lib/eyes');
  3. eyes.inspect({
  4. number: 42,
  5. string: "John Galt",
  6. regexp: /[a-z]+/,
  7. array: [99, 168, 'x', {}],
  8. func: function () {},
  9. bool: false,
  10. nil: null,
  11. undef: undefined,
  12. object: {attr: []}
  13. }, "native types");
  14. eyes.inspect({
  15. number: new(Number)(42),
  16. string: new(String)("John Galt"),
  17. regexp: new(RegExp)(/[a-z]+/),
  18. array: new(Array)(99, 168, 'x', {}),
  19. bool: new(Boolean)(false),
  20. object: new(Object)({attr: []}),
  21. date: new(Date)
  22. }, "wrapped types");
  23. var obj = {};
  24. obj.that = { self: obj };
  25. obj.self = obj;
  26. eyes.inspect(obj, "circular object");
  27. eyes.inspect({hello: 'moto'}, "small object");
  28. eyes.inspect({hello: new(Array)(6) }, "big object");
  29. eyes.inspect(["hello 'world'", 'hello "world"'], "quotes");
  30. eyes.inspect({
  31. recommendations: [{
  32. id: 'a7a6576c2c822c8e2bd81a27e41437d8',
  33. key: [ 'spree', 3.764316258020699 ],
  34. value: {
  35. _id: 'a7a6576c2c822c8e2bd81a27e41437d8',
  36. _rev: '1-2e2d2f7fd858c4a5984bcf809d22ed98',
  37. type: 'domain',
  38. domain: 'spree',
  39. weight: 3.764316258020699,
  40. product_id: 30
  41. }
  42. }]
  43. }, 'complex');
  44. eyes.inspect([null], "null in array");
  45. var inspect = eyes.inspector({ stream: null });
  46. util.puts(inspect('something', "something"));
  47. util.puts(inspect("something else"));
  48. util.puts(inspect(["no color"], null, { styles: false }));