Skip to content

Commit

Permalink
Refactoring: Exercises moved to separate directory
Browse files Browse the repository at this point in the history
  • Loading branch information
Granjow committed Oct 16, 2015
1 parent 43e3cf2 commit 11a2bed
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 51 deletions.
44 changes: 0 additions & 44 deletions ex2-graph-structure/graph-structure.js

This file was deleted.

2 changes: 1 addition & 1 deletion ex0-intro/intro.js → exercises/ex0-intro/intro.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var path = require( 'path' ),
verify = require( 'adventure-verify' ),
tools = require( '../library/tools' );
tools = require( '../../library/tools' );

exports.problem = tools.mdProblem( path.join( __dirname, 'problem-intro.md' ), 'problem-intro.pdf' );
exports.solution = tools.mdSolution( path.join( __dirname, 'solution-intro.js' ) );
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
var path = require( 'path' ),
verify = require( 'adventure-verify' ),
tools = require( '../library/tools' );
tools = require( '../../library/tools' );

exports.problem = tools.mdProblem( path.join( __dirname, 'problem-gve.md' ), 'problem-gve.pdf' );
exports.solution = tools.mdSolution( path.join( __dirname, 'solution-gve.js' ) );
exports.problem = tools.mdProblem( path.join( __dirname, 'problem-vertices-edges.md' ), 'problem-vertices-edges.pdf' );
exports.solution = tools.mdSolution( path.join( __dirname, 'solution-vertices-edges.js' ) );

exports.verify = verify( { modeReset: true }, function checker( args, t ) {
var res = require( path.resolve( args[ 0 ] ) );
Expand Down
File renamed without changes.
28 changes: 28 additions & 0 deletions exercises/ex2-graph-structure/graph-structure.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
var path = require( 'path' ),
verify = require( 'adventure-verify' ),
tools = require( '../../library/tools' );

exports.problem = tools.mdProblem( path.join( __dirname, 'problem-graph-structure.md' ), 'problem-graph-structure.pdf' );

exports.solution = tools.mdSolution( path.join( __dirname, 'solution-graph-structure.js' ) );

exports.verify = verify( { modeReset: true }, function checker( args, t ) {
var Graph = require( path.resolve( args[ 0 ] ) );

var vertices = [ 'A', 'B', 'C', 'D' ];
var edges = [ [ 'A', 'B' ], [ 'A', 'C' ], [ 'D', 'C' ] ];

var graph = new Graph( vertices, edges );

t.ok( graph.v( 'A' ), 'Can retrieve vertex A' );
t.equal( graph.v( 'A' ).id, 'A', 'ID of vertex A is "A"' );

var neighbours = graph.v( 'A' ).neighbours();
t.ok( neighbours, 'Can retrieve neighbours of A' );
t.equal( neighbours.length, 2, 'A has 2 neighbours' );
t.ok( (neighbours[ 0 ].id == 'B' && neighbours[ 1 ].id == 'C') || (neighbours[ 0 ].id == 'C' && neighbours[ 1 ].id == 'B'),
'Vertex A has neighbours B and C' );

t.end();

} );
File renamed without changes.
6 changes: 3 additions & 3 deletions runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ var shop = adventure( {
} );

shop.add( 'Intro', function () {
return require( './ex0-intro/intro' );
return require( './exercises/ex0-intro/intro' );
} );
shop.add( 'Vertices and Edges', function () {
return require( './ex1-gve/gve.js' );
return require( './exercises/ex1-vertices-edges/vertices-edges.js' );
} );
shop.add( 'Graph Structure', function () {
return require( './ex2-graph-structure/graph-structure' );
return require( './exercises/ex2-graph-structure/graph-structure' );
} );

shop.execute( process.argv.slice( 2 ) );

0 comments on commit 11a2bed

Please sign in to comment.