Oo3d Test

Home

Passed 372/372

1-01 `new Oo3d`

The class and instance are expected types

The class is a function

`new` returns an object

`oo3d.toString()` as expected

`oo3d.C` as expected

Config exceptions

If set, `config` must be an object

If set, `config.$main` must be an HTMLCanvasElement

If set, `config.bkgnd` must be a Float32Array

`config.bkgnd` must contain four elements

`config.bkgnd[0]` must be 0 or greater

`config.bkgnd[0]` must be 1 or less

`config.bkgnd[1]` must be 0 or greater

`config.bkgnd[1]` must be 1 or less

`config.bkgnd[2]` must be 0 or greater

`config.bkgnd[2]` must be 1 or less

`config.bkgnd[3]` must be 0 or greater

`config.bkgnd[3]` must be 1 or less

Config usage

`config.bkgnd` can contain four floats 0-1, or NaN

1-02 `oo3d.browse()`

(Mock an `Oo3d` instance)

The method is a function and returns an object

`oo3d.browse()` is a function

`oo3d.browse()` returns an array

`oo3d.browse('abc')` returns an array

1-03 `oo3d.read()`

(Mock an Oo3d instance)

The method is a function and returns an object

`oo3d.read()` is a function

`oo3d.read()` returns an object

1-04 `oo3d.edit()`

(Mock an Oo3d instance)

The method is a function and returns an object

`oo3d.edit()` is a function

`oo3d.edit(0)` returns an object

1-05 `oo3d.add()`

(Mock an Oo3d instance)

The method is a function and returns a number

`oo3d.add()` is a function

`oo3d.add('Item.Mesh')` returns a number

`item.add()` exceptions

`className` is not optional

`className` must not be boolean

`className` must not be an empty string

`className` must not have three parts

`className` base must be a recognised base-class

`className` child must be a recognised child-class

`item.add()` usage

Adding an Item.Mesh increments `_all`

Two calls to `add()` returns two indices in sequence

1-06 `oo3d.delete()`

(Mock an Oo3d instance)

(Add various instances which these tests will try to delete)

State is as expected before any deletion

`oo3d._all` contains 12 instances

`oo3d.layers` contains 1 instance

Various type-checks

`oo3d.delete()` is a function

`oo3d.deleteOne()` (the private function) is not available in the public API

Before deleting programFlatI, `oo3d._all[itemLut.programFlatI]` is an object

`oo3d.delete(itemLut.programFlatI)` returns an object

After deleting programFlatI, `oo3d._all[itemLut.programFlatI]` is undefined

Checks after basic programFlatI deletion

`oo3d.deleteOne()` (the private function) is not reachable by Tudor

After deleting programFlatI, `oo3d._all` now contains 11 instances

After deleting programFlatI, `oo3d.layers` still contains 1 instance

Delete a Item.Mesh instances

Before deleting itemMeshTwoI, `oo3d._all[itemLut.itemMeshI]` is '[object Item.Mesh]'

Before deleting itemMeshTwoI, rendererWireframeI has two elements in `meshes`

`oo3d.delete(itemLut.itemMeshTwoI)` returns an object

After deleting itemMeshTwoI, rendererWireframeI has one element in `meshes`

A second call to `oo3d.delete(itemLut.itemMeshTwoI)` throws an error

After trying to delete itemMeshTwoI for a second time, rendererWireframeI still has one element in `meshes`

After deleting itemMeshI, rendererWireframeI has no elements in `meshes`

After deleting itemMeshI and itemMeshTwoI, `oo3d._all` now contains 9 instances

After deleting itemMeshI and itemMeshTwoI, `oo3d.layers` still contains 1 instance

2-1-01 `new Buffer`

(Mock an Oo3d instance)

The class and instance are expected types

The class is a function

`new` returns an object

`buffer.toString()` as expected

`buffer.C` as expected

Buffer Constructor exceptions

`config.main` must be an object

`config.main` must be an Oo3d instance

`index` must be a number

`index` must be an integer

`index` must be positive

`index` must be below 2^53

`config` must be an object

If set, `config.data` must be a regular array

If set, `config.data` must only contain numbers

Buffer Constructor usage

`config` can contain unexpected properties, which are not recorded

If set, `config.data` can contain strings which resolve to numbers

2-2-01 `new Buffer.Color`

(Mock an Oo3d instance)

The class and instance are expected types

The class is a function

`new` returns an object

`colorBuffer.toString()` as expected

`colorBuffer.C` as expected

Buffer.Color Constructor exceptions

`config.main` must be an object

`config.main` must be an Oo3d instance

`index` must be a number

`index` must be an integer

`index` must be positive

`index` must be below 2^53

`config` must be an object

If set, `config.data` must be a regular array

If set, `config.data` must only contain numbers

If set, `config.data.length` must not be `1`

If set, `config.data.length` must not be `6`

Buffer.Color Constructor usage

`config` can contain unexpected properties, which are not recorded

If set, `config.data` can contain strings which resolve to numbers

2-2-01 `new Buffer.Position`

(Mock an Oo3d instance)

The class and instance are expected types

The class is a function

`new` returns an object

`positionBuffer.toString()` as expected

`positionBuffer.C` as expected

Buffer.Position Constructor exceptions

`config.main` must be an object

`config.main` must be an Oo3d instance

`index` must be a number

`index` must be an integer

`index` must be positive

`index` must be below 2^53

`config` must be an object

If set, `config.data` must be a regular array

If set, `config.data` must only contain numbers

If set, `config.data.length` must not be `1`

If set, `config.data.length` must not be `5`

Buffer.Position Constructor usage

`config` can contain unexpected properties, which are not recorded

If set, `config.data` can contain strings which resolve to numbers

3-1-01 `new Item`

(Mock an Oo3d instance)

The class and instance are expected types

The class is a function

`new` returns an object

`item.toString()` as expected

`item.C` as expected

Constructor exceptions

`config.main` must be an object

`config.main` must be an Oo3d instance

`index` must be a number

`index` must be an integer

`index` must be positive

`index` must be below 2^53

`config` must be an object

Constructor usage

`config` can be an empty object

`item.mT` as expected

`item.rX` `item.rY` `item.rZ` as expected

`item.sX` `item.sY` `item.sZ` as expected

`item.tX` `item.tY` `item.tZ` as expected

3-1-02 `item.browse()`

(Mock an Oo3d instance)

The method is a function and returns an object

`item.browse()` is a function

`item.browse()` returns an array

`item.browse('abc')` returns an array

3-1-03 `item.read()`

(Mock an Oo3d instance)

(Directly create an Item instance)

The method is a function and returns expected types

`item.read()` is a function

`item.read()` returns an object

`item.read('object')` returns an object

`item.read('log')` returns a string

`item.read('nwang')` returns a string

`item.read()` exceptions

`format` must not be boolean

`format` must not be null

`format` 'NOPE!' is not recognized

`item.read()` usage

Object from a default Item contains expected keys and values

Object from a default Item contain only the expected keys

Dumped 'log' from a default Item as expected

Dumped 'nwang' from a default Item as expected

Dumped 'log' from a transformed Item as expected

Dumped 'nwang' from a transformed Item as expected

3-1-04 `item.edit()`

(Mock an Oo3d instance)

(Directly create an Item instance)

The method is a function and returns an object

`item.edit()` is a function

`item.edit()` returns an object

`item.edit('i 0 mT 1 0 0 0 ... t 0 0 0')` returns an object

`item.rX` is a number

`item.rY` is a number

`item.rZ` is a number

`item.sX` is a number

`item.sY` is a number

`item.sZ` is a number

`item.tX` is a number

`item.tY` is a number

`item.tZ` is a number

Ensure private functions cannot be accessed

`xx()` cannot be accessed

`set` argument exceptions

`set` cannot be a Date object

`set` cannot be the string 'NOPE!'

`set` cannot be an empty string

An object passed to the `set` argument must not must not change `item.index` to a boolean

An object passed to the `set` argument must not must not change `item.index` to a number

An `sY` property passed to the `set` argument must be a number

A `tX` property passed to the `set` argument must not be NaN

An `mT` property passed to the `set` argument must be Float32Array|array

An `mT` property passed to the `set` argument must contain 16 values

An 'nwang' string passed to the `set` argument must not be 8 characters

An 'nwang' string passed to the `set` argument must not be 10 characters

An 'nwang' string passed to the `set` argument must be valid nwang

An 'nwang' string passed to the `set` argument must not change `item.index`

A 9-value 'log' string passed to the `set` argument must only contain numbers

A 16-value 'log' string passed to the `set` argument must only contain numbers

A 'log' string passed to the `set` argument must not change `item.index`

`delta` argument exceptions

`delta` cannot be the Math object

`delta` cannot be the string 'NOPE!'

`delta` cannot be an empty string

An `rX` property passed to the `delta` argument must be a number

A `tZ` property passed to the `set` argument must not be NaN

An 'nwang' string passed to the `delta` argument must not be 8 characters

An 'nwang' string passed to the `delta` argument must not be 26 characters

An 'nwang' string passed to the `delta` argument must be valid nwang

A 'log' string passed to the `delta` argument must only contain numbers

Noop ways of calling `item.edit()`

No arguments

Pass null to the `set` and `delta` arguments

Pass undefined to the `set` and `delta` arguments

Pass empty object to the `set` argument

Pass empty object to the `delta` argument

Pass empty objects to the `set` and `delta` arguments

Pass an object to the `set` argument

Pass a complete object to the `set` argument

Pass a partial object to the `set` argument, which includes `mT`

Pass a partial object to the `set` argument, which does not include `mT`

Random properties are ignored

An `mT` property passed to the `set` argument can contain non-numeric values (will become NaN)

An `mT` property passed to the `set` argument can be UInt8Array

Pass an 'nwang' string to the `set` argument

Pass a 26-value 'nwang' string to the `set` argument

Pass a 9-value 'nwang' string to the `set` argument

Pass a 'log' string to the `set` argument

Pass a 26-value 'log' string to the `set` argument, which resets the Item

Note that an inconsistent 26-value 'log' should be accepted without complaint!

Pass a 9-value 'log' string to the `set` argument

Pass an object to the `delta` argument

Pass a 'unity' 9-value object to the `delta` argument

Pass a transforming 9-value object to the `delta` argument

Pass a transforming 2-value object to the `delta` argument

Pass an 'nwang' string to the `delta` argument

Pass a 'unity' 9-value 'nwang' string to the `delta` argument

Pass a transforming 9-value 'nwang' string to the `delta` argument

3-2-01 `new Item.Mesh`

(Mock an Oo3d instance)

The class and instance are expected types

The class is a function

`new` returns an object

Item Constructor exceptions

`config.main` must be an object

`config.main` must be an Oo3d instance

`index` must be a number

`index` must be an integer

`index` must be positive

`index` must be below 2^53

`config` must be an object

Item.Mesh Constructor exceptions

If set, config.positionI must be a number

If set, config.positionI must be an integer

If set, config.positionI must refer to an instance

If set, config.positionI must refer to a Buffer.Position instance

If set, config.colorI must be a number

If set, config.colorI must be a positive number

If set, config.colorI must refer to an instance

If set, config.colorI must refer to a Buffer.Position instance

A Buffer.Position with one vertex does not match a Buffer.Color with two

If set, config.renderMode must be a recognised value

If set, config.blend must be an array

config.blend[0] (for item.sBlend) must be a recognised value

config.blend[1] (for item.dBlend) must be a recognised value

Item Constructor usage

`config` can be an empty object

`item.mT` as expected

`mesh.rX` `mesh.rY` `mesh.rZ` as expected

`mesh.sX` `mesh.sY` `mesh.sZ` as expected

`mesh.tX` `mesh.tY` `mesh.tZ` as expected

Item.Mesh Constructor usage

Complete set of `config` defaults

3-2-03 `Item.Mesh:read()`

(Mock an Oo3d instance)

(Directly create an Item.Mesh instance)

The method is a function and returns expected types

`mesh.read()` is a function

`mesh.read()` returns an object

`mesh.read('object')` returns an object

`mesh.read('log')` returns a string

`mesh.read('nwang')` returns a string

`mesh.read()` exceptions

`format` must not be boolean

`format` must not be null

`format` 'NOPE!' is not recognized

`mesh.read()` usage

Object from a default Item.Mesh contains expected keys and values

Object from a default Item.Mesh contain only the expected keys

Dumped 'log' from a default Item.Mesh as expected

Dumped 'nwang' from a default Item.Mesh as expected

Dumped 'log' from a transformed Item.Mesh as expected

Dumped 'nwang' from a transformed Item.Mesh as expected

3-2-04 `Item.Mesh:edit()`

(Mock an Oo3d instance)

(Directly create an Item.Mesh instance)

The method is a function and returns an object

`mesh.edit()` is a function

`mesh.edit()` returns an object

`mesh.edit('i 0 mT 1 0 0 0 ... t 0 0 0 bP 0 bC 1')` returns an object

`mesh.rX` is a number

`mesh.rY` is a number

`mesh.rZ` is a number

`mesh.sX` is a number

`mesh.sY` is a number

`mesh.sZ` is a number

`mesh.tX` is a number

`mesh.tY` is a number

`mesh.tZ` is a number

Ensure private functions cannot be accessed

`xx()` cannot be accessed

`set` argument exceptions

`set` cannot be a Date object

`set` cannot be the string 'NOPE!'

`set` cannot be an empty string

An object passed to the `set` argument must not must not change `item.index` to a boolean

An object passed to the `set` argument must not must not change `item.index` to a number

An `sY` property passed to the `set` argument must be a number

A `tX` property passed to the `set` argument must not be NaN

An `mT` property passed to the `set` argument must be Float32Array|array

An `mT` property passed to the `set` argument must contain 16 values

A `bpi` property passed to the `set` argument must not be a string

A `bpi` property passed to the `set` argument must not be -ve

A `bpi` property passed to the `set` argument must refer to an instance in `main._all`

A `bpi` property passed to the `set` argument must refer to a Buffer.Position instance

A `bpi` property passed to the `set` argument must match the mesh’s Buffer.Color count

A `bci` property passed to the `set` argument must not be an array

A `bci` property passed to the `set` argument must not be -ve

A `bci` property passed to the `set` argument must refer to an instance in `main._all`

A `bci` property passed to the `set` argument must refer to a Buffer.Color instance

A `bci` property passed to the `set` argument must match the mesh’s Buffer.Position count

`bpi` and `bci` properties passed to the `set` argument must match each other

An 'nwang' string passed to the `set` argument must not be 8 characters

An 'nwang' string passed to the `set` argument must not be 10 characters

An 'nwang' string passed to the `set` argument must be valid nwang

An 'nwang' string passed to the `set` argument must not change `item.index`

An 11-char 'nwang' string’s `bpi` value must not be fractional

An 11-char 'nwang' string’s `bpi` value must refer to an instance in `main._all`

An 11-char 'nwang' string’s `bpi` value must refer to a Buffer.Position instance

An 11-char 'nwang' string’s `bpi` count must match its `bci` count

An 11-char 'nwang' string’s `bci` value must not be fractional

An 11-char 'nwang' string’s `bci` value must refer to an instance in `main._all`

An 11-char 'nwang' string’s `bci` value must refer to a Buffer.Color instance

A 9-value 'log' string passed to the `set` argument must only contain numbers

A 16-value 'log' string passed to the `set` argument must only contain numbers

A 'log' string passed to the `set` argument must not change `item.index`

`delta` argument exceptions

`delta` cannot be the Math object

`delta` cannot be the string 'NOPE!'

`delta` cannot be an empty string

An `rX` property passed to the `delta` argument must be a number

A `tZ` property passed to the `set` argument must not be NaN

An 'nwang' string passed to the `delta` argument must not be 8 characters

An 'nwang' string passed to the `delta` argument must not be 26 characters

An 'nwang' string passed to the `delta` argument must be valid nwang

A 'log' string passed to the `delta` argument must only contain numbers

Noop ways of calling `mesh.edit()`

No arguments

Pass null to the `set` and `delta` arguments

Pass undefined to the `set` and `delta` arguments

Pass empty object to the `set` argument

Pass empty object to the `delta` argument

Pass empty objects to the `set` and `delta` arguments

Pass an object to the `set` argument

Pass a complete object to the `set` argument

Pass a partial object to the `set` argument, which includes `mT`

Pass a partial object to the `set` argument, which does not include `mT`

Random properties are ignored

An `mT` property passed to the `set` argument can contain non-numeric values (will become NaN)

An `mT` property passed to the `set` argument can be UInt8Array

A `bP` property passed to the `set` argument changes the mesh’s Buffer.Position

A `bC` property passed to the `set` argument changes the mesh’s Buffer.Color

Pass an 'nwang' string to the `set` argument

Pass a 26-value 'nwang' string to the `set` argument

Pass a 9-value 'nwang' string to the `set` argument

Pass an 11-value 'nwang' string to the `set` argument

Pass a 'log' string to the `set` argument

Pass a 26-value 'log' string to the `set` argument, which resets the Item

Note that an inconsistent 26-value 'log' should be accepted without complaint!

Pass a 9-value 'log' string to the `set` argument

Pass an object to the `delta` argument

Pass a 'unity' 9-value object to the `delta` argument

Pass a transforming 9-value object to the `delta` argument

Pass a transforming 2-value object to the `delta` argument

Pass an 'nwang' string to the `delta` argument

Pass a 'unity' 9-value 'nwang' string to the `delta` argument

Pass a transforming 9-value 'nwang' string to the `delta` argument

3-3-01 `new Item.Camera`

(Mock an Oo3d instance)

The class and instance are expected types

The class is a function

`new` returns an object

Item Constructor exceptions

`config.main` must be an object

`config.main` must be an Oo3d instance

`index` must be a number

`index` must be an integer

`index` must be positive

`index` must be below 2^53

`config` must be an object

Item.Camera Constructor exceptions

If set, config.fovy must be a number

If set, config.fovy must be greater than zero

If set, config.aspect must be a number

If set, config.aspect must be greater than zero

Item Constructor usage

`config` can be an empty object

`item.mT` as expected

`camera.rX` `camera.rY` `camera.rZ` as expected

`camera.sX` `camera.sY` `camera.sZ` as expected

`camera.tX` `camera.tY` `camera.tZ` as expected

Item.Camera Constructor usage

Complete set of `config` defaults

4-1-01 `new Layer`

(Mock an Oo3d instance)

The class and instance are expected types

The class is a function

`new` returns an object

`layer.toString()` as expected

`layer.C` as expected

layer Constructor exceptions

`config.main` must be an object

`config.main` must be an Oo3d instance

`index` must be a number

`index` must be an integer

`index` must be positive

`index` must be below 2^53

`config` must be an object

`config.rendererIs` must be a regular array

`config.rendererIs` must only contain numbers

`config.rendererIs` must all refer to Renderer instances

layer Constructor usage

Complete set of `config` defaults

9-1-01 `pick.indexToColor()`

The function exists, and returns the expected type

The container exists

The function exists

`pick.indexToColor(0)` returns a Float32Array

`pick.indexToColor()` usage

Returns an array with four elements

Zero returns black, with 100% alpha

`1` returns 50% brightness red

`1` to `7` return combinations of R, G and B at 50% brightness

`585, 521, 73, 9, 577, 513, 65, 1, 584, 520, 72, 8` return various shades of red

`585, 73, 521, 9, 577, 65, 513, 1, 584, 72, 520, 8, 576, 64, 512, 0` return various shades of red

`1170, 146, 1042, 18, 1154, 130, 1026, 2, 1168, 144, 1040, 16, 1152, 128, 1024, 0` return various shades of green

`2340, 292, 2084, 36, 2308, 260, 2052, 4, 2336, 288, 2080, 32, 2304, 256, 2048, 0` return various shades of blue

9-1-02 `pick.colorToIndex()`

The function exists, and returns the expected type

The container exists

The function exists

`pick.colorToIndex(0)` returns a number

`pick.colorToIndex()` usage

Black with 100% alpha returns zero

50% brightness red returns `1`

combinations of R, G and B at 50% brightness return `1` to `7`

various shades of red return `585, 73, 521, 9, 577, 65, 513, 1, 584, 72, 520, 8, 576, 64, 512, 0`

various shades of green return `1170, 146, 1042, 18, 1154, 130, 1026, 2, 1168, 144, 1040, 16, 1152, 128, 1024, 0`

various shades of blue return `2340, 292, 2084, 36, 2308, 260, 2052, 4, 2336, 288, 2080, 32, 2304, 256, 2048, 0`

Passed 372/372