From aae7d8190b26b12486a6e225cc026abca6d5d91b Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Sat, 13 Dec 2014 12:40:43 +1100 Subject: [PATCH] fix up tests to work with the new method binding operator --- .../bin/6to5/stdin --filename/stderr.txt | 2 +- .../fixtures/bin/6to5/stdin --filename/stdin.txt | 4 ++-- .../transformation/errors/syntax/actual.js | 2 +- .../transformation/errors/syntax/options.json | 2 +- .../playground/method-binding/actual.js | 16 ++++++++-------- .../playground/method-binding/exec.js | 12 ++++++------ test/transformation.js | 4 +++- 7 files changed, 22 insertions(+), 20 deletions(-) diff --git a/test/fixtures/bin/6to5/stdin --filename/stderr.txt b/test/fixtures/bin/6to5/stdin --filename/stderr.txt index 40674d06f1..70be01b6f3 100644 --- a/test/fixtures/bin/6to5/stdin --filename/stderr.txt +++ b/test/fixtures/bin/6to5/stdin --filename/stderr.txt @@ -1 +1 @@ -SyntaxError: test.js: Unexpected character '#' +SyntaxError: test.js: Unexpected token (2:10) diff --git a/test/fixtures/bin/6to5/stdin --filename/stdin.txt b/test/fixtures/bin/6to5/stdin --filename/stdin.txt index 6b84913768..1d931c7e85 100644 --- a/test/fixtures/bin/6to5/stdin --filename/stdin.txt +++ b/test/fixtures/bin/6to5/stdin --filename/stdin.txt @@ -1,3 +1,3 @@ -arr.map(x => { - $#! +arr.map(function () { + return $]!; }); diff --git a/test/fixtures/transformation/errors/syntax/actual.js b/test/fixtures/transformation/errors/syntax/actual.js index 1ef7cb5d40..1d931c7e85 100644 --- a/test/fixtures/transformation/errors/syntax/actual.js +++ b/test/fixtures/transformation/errors/syntax/actual.js @@ -1,3 +1,3 @@ arr.map(function () { - return $#!; + return $]!; }); diff --git a/test/fixtures/transformation/errors/syntax/options.json b/test/fixtures/transformation/errors/syntax/options.json index 72ad0f0daf..7c05159f45 100644 --- a/test/fixtures/transformation/errors/syntax/options.json +++ b/test/fixtures/transformation/errors/syntax/options.json @@ -1,3 +1,3 @@ { - "throws": "Unexpected character '#'" + "throws": "Unexpected token (2:10)" } diff --git a/test/fixtures/transformation/playground/method-binding/actual.js b/test/fixtures/transformation/playground/method-binding/actual.js index 1457513da0..12185e1a7c 100644 --- a/test/fixtures/transformation/playground/method-binding/actual.js +++ b/test/fixtures/transformation/playground/method-binding/actual.js @@ -1,13 +1,13 @@ -var fn = obj:method; -var fn = obj:method("foob"); -var fn = obj[foo]:method; -var fn = obj.foo:method; -var fn = obj[foo()]:method; +var fn = obj#method; +var fn = obj#method("foob"); +var fn = obj[foo]#method; +var fn = obj.foo#method; +var fn = obj[foo()]#method; -["foo", "bar"].map(:toUpperCase); -[1.1234, 23.53245, 3].map(:toFixed(2)); +["foo", "bar"].map(#toUpperCase); +[1.1234, 23.53245, 3].map(#toFixed(2)); var get = function () { return 2; }; -[1.1234, 23.53245, 3].map(:toFixed(get())); +[1.1234, 23.53245, 3].map(#toFixed(get())); diff --git a/test/fixtures/transformation/playground/method-binding/exec.js b/test/fixtures/transformation/playground/method-binding/exec.js index 77a2949ab4..b83e4b49aa 100644 --- a/test/fixtures/transformation/playground/method-binding/exec.js +++ b/test/fixtures/transformation/playground/method-binding/exec.js @@ -12,19 +12,19 @@ var obj = { } }; -var foo = obj:getFoo; +var foo = obj#getFoo; assert.equal(foo(), "foo"); -var bar = obj:getBar("foo"); +var bar = obj#getBar("foo"); assert.equal(bar(), "foo bar"); -var zoo = obj:getZoo("foo"); +var zoo = obj#getZoo("foo"); assert.equal(zoo("bar"), "foo bar foo bar"); -assert.deepEqual(["foo", "bar"].map(:toUpperCase), ["FOO", "BAR"]); -assert.deepEqual([1.1234, 23.53245, 3].map(:toFixed(2)), ["1.12", "23.53", "3.00"]); +assert.deepEqual(["foo", "bar"].map(#toUpperCase), ["FOO", "BAR"]); +assert.deepEqual([1.1234, 23.53245, 3].map(#toFixed(2)), ["1.12", "23.53", "3.00"]); var get = function () { return 2; } -assert.deepEqual([1.1234, 23.53245, 3].map(:toFixed(get())), ["1.12", "23.53", "3.00"]); +assert.deepEqual([1.1234, 23.53245, 3].map(#toFixed(get())), ["1.12", "23.53", "3.00"]); diff --git a/test/transformation.js b/test/transformation.js index 03418d0f83..ca03b78af1 100644 --- a/test/transformation.js +++ b/test/transformation.js @@ -77,7 +77,9 @@ _.each(helper.get("transformation"), function (testSuite) { // the options object with useless options delete task.options.throws; - assert.throws(runTask, new RegExp(throwMsg)); + assert.throws(runTask, function (err) { + return err.message.indexOf(throwMsg) >= 0; + }); } else { runTask(); }