Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @fileoverview Library providing basic test framework functionality. | 6 * @fileoverview Library providing basic test framework functionality. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * Namespace for |Test|. | 10 * Namespace for |Test|. |
| (...skipping 1649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1660 | 1660 |
| 1661 /** | 1661 /** |
| 1662 * Builds a MatchJSON agrument matcher for a given expected value. | 1662 * Builds a MatchJSON agrument matcher for a given expected value. |
| 1663 * @param {Object} expectedValue Expected value. | 1663 * @param {Object} expectedValue Expected value. |
| 1664 * @return {MatchJSON} Resulting Mock4JS matcher. | 1664 * @return {MatchJSON} Resulting Mock4JS matcher. |
| 1665 */ | 1665 */ |
| 1666 function eqJSON(expectedValue) { | 1666 function eqJSON(expectedValue) { |
| 1667 return new MatchJSON(expectedValue); | 1667 return new MatchJSON(expectedValue); |
| 1668 } | 1668 } |
| 1669 | 1669 |
| 1670 /** | |
| 1671 * Mock4JS matcher object that matches the actual agrument and the expected | |
|
rgustafson
2013/08/29 00:07:14
argument
vadimt
2013/08/29 00:35:32
Done.
| |
| 1672 * value iff the string representation of the actual argument is equal to the | |
| 1673 * expected value. | |
| 1674 * @param {string} expectedValue Expected value. | |
| 1675 * @constructor | |
| 1676 */ | |
| 1677 function MatchToString(expectedValue) { | |
| 1678 this.expectedValue_ = expectedValue; | |
| 1679 } | |
| 1680 | |
| 1681 MatchToString.prototype = { | |
| 1682 /** | |
| 1683 * Checks that the string representation of the actual argument, and the | |
| 1684 * expected value are same. | |
| 1685 * @param {Object} actualArgument The argument to match. | |
| 1686 * @return {boolean} Result of the comparison. | |
| 1687 */ | |
| 1688 argumentMatches: function(actualArgument) { | |
| 1689 return this.expectedValue_ === actualArgument.toString(); | |
| 1690 }, | |
| 1691 | |
| 1692 /** | |
| 1693 * Describes the matcher. | |
| 1694 * @return {string} Description of this Mock4JS matcher. | |
| 1695 */ | |
| 1696 describe: function() { | |
| 1697 return 'eqToString("' + this.expectedValue_ + '")'; | |
| 1698 }, | |
| 1699 }; | |
| 1700 | |
| 1701 /** | |
| 1702 * Builds a MatchToString agrument matcher for a given expected value. | |
| 1703 * @param {Object} expectedValue Expected value. | |
| 1704 * @return {MatchToString} Resulting Mock4JS matcher. | |
| 1705 */ | |
| 1706 function eqToString(expectedValue) { | |
| 1707 return new MatchToString(expectedValue); | |
| 1708 } | |
| 1709 | |
| 1670 // Exports. | 1710 // Exports. |
| 1671 testing.Test = Test; | 1711 testing.Test = Test; |
| 1672 exports.testDone = testDone; | 1712 exports.testDone = testDone; |
| 1673 exports.assertTrue = assertTrue; | 1713 exports.assertTrue = assertTrue; |
| 1674 exports.assertFalse = assertFalse; | 1714 exports.assertFalse = assertFalse; |
| 1675 exports.assertGE = assertGE; | 1715 exports.assertGE = assertGE; |
| 1676 exports.assertGT = assertGT; | 1716 exports.assertGT = assertGT; |
| 1677 exports.assertEquals = assertEquals; | 1717 exports.assertEquals = assertEquals; |
| 1678 exports.assertLE = assertLE; | 1718 exports.assertLE = assertLE; |
| 1679 exports.assertLT = assertLT; | 1719 exports.assertLT = assertLT; |
| 1680 exports.assertNotEquals = assertNotEquals; | 1720 exports.assertNotEquals = assertNotEquals; |
| 1681 exports.assertNotReached = assertNotReached; | 1721 exports.assertNotReached = assertNotReached; |
| 1682 exports.assertAccessibilityOk = assertAccessibilityOk; | 1722 exports.assertAccessibilityOk = assertAccessibilityOk; |
| 1683 exports.callFunction = callFunction; | 1723 exports.callFunction = callFunction; |
| 1684 exports.callFunctionWithSavedArgs = callFunctionWithSavedArgs; | 1724 exports.callFunctionWithSavedArgs = callFunctionWithSavedArgs; |
| 1685 exports.callGlobalWithSavedArgs = callGlobalWithSavedArgs; | 1725 exports.callGlobalWithSavedArgs = callGlobalWithSavedArgs; |
| 1686 exports.eqJSON = eqJSON; | 1726 exports.eqJSON = eqJSON; |
| 1727 exports.eqToString = eqToString; | |
| 1687 exports.expectTrue = createExpect(assertTrue); | 1728 exports.expectTrue = createExpect(assertTrue); |
| 1688 exports.expectFalse = createExpect(assertFalse); | 1729 exports.expectFalse = createExpect(assertFalse); |
| 1689 exports.expectGE = createExpect(assertGE); | 1730 exports.expectGE = createExpect(assertGE); |
| 1690 exports.expectGT = createExpect(assertGT); | 1731 exports.expectGT = createExpect(assertGT); |
| 1691 exports.expectEquals = createExpect(assertEquals); | 1732 exports.expectEquals = createExpect(assertEquals); |
| 1692 exports.expectLE = createExpect(assertLE); | 1733 exports.expectLE = createExpect(assertLE); |
| 1693 exports.expectLT = createExpect(assertLT); | 1734 exports.expectLT = createExpect(assertLT); |
| 1694 exports.expectNotEquals = createExpect(assertNotEquals); | 1735 exports.expectNotEquals = createExpect(assertNotEquals); |
| 1695 exports.expectNotReached = createExpect(assertNotReached); | 1736 exports.expectNotReached = createExpect(assertNotReached); |
| 1696 exports.expectAccessibilityOk = createExpect(assertAccessibilityOk); | 1737 exports.expectAccessibilityOk = createExpect(assertAccessibilityOk); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 1710 exports.TEST = TEST; | 1751 exports.TEST = TEST; |
| 1711 exports.TEST_F = TEST_F; | 1752 exports.TEST_F = TEST_F; |
| 1712 exports.RUNTIME_TEST_F = TEST_F; | 1753 exports.RUNTIME_TEST_F = TEST_F; |
| 1713 exports.GEN = GEN; | 1754 exports.GEN = GEN; |
| 1714 exports.GEN_INCLUDE = GEN_INCLUDE; | 1755 exports.GEN_INCLUDE = GEN_INCLUDE; |
| 1715 exports.WhenTestDone = WhenTestDone; | 1756 exports.WhenTestDone = WhenTestDone; |
| 1716 | 1757 |
| 1717 // Import the Mock4JS helpers. | 1758 // Import the Mock4JS helpers. |
| 1718 Mock4JS.addMockSupport(exports); | 1759 Mock4JS.addMockSupport(exports); |
| 1719 })(this); | 1760 })(this); |
| OLD | NEW |