Skip to content

Commit

Permalink
Factor tests out of index.js
Browse files Browse the repository at this point in the history
  • Loading branch information
nathancarter committed Jan 14, 2020
1 parent 1571568 commit 0cc4b17
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 57 deletions.
59 changes: 2 additions & 57 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,60 +2,5 @@
const { OM } = require( './dependencies/openmath.js' )
const { LC, Statement, Environment } = require( './classes/lc.js' )

console.log( 'Checking to be sure all defined classes exist...' )
console.log( 'LC?', !!LC )
console.log( 'Statement?', !!Statement )
console.log( 'Environment?', !!Environment )

console.log( 'Checking to be sure I can build instances...' )
console.log( 'LC?', !!new LC() )
console.log( 'Statement?', !!new Statement() )
console.log( 'Environment?', !!new Environment() )

console.log( 'Checking to be sure I can build trees...' )
console.log( 'LC in LC?', ''+new LC( new LC() ) )
console.log( 'LCs in LC?', ''+new LC( new LC(), new LC() ) )
console.log( 'Statement in Statement?',
''+new Statement( new Statement() ) )
console.log( 'Statements in Statement?',
''+new Statement( new Statement(), new Statement() ) )
console.log( 'Environment in Environment?',
''+new Environment( new Environment() ) )
console.log( 'Environment in Environment?',
''+new Environment( new Environment(), new Environment() ) )
console.log( 'Statement in Environment?',
''+new Environment( new Statement() ) )
console.log( 'Environment in Statement?',
''+new Statement( new Environment() ) )
var R = new Statement()
R.identifier = 'R'
var S = new Statement()
S.identifier = 'S'
var T = new Statement( R, S )
T.identifier = 'T'
console.log( 'Appearance of a Statement tree with identifiers:', ''+T )

console.log( 'Verifying that these things don\'t have identifiers by default...' )
console.log( 'LC:', new LC().identifier )
console.log( 'Statement:', new Statement().identifier )
console.log( 'Environment:', new Environment().identifier )
console.log( 'Verifying that these things aren\'t quantifiers by default...' )
console.log( 'LC:', new LC().isAQuantifier )
console.log( 'Statement:', new Statement().isAQuantifier )
console.log( 'Environment:', new Environment().isAQuantifier )

console.log( 'Verify that we can play with given/claim status...' )
console.log( 'Default given value:', new LC().isAGiven )
console.log( 'Default claim value:', new LC().isAClaim )
console.log( 'Appearance:', ''+new LC() )
var tmp = new LC()
console.log( 'Making it a given...' )
tmp.isAGiven = true
console.log( 'Now the given value:', tmp.isAGiven )
console.log( 'Now the claim value:', tmp.isAClaim )
console.log( 'Appearance:', ''+tmp )
console.log( 'Making it a claim...' )
tmp.isAClaim = true
console.log( 'Now the given value:', tmp.isAGiven )
console.log( 'Now the claim value:', tmp.isAClaim )
console.log( 'Appearance:', ''+tmp )
console.log( 'All classes loaded OK.' )
console.log( 'To test further, run one of the scripts in the tests/ folder.' )
61 changes: 61 additions & 0 deletions tests/basics.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@

const { OM } = require( '../dependencies/openmath.js' )
const { LC, Statement, Environment } = require( '../classes/lc.js' )

console.log( 'Checking to be sure all defined classes exist...' )
console.log( 'LC?', !!LC )
console.log( 'Statement?', !!Statement )
console.log( 'Environment?', !!Environment )

console.log( 'Checking to be sure I can build instances...' )
console.log( 'LC?', !!new LC() )
console.log( 'Statement?', !!new Statement() )
console.log( 'Environment?', !!new Environment() )

console.log( 'Checking to be sure I can build trees...' )
console.log( 'LC in LC?', ''+new LC( new LC() ) )
console.log( 'LCs in LC?', ''+new LC( new LC(), new LC() ) )
console.log( 'Statement in Statement?',
''+new Statement( new Statement() ) )
console.log( 'Statements in Statement?',
''+new Statement( new Statement(), new Statement() ) )
console.log( 'Environment in Environment?',
''+new Environment( new Environment() ) )
console.log( 'Environment in Environment?',
''+new Environment( new Environment(), new Environment() ) )
console.log( 'Statement in Environment?',
''+new Environment( new Statement() ) )
console.log( 'Environment in Statement?',
''+new Statement( new Environment() ) )
var R = new Statement()
R.identifier = 'R'
var S = new Statement()
S.identifier = 'S'
var T = new Statement( R, S )
T.identifier = 'T'
console.log( 'Appearance of a Statement tree with identifiers:', ''+T )

console.log( 'Verifying that these things don\'t have identifiers by default...' )
console.log( 'LC:', new LC().identifier )
console.log( 'Statement:', new Statement().identifier )
console.log( 'Environment:', new Environment().identifier )
console.log( 'Verifying that these things aren\'t quantifiers by default...' )
console.log( 'LC:', new LC().isAQuantifier )
console.log( 'Statement:', new Statement().isAQuantifier )
console.log( 'Environment:', new Environment().isAQuantifier )

console.log( 'Verify that we can play with given/claim status...' )
console.log( 'Default given value:', new LC().isAGiven )
console.log( 'Default claim value:', new LC().isAClaim )
console.log( 'Appearance:', ''+new LC() )
var tmp = new LC()
console.log( 'Making it a given...' )
tmp.isAGiven = true
console.log( 'Now the given value:', tmp.isAGiven )
console.log( 'Now the claim value:', tmp.isAClaim )
console.log( 'Appearance:', ''+tmp )
console.log( 'Making it a claim...' )
tmp.isAClaim = true
console.log( 'Now the given value:', tmp.isAGiven )
console.log( 'Now the claim value:', tmp.isAClaim )
console.log( 'Appearance:', ''+tmp )

0 comments on commit 0cc4b17

Please sign in to comment.