UIZE JavaScript Framework

TO DO - Uize.Is

This is a proposal document for a Uize.Is module.

The Uize.Is module would provide methods for testing if values meet various test criteria.

1. Examples of Methods

Uize.Is.nonNull
Uize.Is.anInstanceOf (classOBJ)
Uize.Is.ofType (typeSTR)
Uize.Is.anArray
Uize.Is.aBoolean
Uize.Is.aString
Uize.Is.aNumber
Uize.Is.aFunction
Uize.Is.anObject
Uize.Is.aRegExp
Uize.Is.arrayLike
Uize.Is.inRange (min,max)
Uize.Is.negative
Uize.Is.positive
Uize.Is.inLengthRange (min,max)
Uize.Is.nonEmpty
Uize.Is.anInteger
Uize.Is.evenNumber
Uize.Is.oddNumber
Uize.Is.arrayWithNoRepeats

2. Other Possibles

Uize.Is.greaterThan
Uize.Is.lessThan
Uize.Is.emailAddress
Uize.Is.Url
Uize.Is.Color

3. Semantics for Test vs Make Tester

3.1. Test

Uize.Is.inRange (value,0,100)

3.2. Make Tester

function (value) {return Uize.Is.inRange (value,0,100)}

Uize.Is.inRange.fn (0,100)
Uize.Is.inRange.tester (0,100)
Uize.Is.inRange.test (0,100)
Uize.Is.inRange.match (0,100)
Uize.Is.inRange.matcher (0,100)
Uize.Is.inRange.value (0,100)

Uize.Is.inRange.make (0,100)
Uize.Is.inRange.capture (0,100)
Uize.Is.inRange.freeze (0,100)

Uize.Is.inRange._(0,100)
Uize.Is.inRange ['...'] (0,100)
Uize.Is.inRange ['?'] (0,100)
Uize.Is.inRange.x (0,100)

3.3. More Thoughts on Make Tester

Uize.Is.instanceOf (myInstance,Uize.Widget.FormElement)
Uize.Is.instanceOf (Uize.Widget.FormElement) (myInstance)
Uize.Is.instanceOf.tester (Uize.Widget.FormElement)

4. Migration of Uize.Test Expectations

MAPPINGS

expectNotIdentical     -->  Uize.Is.notIdenticalTo
expectSameAs           -->  Uize.Is.sameAs
expectNotSameAs        -->  Uize.Is.notSameAs
expectNonNull          -->  Uize.Is.nonNull
expectNully            -->  Uize.Is.nully
expectInstanceOf       -->  Uize.Is.anInstanceOf
expectType             -->  Uize.Is.ofType
expectArray            -->  Uize.Is.anArray
expectBoolean          -->  Uize.Is.aBoolean
expectFunction         -->  Uize.Is.aFunction
expectNumber           -->  Uize.Is.aNumber
expectObject           -->  Uize.Is.anObject
expectRegExp           -->  Uize.Is.aRegExp
expectString           -->  Uize.Is.aString
expectArrayLike        -->  Uize.Is.arrayLike
expectInRange          -->  Uize.Is.inRange
expectNumberInRange    -->  Uize.Is.aNumberInRange
expectLengthInRange    -->  Uize.Is.itsLengthInRange
expectEmpty            -->  Uize.Is.empty
expectNonEmpty         -->  Uize.Is.nonEmpty
expectInteger          -->  Uize.Is.anInteger
expectIntegerInRange   -->  Uize.Is.anIntegerInRange
expectNegativeInteger  -->  Uize.Is.aNegativeInteger
expectPositiveInteger  -->  Uize.Is.aPositiveInteger
expectNoRepeats        -->  Uize.Is.nonRepeating
expectEmptyArray       -->  Uize.Is.anEmptyArray
expectNonEmptyArray    -->  Uize.Is.aNonEmptyArray
expectEmptyObject      -->  Uize.Is.anEmptyObject
expectNonEmptyObject   -->  Uize.Is.aNonEmptyObject
expectEmptyString      -->  Uize.Is.anEmptyString
expectNonEmptyString   -->  Uize.Is.aNonEmptyString

EXAMPLE USAGE

var
  is = Uize.Is,
  aNumberOrString = is.anyOf (is.aNumber,is.aString)
;

var _test = Uize.Test.resolve ({
  title:'Foo.bar is not a number or a string',
  test:function () {
    return this.expect (is.not (aNumberOrString),Foo.bar);
  }
})

5. - when a test fails, it should be possible to obtain a summary of where it failed

what is the implication of this for composition of tests?
how can one support this capability while still making simple matcher type tests performant?

6. Summarizing Test Compositions

The summarize method would attempt to serialize any function type arguments using a summarize method, if present on the functions.

COMPOSITION

is.anyOf (is.aNumber,is.aString,is.aBoolean)

SUMMARY

Uize.Is.anyOf (x,Uize.Is.aNumber (x),Uize.Is.aString (x),Uize.Is.aBoolean (x))

COMPOSITION

is.allOf (is.anObject,is.hasProperties (['foo','bar']))

SUMMARY

Uize.Is.allOf (x,Uize.Is.anObject (x),Uize.Is.hasProperties (x,'foo','bar'))