Commit 6e2f3e9d authored by Stefan Cameron's avatar Stefan Cameron

Finished implementing impl.check*() functions

Very preliminary/cursory check: it works!!!

For example, this validates successful:

```javascript
rtv.check({
  finite: 5,
  string: ''
}, {
  finite: rtv.t.FINITE,
  string: [rtv.q.EXPECTED, rtv.t.STRING]
});
```

Unit tests remain now, to get back to 100% coverage.
parent 1a518364
......@@ -36,15 +36,15 @@ Shapes must be:
- [ ] Add a ONE_OF type to check the value is in an enumeration (array of values) -- or make this part of STRING or NUMBER args?
- [ ] Add a convenience method to check values rather than an object with a shape, as in `rtv.check(value, TYPE | array)`, internally can wrap in an object with a single property and then send through normal channels
- [ ] Must have a good error stack output in both string (p1.p2[4].p3...) and object for programmatic interpretation
- [ ] Need `from/toJSON()` methods to de/serialize, which can be customized to handle property validators.
- [ ] Need `from/toJSON()` methods to de/serialize, which can be customized to handle custom validators.
- [ ] Remember that `undefined` cannot be allowed in shape descriptions because that value isn't JSON-serializable -- update docs? -- it's the typeset as a whole (including nested objects) that must be serializable, although CLASS_OBJECT_args would not be with the 'ctr' property because that must be a ref to a function... perhaps emit a warning during serialization (with `toJSON()` override) if this is encountered...
- [ ] Debug the generated docs (including private docs), checking for broken links...
- [ ] Typesets:
- [x] When add support for 'validator functions', will have to allow `CLASS_OBJECT` type to be followed by `null` if it's the last type in the typeset so that `[CLASS_OBJECT, null, v => v.foo === 'bar']` is properly interpreted as a generic class object with a custom validator. Otherwise, `[CLASS_OBJECT, v => v.foo === 'bar']` would be forcibly interpreted as a class object which is an instance of a function that takes a parameter and returns a boolean... Hopefully this is the only place where `null` would be permitted in a typeset/shape description. Make sure this is documented somewhere. -- solved this with `rtvref.types.CLASS_OBJECT_args`
- [ ] Throw an error if a type in a typeset array is not an accepted typeset kind (object, string, array, function), except if the type is `CLASS_OBJECT` and it's followed by `null` (per the exception above).
- [ ] Throw an error if a property in a shape descriptor is not an accepted typeset kind (object, string, array, function).
- [ ] Property validator function's typeset parameter should always be a fully-expanded typeset...
- [ ] When typeset is an array, any nested shape descriptor must always be preceded by a type, even if it's the default OBJECT type, __unless__ it's the first element, at which point the default `OBJECT` type is implied (this is so we can keep the short form of `[[shape]]` to describe a list of objects with a particular shape). Throw an error if the first element in a typeset array is not a string (i.e. a type or a qualifier). It could also be a function to allow a property validator, like `[[v => v === 'foo']]` (a list of elements equal to 'foo'...).
- [ ] Custom validator function's typeset parameter should always be a fully-expanded typeset...
- [ ] When typeset is an array, any nested shape descriptor must always be preceded by a type, even if it's the default OBJECT type, __unless__ it's the first element, at which point the default `OBJECT` type is implied (this is so we can keep the short form of `[[shape]]` to describe a list of objects with a particular shape). Throw an error if the first element in a typeset array is not a string (i.e. a type or a qualifier). It could also be a function to allow a custom validator, like `[[v => v === 'foo']]` (a list of elements equal to 'foo'...).
- [ ] The algorithm should short-circuit type checks in a typeset as soon as the first type-to-value match is found within a typeset array (i.e. don't go into nested arrays/shapes if a simpler type match was found prior to it within the typeset -- just call the validator, if any, immediately and exit).
- [x] Add linting: ESLint
- [x] Add unit test system: Mocha + Chai
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
////// Enumeration
import {print} from './util';
/**
* Simple enumeration type. Own-properties on an instance are the keys in the
* specified `map`, with their associated values.
* specified `map`, with their associated values. Key names cannot start with
* "$".
*
* <pre><code>const state = new Enumeration({
* READY: 1,
......@@ -22,13 +25,17 @@
* @class rtvref.Enumeration
* @param {Object.<String,*>} map Object mapping keys to values. Values cannot
* be `undefined`.
* @param {string} [name] Friendly name used to identify this enumeration,
* especially in validation error messages.
* @throws {Error} If `map` is falsy or empty.
* @throws {Error} If `map` has a key that maps to `undefined`.
* @throws {Error} If `map` contains a duplicate value.
* @throws {Error} If `map` has a key that is a restricted property (starts with
* "$").
*/
export default class Enumeration {
// JSDoc is provided at the @class level
constructor(map) {
constructor(map, name) {
map = map || {};
const keys = Object.keys(map);
......@@ -40,19 +47,37 @@ export default class Enumeration {
// shallow-clone each key in the map into this
keys.forEach((key) => {
if (key.indexOf('$') === 0) {
throw new Error(`map key "${key}" cannot start with "$"`);
}
if (map[key] === undefined) {
throw new Error('map[' + key + '] cannot be undefined');
throw new Error(`map[${key}] cannot be undefined`);
}
const value = map[key];
if (values.indexOf(value) >= 0) {
throw new Error('map[' + key + '] is a duplicate value: ' + value);
throw new Error(`map[${key}] is a duplicate value: ${print(value)}`);
}
values.push(value);
this[key] = value;
});
/**
* Friendly name (not necessarily unique among all enumeration instances)
* used to identify this enumeration, especially in validation error
* messages. Empty string if not specified during construction.
* @readonly
* @name rtvref.Enumeration#$name
* @type {string}
*/
Object.defineProperty(this, '$name', {
enumerable: false,
configurable: true,
value: (name && print(name)) || ''
});
/**
* List of enumeration values. Values are _references_ to values in this
* enumeration.
......@@ -62,7 +87,7 @@ export default class Enumeration {
*
* @readonly
* @name rtvref.Enumeration#$values
* @type Array.<String>
* @type {Array.<String>}
*/
Object.defineProperty(this, '$values', {
enumerable: false,
......@@ -105,7 +130,7 @@ export default class Enumeration {
const result = this.check(value);
if (result === undefined && !silent) {
throw new Error('Invalid value for enum[' + this.$values.join(', ') + ']: ' + value);
throw new Error(`Invalid value for ${this.$name ? `${this.$name} ` : ''}enum[${this.$values.map(print).join(', ')}]: ${print(value)}`);
}
return result;
......@@ -118,6 +143,6 @@ export default class Enumeration {
*/
toString() {
const pairs = Object.keys(this).map((k) => [k, this[k]]);
return `{rtvref.Enumeration pairs=[${pairs.map((p) => `[${p}]`).join(', ')}]}`;
return `{rtvref.Enumeration $name="${this.$name}" pairs=[${pairs.map((p) => `[${print(p)}]`).join(', ')}]}`;
}
}
......@@ -8,6 +8,13 @@ import {print} from './util';
// @type {function} The super class.
const extendsFrom = Error;
// Renders a path array as a string.
// @param {Array.<string>} path
// @returns {string}
const renderPath = function(path) {
return `/${path.join('/')}`;
};
/**
* @external JS_Error
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error
......@@ -40,15 +47,15 @@ const RtvError = function(value, typeset, path, cause) {
// by checking the prototype chain, which isn't properly constructed.
if (!isTypeset(typeset)) {
throw new Error('Invalid typeset: ' + typeset);
throw new Error(`Invalid typeset: ${print(typeset)}`);
}
if (!isArray(path)) {
throw new Error('Invalid path: ' + path);
throw new Error(`Invalid path: ${print(path)}`);
}
if (!isTypeset(cause, {fullyQualified: true})) {
throw new Error('Invalid cause (expecting a fully-qualified typeset): ' + cause);
throw new Error(`Invalid cause (expecting a fully-qualified typeset): ${print(cause)}`);
}
// NOTE: For some reason, calling `extendsFrom.call(this, message)` has
......@@ -56,7 +63,7 @@ const RtvError = function(value, typeset, path, cause) {
// or there's something strange about the built-in Error type, so we just
// call the super's constructor as a formality.
extendsFrom.call(this);
this.message = `Verification failed: value=${value}, path=${path}`;
this.message = `Verification failed: value=${print(value)}, path="${renderPath(this.path)}"`;
this.name = 'RtvError';
Object.defineProperties(this, {
......@@ -102,7 +109,8 @@ const RtvError = function(value, typeset, path, cause) {
},
/**
* Path from `value` to the nested property that caused the failure.
* Path from `value` to the nested property that caused the failure. This
* is a shallow clone of the original `path` specified.
* @readonly
* @name rtvref.RtvError#path
* @type {Array.<string>}
......@@ -149,7 +157,7 @@ RtvError.prototype.constructor = RtvError;
* @returns {string} String representation.
*/
RtvError.prototype.toString = function() {
return `{rtvref.RtvError value=${print(this.value)}, path="${this.path.join('/')}"}`;
return `{rtvref.RtvError value=${print(this.value)}, path="${renderPath(this.path)}"}`;
};
export default RtvError;
This diff is collapsed.
......@@ -75,4 +75,4 @@ export default new Enumeration({
REQUIRED,
EXPECTED,
OPTIONAL
});
}, 'qualifiers');
......@@ -165,16 +165,16 @@ import Enumeration from './Enumeration';
* {@link rtvref.types.FINITE FINITE} for a finite number. Must be one of the types
* defined in {@link rtvref.types}.
* - {@link rtvref.types.FUNCTION Function}: For a
* {@link rtvref.types.property_validator property validator} that will verify the value of the
* {@link rtvref.types.custom_validator custom validator} that will verify the value of the
* property using custom code. Since the Array form is not being used (only the validator is
* being provided), it's always invoked immediately. Since a type is not provided, the
* {@link rtvref.types.ANY ANY} type is implied.
* - {@link rtvref.types.ARRAY Array}: For multiple type possibilities, optionally
* {@link rtvref.qualifiers qualified}, using an __OR__ conjunction, which means the value of
* the property being described must match at _least one_ of the types listed, but not all.
* Matching is done in a short-circuit fashion, from the first to the last element in the typeset.
* If a simpler type is likely, it's more performant to specify it first/earlier in the typeset
* to avoid a match attempt on a nested shape or Array.
* {@link rtvref.qualifiers qualified}, using a short-circuit __OR__ conjunction, which means
* the value of the property being described must match _at least one_ of the types listed, but
* not all. Matching is done in a short-circuit fashion, from the first to the last element in
* the typeset. If a simpler type is a more likely match, it's more performant to specify it
* first/earlier in the typeset to avoid a match attempt on a nested shape or Array.
* - Cannot be an empty Array.
* - A given type may not be included more than once in the typeset, but may appear
* again in a nested typeset (when a parent typeset describes an
......@@ -197,7 +197,7 @@ import Enumeration from './Enumeration';
* or an array of non-empty strings or finite numbers. See the `ARRAY` type
* reference for more information on _shorthand_ and _full_ notations.
* - If an element is a `Function`, it must be the __last__ element in the Array
* and will be treated as a {@link rtvref.types.property_validator property validator}.
* and will be treated as a {@link rtvref.types.custom_validator custom validator}.
* Only one validator can be specified for a given typeset (additional validators
* may appear in nested typesets).
*
......@@ -292,7 +292,7 @@ import Enumeration from './Enumeration';
*
* A {@link rtvref.types.typeset typeset} expressed without any shortcut notations
* or implied/default types to make it easier to parse, especially as the `match`
* parameter given to a {@link rtvref.types.property_validator property validator}.
* parameter given to a {@link rtvref.types.custom_validator custom validator}.
* A fully-qualified typeset always uses the array notation, and has a single
* {@link rtvref.qualifiers qualifier} as its first element, followed by
* at least one type, and at most one validator.
......@@ -308,37 +308,44 @@ import Enumeration from './Enumeration';
*/
/**
* <h3>Property Validator</h3>
* <h3>Custom Validator</h3>
*
* A function used as a {@link rtvref.types.typeset typeset}, or as a subset to
* a typeset, to provide custom verification of the value being verified.
*
* A typeset may only have one validator, and the validator is only called if
* the value being verified was verified by at least one type in the typeset.
* A typeset may only have one validator, and the validator is _only called if
* the value being verified was verified by at least one type in the typeset_.
* The validator must be the __last__ element within the typeset (if the typeset
* is an array, and a validator is needed). The validator must also be
* specified _after_ the {@link rtvref.qualifiers qualifier} in a typeset Array.
* The validator is invoked immediately after the first type match, but only if
* a type match is made. If the typeset is not
*
* The validator is invoked immediately after the first type match, but _only if
* a type match is made_. If the typeset is not
* {@link rtvref.types.fully_qualified_typeset fully-qualified} and does not
* explicitly specify a type, the {@link rtvref.types.ANY ANY} type is implied.
* explicitly specify a type, the {@link rtvref.types.ANY ANY} type is implied,
* which will match _any_ value, which means the validator will always be called.
*
* There is one disadvantage to using a property validator: It cannot be de/serialized
* There is one disadvantage to using a custom validator: It cannot be de/serialized
* via JSON, which means it cannot be transmitted or persisted. One option would be
* to customize the de/serialization to JSON by serializing the validator to a
* special object with properties that would inform the deserialization process
* on how to reconstruct the validator dynamically.
*
* @typedef {function} rtvref.types.property_validator
* @typedef {function} rtvref.types.custom_validator
* @param {*} value The value being verified.
* @param {Array} match A __first-level__, {@link rtvref.types.fully_qualified_typeset fully-qualified}
* typeset describing the type that matched. This means the first level of this
* subset of `typeset` (the 3rd parameter) is fully-qualified, but any nested
* {@link rtvref.shape_descriptor shape descriptors} or arrays will not be (they
* will remain references to the same shapes/arrays in `typeset`). For example,
* if the given typeset was `[PLAIN_OBJECT, {note: STRING}]`, this parameter
* would be a new typeset array `[REQUIRED, PLAIN_OBJECT, {note: STRING}]`,
* will remain references to the same shapes/arrays in `typeset`).
*
* For example, if the given typeset was `[PLAIN_OBJECT, {note: STRING}]`, this
* parameter would be a new typeset array `[REQUIRED, PLAIN_OBJECT, {note: STRING}]`,
* and the `typeset` parameter would be the original `[PLAIN_OBJECT, {note: STRING}]`.
*
* If the given typeset was `[STRING, FINITE]` and FINITE matched, this parameter
* would be `[REQUIRED, FINITE]` and the `typeset` parameter would be the
* original `[STRING, FINITE]`.
* @param {rtvref.types.typeset} typeset Reference to the typeset used for
* verification. Note that the typeset may contain nested typeset(s), and may
* be part of a larger parent typeset (though there would be no reference to
......@@ -376,7 +383,7 @@ const defs = {
* - OPTIONAL: Since this qualifier removes the property's need for existence
* in the prototype chain, it renders the verification moot (i.e. the property
* might as well not be included in the {@link rtvref.shape_descriptor shape descriptor}
* unless a {@link rtvref.types.property_validator property validator} is being
* unless a {@link rtvref.types.custom_validator custom validator} is being
* used to do customized verification.
*
* @name rtvref.types.ANY
......@@ -986,7 +993,7 @@ export const objTypes = new Enumeration(function() {
}
});
return types;
}());
}(), 'objTypes');
/**
* Enumeration (`string -> string`) of {@link rtvref.types types} that accept
......@@ -1002,7 +1009,7 @@ export const argTypes = new Enumeration(function() {
}
});
return types;
}());
}(), 'argTypes');
/**
* Enumeration (`string -> string`) of all {@link rtvref.types types}.
......@@ -1015,4 +1022,4 @@ export default new Enumeration(function() {
types[name] = defs[name].value;
});
return types;
}());
}(), 'types');
......@@ -77,8 +77,9 @@ export default function isTypeset(v, {deep = false, fullyQualified = false} = {}
}
} else if (isFunction(rule)) {
// must be a validator, but there can't be more than 1, it must be
// in the last position (and always after the qualifier), and since
// the typeset must be FQ'd, we must have an in-scope type
// in the last position (which enforces the 1 count), always after the
// qualifier, and since the typeset must be FQ'd, we must have an
// in-scope type
valid = !!(curType && (i + 1 === v.length));
} else if (isObject(rule)) {
// could be a shape, or type args (either way, it's a single object)
......@@ -178,7 +179,8 @@ export default function isTypeset(v, {deep = false, fullyQualified = false} = {}
}
} else if (isFunction(rule)) {
// must be a validator, but there can't be more than 1, and it must be
// in the last position (and always after the qualifier, if any)
// in the last position (which enforces the 1 count), and always after
// the qualifier (if any)
valid = (i + 1 === v.length);
if (valid && !curType) {
// if we have a validator but no in-scope type, ANY is implied
......
......@@ -11,7 +11,7 @@ export const type = types.ANY;
/**
* {@link rtvref.validator.validator_config Configuration Function}
* @function rtvref.validator.isAny.config
* @param {Object} settings Standard configuration settings.
* @param {rtvref.validator.validator_config_settings} settings Configuration settings.
*/
export const config = function(settings) {
};
......
......@@ -13,7 +13,7 @@ export const type = types.ANY_OBJECT;
/**
* {@link rtvref.validator.validator_config Configuration Function}
* @function rtvref.validator.isAnyObject.config
* @param {Object} settings Standard configuration settings.
* @param {rtvref.validator.validator_config_settings} settings Configuration settings.
*/
export const config = function(settings) {
};
......
......@@ -16,7 +16,7 @@ export const type = types.ARRAY;
/**
* {@link rtvref.validator.validator_config Configuration Function}
* @function rtvref.validator.isArray.config
* @param {Object} settings Standard configuration settings.
* @param {rtvref.validator.validator_config_settings} settings Configuration settings.
*/
export const config = function(settings) {
};
......
......@@ -11,7 +11,7 @@ export const type = types.BOOLEAN;
/**
* {@link rtvref.validator.validator_config Configuration Function}
* @function rtvref.validator.isBoolean.config
* @param {Object} settings Standard configuration settings.
* @param {rtvref.validator.validator_config_settings} settings Configuration settings.
*/
export const config = function(settings) {
};
......
......@@ -14,7 +14,7 @@ export const type = types.FINITE;
/**
* {@link rtvref.validator.validator_config Configuration Function}
* @function rtvref.validator.isFinite.config
* @param {Object} settings Standard configuration settings.
* @param {rtvref.validator.validator_config_settings} settings Configuration settings.
*/
export const config = function(settings) {
};
......
......@@ -13,7 +13,7 @@ export const type = types.FUNCTION;
/**
* {@link rtvref.validator.validator_config Configuration Function}
* @function rtvref.validator.isFunction.config
* @param {Object} settings Standard configuration settings.
* @param {rtvref.validator.validator_config_settings} settings Configuration settings.
*/
export const config = function(settings) {
};
......
......@@ -20,7 +20,7 @@ export const type = types.MAP;
/**
* {@link rtvref.validator.validator_config Configuration Function}
* @function rtvref.validator.isMap.config
* @param {Object} settings Standard configuration settings.
* @param {rtvref.validator.validator_config_settings} settings Configuration settings.
*/
export const config = function(settings) {
impl = settings.impl;
......
......@@ -15,7 +15,7 @@ export const type = types.NUMBER;
/**
* {@link rtvref.validator.validator_config Configuration Function}
* @function rtvref.validator.isNumber.config
* @param {Object} settings Standard configuration settings.
* @param {rtvref.validator.validator_config_settings} settings Configuration settings.
*/
export const config = function(settings) {
};
......
......@@ -22,7 +22,7 @@ export const type = types.OBJECT;
/**
* {@link rtvref.validator.validator_config Configuration Function}
* @function rtvref.validator.isObject.config
* @param {Object} settings Standard configuration settings.
* @param {rtvref.validator.validator_config_settings} settings Configuration settings.
*/
export const config = function(settings) {
};
......
......@@ -13,7 +13,7 @@ export const type = types.REGEXP;
/**
* {@link rtvref.validator.validator_config Configuration Function}
* @function rtvref.validator.isRegExp.config
* @param {Object} settings Standard configuration settings.
* @param {rtvref.validator.validator_config_settings} settings Configuration settings.
*/
export const config = function(settings) {
};
......
......@@ -19,7 +19,7 @@ export const type = types.SET;
/**
* {@link rtvref.validator.validator_config Configuration Function}
* @function rtvref.validator.isSet.config
* @param {Object} settings Standard configuration settings.
* @param {rtvref.validator.validator_config_settings} settings Configuration settings.
*/
export const config = function(settings) {
impl = settings.impl;
......
......@@ -14,7 +14,7 @@ export const type = types.STRING;
/**
* {@link rtvref.validator.validator_config Configuration Function}
* @function rtvref.validator.isString.config
* @param {Object} settings Standard configuration settings.
* @param {rtvref.validator.validator_config_settings} settings Configuration settings.
*/
export const config = function(settings) {
};
......
......@@ -13,7 +13,7 @@ export const type = types.SYMBOL;
/**
* {@link rtvref.validator.validator_config Configuration Function}
* @function rtvref.validator.isSymbol.config
* @param {Object} settings Standard configuration settings.
* @param {rtvref.validator.validator_config_settings} settings Configuration settings.
*/
export const config = function(settings) {
};
......
......@@ -13,7 +13,7 @@ export const type = types.WEAK_MAP;
/**
* {@link rtvref.validator.validator_config Configuration Function}
* @function rtvref.validator.isWeakMap.config
* @param {Object} settings Standard configuration settings.
* @param {rtvref.validator.validator_config_settings} settings Configuration settings.
*/
export const config = function(settings) {
};
......
......@@ -13,7 +13,7 @@ export const type = types.WEAK_SET;
/**
* {@link rtvref.validator.validator_config Configuration Function}
* @function rtvref.validator.isWeakSet.config
* @param {Object} settings Standard configuration settings.
* @param {rtvref.validator.validator_config_settings} settings Configuration settings.
*/
export const config = function(settings) {
};
......
......@@ -80,6 +80,16 @@
* and args, a _falsy_ value to reject.
*/
/**
* <h3>Type Validation Configuration Settings</h3>
*
* The settings provided to the
* {@link rtvref.validator.validator_config configuration function}.
*
* @typedef {Object} rtvref.validator.validator_config_settings
* @property {rtvref.impl} impl Reference to the `impl` module.
*/
// TODO: Is it good to expose the entire impl module to _any_ type validator,
// even third-party plugin validators in the future? Should we, instead, provide
// a series of function references without stating where they come from (even
......@@ -95,7 +105,6 @@
* internal utilities.
*
* @function rtvref.validator.validator_config
* @param {Object} settings Configuration settings.
* @param {rtvref.impl} settings.impl Reference to the `impl` module.
* @param {rtvref.validator.validator_config_settings} settings Configuration settings.
*/
......@@ -44,12 +44,18 @@ describe('module: lib/Enumeration', function() {
}).to.throw(/cannot be undefined/);
});
it('should prevent duplication values', function() {
it('should prevent duplicate values', function() {
expect(function() {
new Enumeration({foo: 1, bar: 1});
}).to.throw(/duplicate value/);
});
it('should disallow keys that begin with "$"', function() {
expect(function() {
new Enumeration({$foo: 1});
}).to.throw(/cannot start with "\$"/);
});
it('should allow a null value', function() {
expect(function() {
new Enumeration({foo: null});
......@@ -105,6 +111,27 @@ describe('module: lib/Enumeration', function() {
const str = en + '';
expect(str).not.to.equal({} + ''); // not the default serialization
expect(str).to.contain('Enumeration');
expect(str).to.contain('$name=""');
expect(str).to.contain('pairs=');
});
it('should default to an empty name', function() {
expect(en.$name).to.equal('');
});
it('should have a non-enumerable, read-only "$name" property', function() {
const desc = Object.getOwnPropertyDescriptor(en, '$name');
expect(desc.enumerable).to.be.false;
expect(desc.configurable).to.be.true;
expect(desc.writable).to.be.false;
});
it('should use its name in validation error messages', function() {
const en2 = new Enumeration({a: 1}, 'foo');
const str = en2 + '';
expect(str).to.contain('$name="foo"');
expect(function() {
en2.verify(2);
}).to.throw(/for foo enum/);
});
});
......@@ -77,7 +77,9 @@ describe('module: lib/impl', function() {
});
});
describe('#_getCheckOptions()'); // TODO
describe('#_getCheckOptions()', function() {
it('// TODO');
});
describe('#check()', function() {
it('should return an RtvSuccess on successful validation'); // TODO
......@@ -118,10 +120,16 @@ describe('module: lib/impl', function() {
});
it('should return an RtvError if a value is not verified against a type'); // TODO
it('should use the options.qualifier if specified, only for non-array typesets'); // TODO
});
describe('#checkShape()'); // TODO
describe('#checkTypeset()'); // TODO
describe('#checkShape()', function() {
it('// TODO');
});
describe('#checkTypeset()', function() {
it('// TODO');
});
describe('#fullyQualify()', function() {
it('should FQ string typesets', function() {
......@@ -194,5 +202,7 @@ describe('module: lib/impl', function() {
expect(function() { impl.fullyQualify(new Map()); }).to.throw(re);
expect(function() { impl.fullyQualify(Symbol('asdf')); }).to.throw(re);
});
it('should accept a qualifier override'); // TODO
});
});
......@@ -10,6 +10,7 @@ describe('module: lib/qualifiers', function() {
it('should export a "qualifiers" enumeration', function() {
expect(qualifiers instanceof Enumeration).to.equal(true);
expect(qualifiers.$name).to.equal('qualifiers');
});
it('should export a default qualifier', function() {
......
......@@ -10,6 +10,7 @@ describe('module: lib/types', function() {
it('should export a "types" enumeration', function() {
expect(types instanceof Enumeration).to.equal(true);
expect(types.$name).to.equal('types');
});
it('should export a default object type', function() {
......@@ -37,6 +38,7 @@ describe('module: lib/types', function() {
];
expect(_.difference(mod.objTypes.$values, knownTypes)).to.eql([]);
expect(mod.objTypes.$name).to.equal('objTypes');
});
it('should export an enumeration of all types that accept arguments', function() {
......@@ -60,5 +62,6 @@ describe('module: lib/types', function() {
];
expect(_.difference(mod.argTypes.$values, knownTypes)).to.eql([]);
expect(mod.argTypes.$name).to.equal('argTypes');
});
});
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment