Skip to content

Commit

Permalink
Merge pull request web-platform-tests#58 from zcorpan/add-argument-to…
Browse files Browse the repository at this point in the history
…-test-function

Make test(function(t) { t.add_cleanup(...) }) work
  • Loading branch information
jgraham committed Feb 3, 2014
2 parents 58e0b85 + fc74e27 commit 12a4bc0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions apisample.htm
Expand Up @@ -61,7 +61,7 @@ <h1>Sample HTML5 API Tests</h1>
assert_true(false, "false should not be true");
}
test(testAssertFalse, "assert_true expected to fail");

function basicAssertArrayEquals()
{
assert_array_equals([1, NaN], [1, NaN], "[1, NaN] is equal to [1, NaN]");
Expand Down Expand Up @@ -157,19 +157,19 @@ <h1>Sample HTML5 API Tests</h1>
async_test("async test that is never started, should have status Not Run", {timeout:1000});


test(function() {
test(function(t) {
window.global = 1;
this.add_cleanup(function() {delete window.global});
t.add_cleanup(function() {delete window.global});
assert_equals(window.global, 1);
},
"Test that defines a global and cleans it up");

test(function() {assert_equals(window.global, undefined)},
"Test that cleanup handlers from previous test ran");
test(function() {assert_equals(window.global, undefined)},
"Test that cleanup handlers from previous test ran");

</script>
</body>
</html>


2 changes: 1 addition & 1 deletion testharness.js
Expand Up @@ -439,7 +439,7 @@ policies and contribution forms [3].
var test_name = name ? name : next_default_name();
properties = properties ? properties : {};
var test_obj = new Test(test_name, properties);
test_obj.step(func);
test_obj.step(func, test_obj, test_obj);
if (test_obj.phase === test_obj.phases.STARTED) {
test_obj.done();
}
Expand Down

0 comments on commit 12a4bc0

Please sign in to comment.