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U,OACX,GAAU,MAAP,EAAa,0BAEhB,GAAU,MAAP,GAAe,OAAO,UAAU,SAAS,KAAK,GAAK,MAAM,GAAI,GAAG,eAAiB,EAAK,cAE7F,CAOA,SAAS,QAAQ,EAAM,EAAK,GAC1B,GAAG,EAAM,EAAK,CACZ,IAAI,EAAI,EACR,EAAM,EACN,EAAO,CACT,CAEA,GAAG,GAAQ,GAAO,GAAQ,EAAM,0BAA0B,EAAI,IAAI,EACpE,CAOA,SAAS,MAAM,EAAM,EAAK,GACP,iBAAP,IACR,EAAM,IAAI,OAAO,EAAK,IAGxB,GAAsB,MAAnB,EAAK,MAAM,GAAc,qBAAqB,EAEnD,CAGA,MAAM,OAAQ,MAAO,CAYnB,MAAO,SAAS,EAAQ,EAAU,EAAe,GAC/C,IAAI,EAAU,IAAW,GAAa,KAAK,IAAI,EAAS,IAAa,EACrE,MAAM,KAAK,EAAQ,EAAQ,EAAU,EACvC,EAaA,SAAU,SAAS,EAAQ,EAAU,EAAe,GAClD,MAAM,KAAK,KAAK,IAAI,EAAS,GAAY,EAAe,EAAQ,EAAU,EAC5E","file":"/npm/entity@0.0.0/public/qunit/qunit.entity.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/entity@0.0.0/public/qunit/qunit.entity.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","ETest = function(){\n};\n\nETest.prototype.push = function(){\n  var that = this;\n  if(QUnit.config.blocking){\n    that.run();\n  } else {\n    QUnit.config.queue.unshift(function(){\n      that.run();\n    });\n  }\n};\n\nETest.prototype.run = function(){\n  ok(this.check(), this.message);\n};\n\n/*\nExpects a trigger call from the given obj.\n\nvar e = re.e('flicker');\n\nexpectTrigger(e, 'flicker:finish', function(){\n  //if triggered this will be called\n});\n\nvar e = re.e('counter');\n\n//expect given arguments\nexpectTrigger(e, 'maxed', [10]);\n\n*/\nfunction expectTrigger(obj, trigger, func){\n  var trig = new ETest();\n  trig.called = 0;\n  trig.message = \"Expected \"+trigger+\" to be triggered\";\n  \n  trig.check = function(){\n    return this.called;\n  };\n  \n  trig.meth = function(){\n    trig.called++;\n    \n    if(typeof func == 'object'){\n      \n      var args = Array.prototype.slice.call(arguments, 0);\n      \n      ok(!(args>func || args<func), \"trigger \"+trigger+\" should have same arguments\");\n      \n    } else if(typeof func == 'function'){\n      func.apply(obj, arguments);\n    }\n  };\n  \n  obj.on(trigger, trig.meth);\n  \n  trig.push();\n};\n\nfunction expectValueUp(obj, prop){\n  var trig = new ETest();\n  trig.message = \"Expected \"+prop+\" to value up\";\n  trig.old = obj[prop];\n  \n  trig.check = function(){\n    return this.old < obj[prop];\n  };\n  \n  trig.push();\n};\n\nfunction expectValueDown(obj, prop){\n  var trig = new ETest();\n  trig.message = \"Expected \"+prop+\" to value down\";\n  trig.old = obj[prop];\n  \n  trig.check = function(){\n    return this.old > obj[prop];\n  };\n  \n  trig.push();\n};\n\n/*\n\nre.e('circle')\n.set('color', '#ff0000');\n\npixelEqual(10, 10, 255, 0, 0, 0);\n\n*/\nfunction pixelEqual(x, y, r, g, b, a, message){\n  var actual = Array.prototype.slice.apply(re.loop().context.getImageData(x, y, 1, 1).data), expected = [r, g, b, a];\n\tQUnit.push(QUnit.equiv(actual, expected), actual, expected, message);\n}\n\n/*\nExpects an entity or component to have a current event attached.\n\nvar e = re.e();\n\nexpectEvent(e, 'update'); //false\n\ne.on('update', function(){\n  \n});\n\nexpectEvent(e, 'update') //true\n\n*/\nfunction expectEvent(ent, trigger, func){\n  if(arguments.length == 2){\n    ok(ent.has('^'+trigger), \"Expected entity to have event \"+trigger);\n  } else {\n    var fin = false;\n    for(var i in ent._re_signals[trigger]){\n      fin = (ent._re_signals[trigger][i] == func)\n      if(fin) break;\n    }\n    \n    ok(fin, \"Expected entity to have event \"+trigger+\" with function\");\n    \n  }\n}\n\n/*\nGenerates a factory for creating complex entities.\n\n//create coin factory\nfactory('coin', function(){\n  //set values on the newly created coin\n  this.value = 10;\n  \n  //has all normal methods\n  this.def('blah', 10);\n  this.on('update', function(){\n  });\n});\n\n//create coin\nvar e = factory('coin');\ne.value // 10\ne.has('coin') //true\n\n//can also use f\nvar coin2 = f('coin');\ncoin2.value //10\n\n//create coin with custom factory\n//still has other defines properties\n\nvar customCoin = f('coin', function(){\n  this.getValue = function(){\n    return this.value;\n  };\n});\n\ncustomCoin.value //10\ncustomCoin.getValue(); //10\n\n//create custom enemy\n\ntest('blah', function(){\n  \n  enemy = f('enemy', {health:100, attack:10});\n\n});\n\n*/\nvar _factories = {};\nfunction factory(comps, func){\n  //define new factory\n  if(func && !_factories[comps]){\n    _factories[comps] = func;\n    \n  } else {\n    //create\n    var e = re.e(comps);\n    \n    //call defined factory\n    if(_factories[comps]) _factories[comps].call(e);\n    \n    //add custom attributes\n    if(typeof func == 'object') e.set(func);\n\n    //call custom method\n    if(func) func.call(e);\n    return e;\n  }\n}\nvar f = factory;\n\n/*\nGenerates a factory entity for easy use in the module()\n\n//light weight\n//a new coin in coin will be created for every test()\nmodule('coin', lazy('coin'));\n\n//do something after coin creation\nmodule('coin', lazy('coin', function(e){\n  //called on coin creation.\n}));\n\n//setup teardown methods together\nmodule('coin', lazy('coin', {\nsetup:function(e){\n  //called on coin creation.\n},\nteardown:function(e){\n  //called after each test\n}\n}));\n\ntest('coin should have valid of 10', function(){\n  equal(coin.value, 10);\n})\n\netc..\n\n*/\nfunction lazy(comps, obj){\n  var name;\n  if(typeof comps == 'string') comps = comps.split(' ');\n  name = comps[0];\n  var e;\n  \n  return {\n    setup:function(){\n      \n      this[name] = e = f(comps.join(' '));\n      \n      if(typeof obj == 'function') obj(e);\n      if(obj && obj.setup) obj.setup(e);\n    },\n    teardown:function(){\n      if(obj && obj.teardown) obj.teardown(e);\n      e.dispose();\n    }\n  }\n}\n\n/*\n  Simple scene testing.\n\n  module('scenes/home', lazyScene('home', 'hello'));\n  \n  //goes into home..\n  //re.scene('home').enter('hello');\n  test('shows title', function(){\n    eq(re('text').first().text(), 'hello');\n  });\n  //afterwards\n  //re.scene('home').exit();\n*/\nfunction lazyScene(scene){\n  var args = Array.prototype.slice.call(arguments, 1);\n  return {\n    setup:function(){\n      var s = this.scene = re.scene(scene);\n\n      s.enter.apply(s, args);\n    },\n    teardown:function(){\n      this.scene.exit();\n    }\n  };\n};\n\n/*\nSome super lazy evaluations\n*/\nvar eq = equal;\nvar not = function(arg, message){ok(!arg, message);}\n\n/*\nObject exists or is of type.\n\nis({}, 'object');\nis(null) //false\nis(1)\nis('sdsf', 'string') //true\n*/\nfunction is(obj, type){\n  if(arguments.length == 1){\n    ok(obj != null, \"Expected to be present\");\n  } else{\n    ok(obj != null && Object.prototype.toString.call(obj).slice(8, -1).toLowerCase() == type.toLowerCase())\n  }\n}\n\n/*\nBetween or equal to two numbers\n\nbetween(10, 30, 90)\n*/\nfunction between(test, low, high){\n  if(low > high){\n    var t = low;\n    low = high;\n    high = t;\n  }\n\n  ok(test >= low && test <= high, \"Expected to be between \"+low+\"-\"+high);\n}\n\n/*\nMatches a regular expression\n\nmatch('hello', /h/, 'i');\n*/\nfunction match(test, reg, i){\n  if(typeof reg == 'string'){\n    reg = new RegExp(reg, i)\n  }\n  \n  ok(test.match(reg) != null, \"Expected to match \"+reg)\n  \n}\n\n\nQUnit.extend( QUnit, {\n  /**\n   * Checks that the first two arguments are equal, or are numbers close enough to be considered equal\n   * based on a specified maximum allowable difference.\n   *\n   * @example close(3.141, Math.PI, 0.001);\n   *\n   * @param Number actual\n   * @param Number expected\n   * @param Number maxDifference (the maximum inclusive difference allowed between the actual and expected numbers)\n   * @param String message (optional)\n   */\n  close: function(actual, expected, maxDifference, message) {\n    var passes = (actual === expected) || Math.abs(actual - expected) <= maxDifference;\n    QUnit.push(passes, actual, expected, message);\n  },\n\n  /**\n   * Checks that the first two arguments are numbers with differences greater than the specified\n   * minimum difference.\n   *\n   * @example notClose(3.1, Math.PI, 0.001);\n   *\n   * @param Number actual\n   * @param Number expected\n   * @param Number minDifference (the minimum exclusive difference allowed between the actual and expected numbers)\n   * @param String message (optional)\n   */\n  notClose: function(actual, expected, minDifference, message) {\n    QUnit.push(Math.abs(actual - expected) > minDifference, actual, expected, message);\n  }\n});"]}