Editing teststoring This edit will create a new revision. Your details (optional) Name Email (won’t be displayed; might be used for Gravatar) URL Test case details Title * Published (uncheck if you want to fiddle around before making the page public) Description (in case you feel further explanation is needed)(Markdown syntax is allowed) Are you a spammer? (just answer the question) Preparation code Preparation code HTML (this will be inserted in the <body> of a valid HTML5 document in standards mode) (useful when testing DOM operations or including libraries) <script> var Store = function Store() { var values = []; var keys = []; var remove = function remove(array, from, to) { var rest = array.slice((to || from) + 1 || array.length); array.length = from < 0 ? array.length + from : from; return array.push.apply(array, rest); }; var removeItem = function removeItem(index) { remove(values, index); remove(keys, index); }; var addItem = function addItem(key, val) { values.push(val); keys.push(key); }; var keyIndex = function keyIndex(key) { var val; for (var i = 0, len = keys.length; i < len; i++) { if (keys[i] === key) { val = i; } } return val; }; this.get = function(key) { var val; for (var i = 0, len = keys.length; i < len; i++) { if (keys[i] === key) { val = values[i]; } } return val; }; this.set = function(key, val) { var index = keyIndex(key); if (index > -1) { removeItem(index); } addItem(key, val); }; }; var SimpleStore = function SimpleStore(){ var store = {}; this.get = function get(key){ return store[key]; }; this.set = function set(key, val){ store[key] = val; }; }; var a = new Store(); var b = new SimpleStore(); a.set('apple1', {}); a.set('apple2', {}); a.set('apple3', {}); b.set('apple1', {}); b.set('apple2', {}); b.set('apple3', {}); </script> Include JavaScript libraries as follows: <script src="//cdn.ext/library.js"></script> Define setup for all tests (variables, functions, arrays or other objects that will be used in the tests) (runs before each clocked test loop, outside of the timed code region) (e.g. define local test variables, reset global variables, clear canvas, etc.) (see FAQ) Define teardown for all tests (runs after each clocked test loop, outside of the timed code region) (see FAQ) Code snippets to compare Test 1 Title Async (check if this is an asynchronous test) Code a.get('apple1'); a.get('apple2'); a.get('apple3'); Test 2 Title Async (check if this is an asynchronous test) Code b.get('apple1'); b.get('apple2'); b.get('apple3');