2011-11-05 08:52:19 -04:00
|
|
|
/**
|
|
|
|
* Shared functions for MemberBuilder tests
|
|
|
|
*
|
2014-04-09 18:59:22 -04:00
|
|
|
* Copyright (C) 2011, 2013, 2014 Free Software Foundation, Inc.
|
2011-11-05 08:52:19 -04:00
|
|
|
*
|
2013-12-22 09:37:21 -05:00
|
|
|
* This file is part of GNU ease.js.
|
2011-11-05 08:52:19 -04:00
|
|
|
*
|
2014-01-15 23:56:00 -05:00
|
|
|
* ease.js is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
2011-11-05 08:52:19 -04:00
|
|
|
*
|
2014-01-15 23:56:00 -05:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2011-11-05 08:52:19 -04:00
|
|
|
*
|
2014-01-15 23:56:00 -05:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2011-11-05 08:52:19 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Perform common assertions on validator arguments
|
|
|
|
*
|
|
|
|
* @param {Object} testcase test case being executed
|
|
|
|
* @param {arguments} args arguments to check
|
|
|
|
* @param {string} name member name
|
|
|
|
* @param {*} value expected value
|
|
|
|
* @param {Object} keywords expected keywords
|
2014-01-30 23:13:52 -05:00
|
|
|
* @param {Object} state validation state
|
|
|
|
* @param {function()} prevLookup function to look up prev member data
|
2011-11-05 08:52:19 -04:00
|
|
|
*
|
|
|
|
* @return {undefined}
|
|
|
|
*/
|
2014-01-30 23:13:52 -05:00
|
|
|
exports.testArgs = function(
|
|
|
|
testcase, args, name, value, keywords, state, prevLookup
|
|
|
|
)
|
2011-11-05 08:52:19 -04:00
|
|
|
{
|
|
|
|
var prev = {
|
|
|
|
value: { expected: null, given: args[ 3 ] },
|
|
|
|
keywords: { expected: null, given: args[ 4 ] },
|
|
|
|
};
|
|
|
|
|
|
|
|
prev = prevLookup( prev, prev.value.given, prev.keywords.given );
|
|
|
|
|
|
|
|
testcase.assertEqual( name, args[ 0 ],
|
2014-01-30 23:13:52 -05:00
|
|
|
"Incorrect name passed to validator"
|
2011-11-05 08:52:19 -04:00
|
|
|
);
|
|
|
|
|
2011-11-05 09:40:56 -04:00
|
|
|
testcase.assertDeepEqual( value, args[ 1 ],
|
2014-01-30 23:13:52 -05:00
|
|
|
"Incorrect value passed to validator"
|
2011-11-05 08:52:19 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
testcase.assertStrictEqual( keywords, args[ 2 ],
|
2014-01-30 23:13:52 -05:00
|
|
|
"Incorrect keywords passed to validator"
|
2011-11-05 08:52:19 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
testcase.assertStrictEqual( prev.value.expected, prev.value.given,
|
2014-01-30 23:13:52 -05:00
|
|
|
"Previous data should contain prev value if overriding, " +
|
|
|
|
"otherwise null"
|
2011-11-05 08:52:19 -04:00
|
|
|
);
|
|
|
|
|
2011-11-05 09:40:56 -04:00
|
|
|
testcase.assertDeepEqual( prev.keywords.expected, prev.keywords.given,
|
2014-01-30 23:13:52 -05:00
|
|
|
"Previous keywords should contain prev keyword if " +
|
|
|
|
"overriding, otherwise null"
|
|
|
|
);
|
|
|
|
|
|
|
|
testcase.assertStrictEqual( state, args[ 5 ],
|
|
|
|
"State object was not passed to validator"
|
2011-11-05 08:52:19 -04:00
|
|
|
);
|
|
|
|
};
|