test.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. ;(function() {
  2. var console = {}
  3. , files = __TESTS__;
  4. console.log = function(text) {
  5. var args = Array.prototype.slice.call(arguments, 1)
  6. , i = 0;
  7. text = text.replace(/%\w/g, function() {
  8. return args[i++] || '';
  9. });
  10. if (window.console) window.console.log(text);
  11. document.body.innerHTML += '<pre>' + escape(text) + '</pre>';
  12. };
  13. if (!Object.keys) {
  14. Object.keys = function(obj) {
  15. var out = []
  16. , key;
  17. for (key in obj) {
  18. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  19. out.push(key);
  20. }
  21. }
  22. return out;
  23. };
  24. }
  25. if (!Array.prototype.forEach) {
  26. Array.prototype.forEach = function(callback, context) {
  27. for (var i = 0; i < this.length; i++) {
  28. callback.call(context || null, this[i], i, obj);
  29. }
  30. };
  31. }
  32. if (!String.prototype.trim) {
  33. String.prototype.trim = function() {
  34. return this.replace(/^\s+|\s+$/g, '');
  35. };
  36. }
  37. function load() {
  38. return files;
  39. }
  40. function escape(html, encode) {
  41. return html
  42. .replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&amp;')
  43. .replace(/</g, '&lt;')
  44. .replace(/>/g, '&gt;')
  45. .replace(/"/g, '&quot;')
  46. .replace(/'/g, '&#39;');
  47. }
  48. (__MAIN__)();
  49. }).call(this);