Skip to content

Commit

Permalink
Move thallium/assert implementation out of core
Browse files Browse the repository at this point in the history
  • Loading branch information
dead-claudia committed Jan 9, 2017
1 parent 692471b commit 7412ded
Show file tree
Hide file tree
Showing 35 changed files with 66 additions and 3,130 deletions.
7 changes: 5 additions & 2 deletions .gitignore
@@ -1,5 +1,8 @@
/node_modules

# Tooling stuff
npm-debug.log
.eslintcache
/npm-debug.log
/.eslintcache

# Generated stuff
/assert.d.ts
4 changes: 3 additions & 1 deletion .npmignore
@@ -1,6 +1,5 @@
# General dev crap
/appveyor.yml
/bench
/coffeelint.json
/fixtures
/karma.conf.js
Expand All @@ -16,3 +15,6 @@
# Any incomplete, in-progress feature goes here.
/r/dom.js
/r/dom.d.ts

# Specific exclusion because it's used for post-install.
!/scripts/update-clean-assert.js
2 changes: 0 additions & 2 deletions CONTRIBUTING.md
Expand Up @@ -83,8 +83,6 @@ Note that I don't actually test the documentation's code, but please ensure it o

- `lib` - The core of this project. Many public API modules are just thin wrappers for something in here, including the main export.

- `lib/assert` - The built-in assertions. Most of these are re-exported under the same name.

- `lib/api` - The core API. Both the primary `t` and `reflect` APIs are defined here.

- `lib/core` - The core test state and execution logic. Handle with care, since it's probably the most heavily used. Bugs in this can and often will affect seemingly unrelated tests. Also, the report types are defined here.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -31,7 +31,7 @@ tl

Couple specific notes:

1. I plan to make this a very batteries-included framework. It includes several useful utilities like an assertion library far more helpful than Node's `assert` (you can define your own ad-hoc assertions, even - I do it in the tests themselves).
1. I plan to make this a very batteries-included framework. It includes several useful utilities like an assertion library far more helpful than Node's `assert` (you can easily define your own ad-hoc assertions, even - I do it in the tests themselves).

2. Not much configuration is required to get started. I aim for ease of use and convention over configuration, but I also try to enable as much flexibility as you need. Your config file can even return a promise, if that's what you need.

Expand Down
163 changes: 0 additions & 163 deletions assert.d.ts

This file was deleted.

131 changes: 1 addition & 130 deletions assert.js
@@ -1,132 +1,3 @@
"use strict"

/**
* Core TDD-style assertions. These are done by a composition of DSLs, since
* there is *so* much repetition. Also, this is split into several namespaces to
* keep the file size manageable.
*/

var Util = require("./lib/assert/util")
var Type = require("./lib/assert/type")
var Equal = require("./lib/assert/equal")
var Throws = require("./lib/assert/throws")
var Has = require("./lib/assert/has")
var Includes = require("./lib/assert/includes")
var HasKeys = require("./lib/assert/has-keys")

exports.AssertionError = Util.AssertionError
exports.assert = Util.assert
exports.fail = Util.fail
exports.format = Util.format
exports.escape = Util.escape

exports.ok = Type.ok
exports.notOk = Type.notOk
exports.isBoolean = Type.isBoolean
exports.notBoolean = Type.notBoolean
exports.isFunction = Type.isFunction
exports.notFunction = Type.notFunction
exports.isNumber = Type.isNumber
exports.notNumber = Type.notNumber
exports.isObject = Type.isObject
exports.notObject = Type.notObject
exports.isString = Type.isString
exports.notString = Type.notString
exports.isSymbol = Type.isSymbol
exports.notSymbol = Type.notSymbol
exports.exists = Type.exists
exports.notExists = Type.notExists
exports.isArray = Type.isArray
exports.notArray = Type.notArray
exports.is = Type.is
exports.not = Type.not

exports.equal = Equal.equal
exports.notEqual = Equal.notEqual
exports.equalLoose = Equal.equalLoose
exports.notEqualLoose = Equal.notEqualLoose
exports.deepEqual = Equal.deepEqual
exports.notDeepEqual = Equal.notDeepEqual
exports.match = Equal.match
exports.notMatch = Equal.notMatch
exports.atLeast = Equal.atLeast
exports.atMost = Equal.atMost
exports.above = Equal.above
exports.below = Equal.below
exports.between = Equal.between
exports.closeTo = Equal.closeTo
exports.notCloseTo = Equal.notCloseTo

exports.throws = Throws.throws
exports.throwsMatch = Throws.throwsMatch

exports.hasOwn = Has.hasOwn
exports.notHasOwn = Has.notHasOwn
exports.hasOwnLoose = Has.hasOwnLoose
exports.notHasOwnLoose = Has.notHasOwnLoose
exports.hasKey = Has.hasKey
exports.notHasKey = Has.notHasKey
exports.hasKeyLoose = Has.hasKeyLoose
exports.notHasKeyLoose = Has.notHasKeyLoose
exports.has = Has.has
exports.notHas = Has.notHas
exports.hasLoose = Has.hasLoose
exports.notHasLoose = Has.notHasLoose

/**
* There's 2 sets of 12 permutations here for `includes` and `hasKeys`, instead
* of N sets of 2 (which would fit the `foo`/`notFoo` idiom better), so it's
* easier to just make a couple separate DSLs and use that to define everything.
*
* Here's the top level:
*
* - shallow
* - strict deep
* - structural deep
*
* And the second level:
*
* - includes all/not missing some
* - includes some/not missing all
* - not including all/missing some
* - not including some/missing all
*
* Here's an example using the naming scheme for `hasKeys*`
*
* | shallow | strict deep | structural deep
* --------------|-----------------|---------------------|----------------------
* includes all | `hasKeys` | `hasKeysDeep` | `hasKeysMatch`
* includes some | `hasKeysAny` | `hasKeysAnyDeep` | `hasKeysAnyMatch`
* missing some | `notHasKeysAll` | `notHasKeysAllDeep` | `notHasKeysAllMatch`
* missing all | `notHasKeys` | `notHasKeysDeep` | `notHasKeysMatch`
*
* Note that the `hasKeys` shallow comparison variants are also overloaded to
* consume either an array (in which it simply checks against a list of keys) or
* an object (where it does a full deep comparison).
*/

exports.includes = Includes.includes
exports.includesDeep = Includes.includesDeep
exports.includesMatch = Includes.includesMatch
exports.includesAny = Includes.includesAny
exports.includesAnyDeep = Includes.includesAnyDeep
exports.includesAnyMatch = Includes.includesAnyMatch
exports.notIncludesAll = Includes.notIncludesAll
exports.notIncludesAllDeep = Includes.notIncludesAllDeep
exports.notIncludesAllMatch = Includes.notIncludesAllMatch
exports.notIncludes = Includes.notIncludes
exports.notIncludesDeep = Includes.notIncludesDeep
exports.notIncludesMatch = Includes.notIncludesMatch

exports.hasKeys = HasKeys.hasKeys
exports.hasKeysDeep = HasKeys.hasKeysDeep
exports.hasKeysMatch = HasKeys.hasKeysMatch
exports.hasKeysAny = HasKeys.hasKeysAny
exports.hasKeysAnyDeep = HasKeys.hasKeysAnyDeep
exports.hasKeysAnyMatch = HasKeys.hasKeysAnyMatch
exports.notHasKeysAll = HasKeys.notHasKeysAll
exports.notHasKeysAllDeep = HasKeys.notHasKeysAllDeep
exports.notHasKeysAllMatch = HasKeys.notHasKeysAllMatch
exports.notHasKeys = HasKeys.notHasKeys
exports.notHasKeysDeep = HasKeys.notHasKeysDeep
exports.notHasKeysMatch = HasKeys.notHasKeysMatch
module.exports = require("clean-assert")
16 changes: 7 additions & 9 deletions docs/README.md
@@ -1,12 +1,10 @@
# Documentation

This is the Thallium documentation. It's still a work in progress, as there's a
lot left to do in this framework.
This is the Thallium documentation. It's still a work in progress, as there's a lot left to do in this framework.

- [Getting Started](http://github.com/isiahmeadows/thallium/blob/master/docs/getting-started.md)
- [API](http://github.com/isiahmeadows/thallium/blob/master/docs/api.md)
- [Reporters](http://github.com/isiahmeadows/thallium/blob/master/docs/reporters.md)
- [Core assertions](http://github.com/isiahmeadows/thallium/blob/master/docs/assertions.md)
- [Command Line Runner](http://github.com/isiahmeadows/thallium/blob/master/docs/cli.md)
- [Plugins](http://github.com/isiahmeadows/thallium/blob/master/docs/plugins.md)
- [Examples](http://github.com/isiahmeadows/thallium/tree/master/docs/examples)
- [Getting Started](./getting-started.md)
- [API](./api.md)
- [Reporters](./reporters.md)
- [Command Line Runner](./cli.md)
- [Plugins](./plugins.md)
- [Examples](./examples)
4 changes: 2 additions & 2 deletions docs/api.md
Expand Up @@ -4,8 +4,8 @@ This has a very straightforward, intuitive core API. If you're new to this, you

- [Primary API](./api/thallium.md)
- [Reflect API](./api/reflect.md)
- [Assertion API](./api/assert.md)
- [Assertion API using `clean-assert`](https://github.com/isiahmeadows/clean-assert/blob/master/api.md), aliased as `thallium/assert`
- [Bundle API](./api/bundle.md)
- [Other APIs](./api/other.md)

I would also like to note that if you're importing this using ES6 module syntax (like with Babel or TypeScript), import this as a single default export.
I would also like to note that if you're importing this using ES6 module syntax (like with Babel or TypeScript), import `thallium` as a single default export.

0 comments on commit 7412ded

Please sign in to comment.