diff --git a/exercises/practice/acronym/TestRunner.bxs b/exercises/practice/acronym/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/acronym/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/acronym/boxlang.json b/exercises/practice/acronym/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/acronym/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/acronym/index.cfm b/exercises/practice/acronym/index.cfm deleted file mode 100644 index 1e35079..0000000 --- a/exercises/practice/acronym/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your excercise folder and refresh this page. - diff --git a/exercises/practice/all-your-base/TestRunner.bxs b/exercises/practice/all-your-base/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/all-your-base/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/all-your-base/boxlang.json b/exercises/practice/all-your-base/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/all-your-base/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/all-your-base/index.cfm b/exercises/practice/all-your-base/index.cfm deleted file mode 100644 index 1e35079..0000000 --- a/exercises/practice/all-your-base/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your excercise folder and refresh this page. - diff --git a/exercises/practice/allergies/TestRunner.bxs b/exercises/practice/allergies/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/allergies/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/allergies/boxlang.json b/exercises/practice/allergies/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/allergies/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/allergies/index.cfm b/exercises/practice/allergies/index.cfm deleted file mode 100644 index bb28af8..0000000 --- a/exercises/practice/allergies/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your exercise folder and refresh this page. - diff --git a/exercises/practice/anagram/TestRunner.bxs b/exercises/practice/anagram/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/anagram/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/anagram/boxlang.json b/exercises/practice/anagram/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/anagram/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/anagram/index.cfm b/exercises/practice/anagram/index.cfm deleted file mode 100644 index 1e35079..0000000 --- a/exercises/practice/anagram/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your excercise folder and refresh this page. - diff --git a/exercises/practice/atbash-cipher/TestRunner.bxs b/exercises/practice/atbash-cipher/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/atbash-cipher/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/atbash-cipher/boxlang.json b/exercises/practice/atbash-cipher/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/atbash-cipher/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/atbash-cipher/index.cfm b/exercises/practice/atbash-cipher/index.cfm deleted file mode 100644 index 1e35079..0000000 --- a/exercises/practice/atbash-cipher/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your excercise folder and refresh this page. - diff --git a/exercises/practice/binary-search/TestRunner.bxs b/exercises/practice/binary-search/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/binary-search/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/binary-search/boxlang.json b/exercises/practice/binary-search/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/binary-search/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/binary-search/index.cfm b/exercises/practice/binary-search/index.cfm deleted file mode 100644 index bb28af8..0000000 --- a/exercises/practice/binary-search/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your exercise folder and refresh this page. - diff --git a/exercises/practice/bob/TestRunner.bxs b/exercises/practice/bob/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/bob/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/bob/boxlang.json b/exercises/practice/bob/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/bob/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/bob/index.cfm b/exercises/practice/bob/index.cfm deleted file mode 100644 index 1e35079..0000000 --- a/exercises/practice/bob/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your excercise folder and refresh this page. - diff --git a/exercises/practice/circular-buffer/TestRunner.bxs b/exercises/practice/circular-buffer/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/circular-buffer/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/circular-buffer/boxlang.json b/exercises/practice/circular-buffer/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/circular-buffer/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/circular-buffer/index.cfm b/exercises/practice/circular-buffer/index.cfm deleted file mode 100644 index bb28af8..0000000 --- a/exercises/practice/circular-buffer/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your exercise folder and refresh this page. - diff --git a/exercises/practice/collatz-conjecture/TestRunner.bxs b/exercises/practice/collatz-conjecture/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/collatz-conjecture/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/collatz-conjecture/boxlang.json b/exercises/practice/collatz-conjecture/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/collatz-conjecture/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/collatz-conjecture/index.cfm b/exercises/practice/collatz-conjecture/index.cfm deleted file mode 100644 index bb28af8..0000000 --- a/exercises/practice/collatz-conjecture/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your exercise folder and refresh this page. - diff --git a/exercises/practice/darts/TestRunner.bxs b/exercises/practice/darts/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/darts/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/darts/boxlang.json b/exercises/practice/darts/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/darts/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/darts/index.cfm b/exercises/practice/darts/index.cfm deleted file mode 100644 index 1e35079..0000000 --- a/exercises/practice/darts/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your excercise folder and refresh this page. - diff --git a/exercises/practice/diamond/TestRunner.bxs b/exercises/practice/diamond/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/diamond/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/diamond/boxlang.json b/exercises/practice/diamond/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/diamond/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/diamond/index.cfm b/exercises/practice/diamond/index.cfm deleted file mode 100644 index 1e35079..0000000 --- a/exercises/practice/diamond/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your excercise folder and refresh this page. - diff --git a/exercises/practice/difference-of-squares/TestRunner.bxs b/exercises/practice/difference-of-squares/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/difference-of-squares/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/difference-of-squares/boxlang.json b/exercises/practice/difference-of-squares/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/difference-of-squares/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/difference-of-squares/index.cfm b/exercises/practice/difference-of-squares/index.cfm deleted file mode 100644 index 1e35079..0000000 --- a/exercises/practice/difference-of-squares/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your excercise folder and refresh this page. - diff --git a/exercises/practice/dnd-character/TestRunner.bxs b/exercises/practice/dnd-character/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/dnd-character/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/dnd-character/boxlang.json b/exercises/practice/dnd-character/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/dnd-character/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/dnd-character/index.cfm b/exercises/practice/dnd-character/index.cfm deleted file mode 100644 index 1e35079..0000000 --- a/exercises/practice/dnd-character/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your excercise folder and refresh this page. - diff --git a/exercises/practice/eliuds-eggs/TestRunner.bxs b/exercises/practice/eliuds-eggs/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/eliuds-eggs/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/eliuds-eggs/boxlang.json b/exercises/practice/eliuds-eggs/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/eliuds-eggs/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/eliuds-eggs/index.cfm b/exercises/practice/eliuds-eggs/index.cfm deleted file mode 100644 index 1e35079..0000000 --- a/exercises/practice/eliuds-eggs/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your excercise folder and refresh this page. - diff --git a/exercises/practice/etl/TestRunner.bxs b/exercises/practice/etl/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/etl/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/etl/boxlang.json b/exercises/practice/etl/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/etl/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/etl/index.cfm b/exercises/practice/etl/index.cfm deleted file mode 100644 index bb28af8..0000000 --- a/exercises/practice/etl/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your exercise folder and refresh this page. - diff --git a/exercises/practice/flatten-array/TestRunner.bxs b/exercises/practice/flatten-array/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/flatten-array/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/flatten-array/boxlang.json b/exercises/practice/flatten-array/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/flatten-array/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/flatten-array/index.cfm b/exercises/practice/flatten-array/index.cfm deleted file mode 100644 index 1e35079..0000000 --- a/exercises/practice/flatten-array/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your excercise folder and refresh this page. - diff --git a/exercises/practice/gigasecond/TestRunner.bxs b/exercises/practice/gigasecond/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/gigasecond/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/gigasecond/boxlang.json b/exercises/practice/gigasecond/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/gigasecond/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/gigasecond/index.cfm b/exercises/practice/gigasecond/index.cfm deleted file mode 100644 index 1e35079..0000000 --- a/exercises/practice/gigasecond/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your excercise folder and refresh this page. - diff --git a/exercises/practice/grains/TestRunner.bxs b/exercises/practice/grains/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/grains/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/grains/boxlang.json b/exercises/practice/grains/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/grains/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/grains/index.cfm b/exercises/practice/grains/index.cfm deleted file mode 100644 index 1e35079..0000000 --- a/exercises/practice/grains/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your excercise folder and refresh this page. - diff --git a/exercises/practice/hamming/TestRunner.bxs b/exercises/practice/hamming/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/hamming/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/hamming/boxlang.json b/exercises/practice/hamming/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/hamming/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/hamming/index.cfm b/exercises/practice/hamming/index.cfm deleted file mode 100644 index 1e35079..0000000 --- a/exercises/practice/hamming/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your excercise folder and refresh this page. - diff --git a/exercises/practice/hello-world/TestRunner.bxs b/exercises/practice/hello-world/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/hello-world/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/hello-world/boxlang.json b/exercises/practice/hello-world/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/hello-world/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/hello-world/index.cfm b/exercises/practice/hello-world/index.cfm deleted file mode 100644 index 1e35079..0000000 --- a/exercises/practice/hello-world/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your excercise folder and refresh this page. - diff --git a/exercises/practice/isogram/TestRunner.bxs b/exercises/practice/isogram/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/isogram/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/isogram/boxlang.json b/exercises/practice/isogram/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/isogram/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/isogram/index.cfm b/exercises/practice/isogram/index.cfm deleted file mode 100644 index 1e35079..0000000 --- a/exercises/practice/isogram/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your excercise folder and refresh this page. - diff --git a/exercises/practice/largest-series-product/TestRunner.bxs b/exercises/practice/largest-series-product/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/largest-series-product/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/largest-series-product/boxlang.json b/exercises/practice/largest-series-product/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/largest-series-product/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/largest-series-product/index.cfm b/exercises/practice/largest-series-product/index.cfm deleted file mode 100644 index 1e35079..0000000 --- a/exercises/practice/largest-series-product/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your excercise folder and refresh this page. - diff --git a/exercises/practice/leap/TestRunner.bxs b/exercises/practice/leap/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/leap/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/leap/boxlang.json b/exercises/practice/leap/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/leap/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/leap/index.cfm b/exercises/practice/leap/index.cfm deleted file mode 100644 index 1e35079..0000000 --- a/exercises/practice/leap/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your excercise folder and refresh this page. - diff --git a/exercises/practice/list-ops/TestRunner.bxs b/exercises/practice/list-ops/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/list-ops/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/list-ops/boxlang.json b/exercises/practice/list-ops/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/list-ops/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/list-ops/index.cfm b/exercises/practice/list-ops/index.cfm deleted file mode 100644 index bb28af8..0000000 --- a/exercises/practice/list-ops/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your exercise folder and refresh this page. - diff --git a/exercises/practice/luhn/TestRunner.bxs b/exercises/practice/luhn/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/luhn/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/luhn/boxlang.json b/exercises/practice/luhn/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/luhn/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/luhn/index.cfm b/exercises/practice/luhn/index.cfm deleted file mode 100644 index 1e35079..0000000 --- a/exercises/practice/luhn/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your excercise folder and refresh this page. - diff --git a/exercises/practice/markdown/TestRunner.bxs b/exercises/practice/markdown/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/markdown/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/markdown/boxlang.json b/exercises/practice/markdown/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/markdown/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/markdown/index.cfm b/exercises/practice/markdown/index.cfm deleted file mode 100644 index 1e35079..0000000 --- a/exercises/practice/markdown/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your excercise folder and refresh this page. - diff --git a/exercises/practice/nth-prime/TestRunner.bxs b/exercises/practice/nth-prime/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/nth-prime/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/nth-prime/boxlang.json b/exercises/practice/nth-prime/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/nth-prime/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/nth-prime/index.cfm b/exercises/practice/nth-prime/index.cfm deleted file mode 100644 index 1e35079..0000000 --- a/exercises/practice/nth-prime/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your excercise folder and refresh this page. - diff --git a/exercises/practice/nucleotide-count/TestRunner.bxs b/exercises/practice/nucleotide-count/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/nucleotide-count/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/nucleotide-count/boxlang.json b/exercises/practice/nucleotide-count/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/nucleotide-count/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/nucleotide-count/index.cfm b/exercises/practice/nucleotide-count/index.cfm deleted file mode 100644 index 1e35079..0000000 --- a/exercises/practice/nucleotide-count/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your excercise folder and refresh this page. - diff --git a/exercises/practice/pangram/TestRunner.bxs b/exercises/practice/pangram/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/pangram/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/pangram/boxlang.json b/exercises/practice/pangram/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/pangram/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/pangram/index.cfm b/exercises/practice/pangram/index.cfm deleted file mode 100644 index 1e35079..0000000 --- a/exercises/practice/pangram/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your excercise folder and refresh this page. - diff --git a/exercises/practice/perfect-numbers/TestRunner.bxs b/exercises/practice/perfect-numbers/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/perfect-numbers/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/perfect-numbers/boxlang.json b/exercises/practice/perfect-numbers/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/perfect-numbers/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/perfect-numbers/index.cfm b/exercises/practice/perfect-numbers/index.cfm deleted file mode 100644 index bb28af8..0000000 --- a/exercises/practice/perfect-numbers/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your exercise folder and refresh this page. - diff --git a/exercises/practice/pig-latin/TestRunner.bxs b/exercises/practice/pig-latin/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/pig-latin/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/pig-latin/boxlang.json b/exercises/practice/pig-latin/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/pig-latin/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/pig-latin/index.cfm b/exercises/practice/pig-latin/index.cfm deleted file mode 100644 index 1e35079..0000000 --- a/exercises/practice/pig-latin/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your excercise folder and refresh this page. - diff --git a/exercises/practice/protein-translation/TestRunner.bxs b/exercises/practice/protein-translation/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/protein-translation/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/protein-translation/boxlang.json b/exercises/practice/protein-translation/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/protein-translation/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/protein-translation/index.cfm b/exercises/practice/protein-translation/index.cfm deleted file mode 100644 index 1e35079..0000000 --- a/exercises/practice/protein-translation/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your excercise folder and refresh this page. - diff --git a/exercises/practice/queen-attack/TestRunner.bxs b/exercises/practice/queen-attack/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/queen-attack/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/queen-attack/boxlang.json b/exercises/practice/queen-attack/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/queen-attack/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/queen-attack/index.cfm b/exercises/practice/queen-attack/index.cfm deleted file mode 100644 index 1e35079..0000000 --- a/exercises/practice/queen-attack/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your excercise folder and refresh this page. - diff --git a/exercises/practice/raindrops/TestRunner.bxs b/exercises/practice/raindrops/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/raindrops/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/raindrops/boxlang.json b/exercises/practice/raindrops/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/raindrops/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/raindrops/index.cfm b/exercises/practice/raindrops/index.cfm deleted file mode 100644 index 1e35079..0000000 --- a/exercises/practice/raindrops/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your excercise folder and refresh this page. - diff --git a/exercises/practice/resistor-color-duo/TestRunner.bxs b/exercises/practice/resistor-color-duo/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/resistor-color-duo/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/resistor-color-duo/boxlang.json b/exercises/practice/resistor-color-duo/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/resistor-color-duo/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/resistor-color-duo/index.cfm b/exercises/practice/resistor-color-duo/index.cfm deleted file mode 100644 index 1e35079..0000000 --- a/exercises/practice/resistor-color-duo/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your excercise folder and refresh this page. - diff --git a/exercises/practice/resistor-color/TestRunner.bxs b/exercises/practice/resistor-color/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/resistor-color/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/resistor-color/boxlang.json b/exercises/practice/resistor-color/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/resistor-color/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/resistor-color/index.cfm b/exercises/practice/resistor-color/index.cfm deleted file mode 100644 index 1e35079..0000000 --- a/exercises/practice/resistor-color/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your excercise folder and refresh this page. - diff --git a/exercises/practice/reverse-string/TestRunner.bxs b/exercises/practice/reverse-string/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/reverse-string/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/reverse-string/boxlang.json b/exercises/practice/reverse-string/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/reverse-string/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/reverse-string/index.cfm b/exercises/practice/reverse-string/index.cfm deleted file mode 100644 index bb28af8..0000000 --- a/exercises/practice/reverse-string/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your exercise folder and refresh this page. - diff --git a/exercises/practice/rna-transcription/TestRunner.bxs b/exercises/practice/rna-transcription/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/rna-transcription/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/rna-transcription/boxlang.json b/exercises/practice/rna-transcription/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/rna-transcription/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/rna-transcription/index.cfm b/exercises/practice/rna-transcription/index.cfm deleted file mode 100644 index 1e35079..0000000 --- a/exercises/practice/rna-transcription/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your excercise folder and refresh this page. - diff --git a/exercises/practice/robot-simulator/TestRunner.bxs b/exercises/practice/robot-simulator/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/robot-simulator/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/robot-simulator/boxlang.json b/exercises/practice/robot-simulator/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/robot-simulator/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/robot-simulator/index.cfm b/exercises/practice/robot-simulator/index.cfm deleted file mode 100644 index bb28af8..0000000 --- a/exercises/practice/robot-simulator/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your exercise folder and refresh this page. - diff --git a/exercises/practice/roman-numerals/TestRunner.bxs b/exercises/practice/roman-numerals/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/roman-numerals/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/roman-numerals/boxlang.json b/exercises/practice/roman-numerals/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/roman-numerals/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/roman-numerals/index.cfm b/exercises/practice/roman-numerals/index.cfm deleted file mode 100644 index bb28af8..0000000 --- a/exercises/practice/roman-numerals/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your exercise folder and refresh this page. - diff --git a/exercises/practice/run-length-encoding/TestRunner.bxs b/exercises/practice/run-length-encoding/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/run-length-encoding/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/run-length-encoding/boxlang.json b/exercises/practice/run-length-encoding/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/run-length-encoding/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/run-length-encoding/index.cfm b/exercises/practice/run-length-encoding/index.cfm deleted file mode 100644 index 1e35079..0000000 --- a/exercises/practice/run-length-encoding/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your excercise folder and refresh this page. - diff --git a/exercises/practice/saddle-points/TestRunner.bxs b/exercises/practice/saddle-points/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/saddle-points/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/saddle-points/boxlang.json b/exercises/practice/saddle-points/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/saddle-points/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/saddle-points/index.cfm b/exercises/practice/saddle-points/index.cfm deleted file mode 100644 index 1e35079..0000000 --- a/exercises/practice/saddle-points/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your excercise folder and refresh this page. - diff --git a/exercises/practice/scrabble-score/TestRunner.bxs b/exercises/practice/scrabble-score/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/scrabble-score/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/scrabble-score/boxlang.json b/exercises/practice/scrabble-score/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/scrabble-score/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/scrabble-score/index.cfm b/exercises/practice/scrabble-score/index.cfm deleted file mode 100644 index 1e35079..0000000 --- a/exercises/practice/scrabble-score/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your excercise folder and refresh this page. - diff --git a/exercises/practice/secret-handshake/TestRunner.bxs b/exercises/practice/secret-handshake/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/secret-handshake/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/secret-handshake/boxlang.json b/exercises/practice/secret-handshake/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/secret-handshake/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/secret-handshake/index.cfm b/exercises/practice/secret-handshake/index.cfm deleted file mode 100644 index 1e35079..0000000 --- a/exercises/practice/secret-handshake/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your excercise folder and refresh this page. - diff --git a/exercises/practice/space-age/TestRunner.bxs b/exercises/practice/space-age/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/space-age/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/space-age/boxlang.json b/exercises/practice/space-age/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/space-age/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/space-age/index.cfm b/exercises/practice/space-age/index.cfm deleted file mode 100644 index 1e35079..0000000 --- a/exercises/practice/space-age/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your excercise folder and refresh this page. - diff --git a/exercises/practice/square-root/TestRunner.bxs b/exercises/practice/square-root/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/square-root/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/square-root/boxlang.json b/exercises/practice/square-root/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/square-root/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/square-root/index.cfm b/exercises/practice/square-root/index.cfm deleted file mode 100644 index bb28af8..0000000 --- a/exercises/practice/square-root/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your exercise folder and refresh this page. - diff --git a/exercises/practice/strain/TestRunner.bxs b/exercises/practice/strain/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/strain/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/strain/boxlang.json b/exercises/practice/strain/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/strain/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/strain/index.cfm b/exercises/practice/strain/index.cfm deleted file mode 100644 index bb28af8..0000000 --- a/exercises/practice/strain/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your exercise folder and refresh this page. - diff --git a/exercises/practice/sum-of-multiples/TestRunner.bxs b/exercises/practice/sum-of-multiples/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/sum-of-multiples/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/sum-of-multiples/boxlang.json b/exercises/practice/sum-of-multiples/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/sum-of-multiples/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/sum-of-multiples/index.cfm b/exercises/practice/sum-of-multiples/index.cfm deleted file mode 100644 index 1e35079..0000000 --- a/exercises/practice/sum-of-multiples/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your excercise folder and refresh this page. - diff --git a/exercises/practice/triangle/TestRunner.bxs b/exercises/practice/triangle/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/triangle/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/triangle/boxlang.json b/exercises/practice/triangle/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/triangle/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/triangle/index.cfm b/exercises/practice/triangle/index.cfm deleted file mode 100644 index 1e35079..0000000 --- a/exercises/practice/triangle/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your excercise folder and refresh this page. - diff --git a/exercises/practice/two-fer/TestRunner.bxs b/exercises/practice/two-fer/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/two-fer/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/two-fer/boxlang.json b/exercises/practice/two-fer/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/two-fer/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/two-fer/index.cfm b/exercises/practice/two-fer/index.cfm deleted file mode 100644 index 1e35079..0000000 --- a/exercises/practice/two-fer/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your excercise folder and refresh this page. - diff --git a/exercises/practice/word-count/TestRunner.bxs b/exercises/practice/word-count/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/exercises/practice/word-count/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/exercises/practice/word-count/boxlang.json b/exercises/practice/word-count/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/exercises/practice/word-count/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/exercises/practice/word-count/index.cfm b/exercises/practice/word-count/index.cfm deleted file mode 100644 index 1e35079..0000000 --- a/exercises/practice/word-count/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your excercise folder and refresh this page. - diff --git a/tasks/exercise_template/TestRunner.bxs b/tasks/exercise_template/TestRunner.bxs new file mode 100644 index 0000000..13118d8 --- /dev/null +++ b/tasks/exercise_template/TestRunner.bxs @@ -0,0 +1,46 @@ +exerciseDir = getDirectoryFromPath( getCurrentTemplatePath() ); +localTestBox = exerciseDir & "testbox"; +hiddenTestBox = exerciseDir & ".testbox_cfml"; +testBoxWasHidden = false; +exitCode = 0; + +try { + // CommandBox installs its CFML TestBox dependency here. Hide it while the + // BoxLang module is running so both local test runners can coexist. + if( directoryExists( localTestBox ) ) { + if( directoryExists( hiddenTestBox ) ) { + throw( message = "Both testbox and .testbox_cfml exist. Remove the stale .testbox_cfml directory and try again." ); + } + directoryRename( localTestBox, hiddenTestBox ); + testBoxWasHidden = true; + } + + testBox = new testbox.system.TestBox( reporter = "console" ); + testFiles = directoryList( exerciseDir, false, "name", "*Test.cfc" ); + if( !testFiles.len() ) { + throw( message = "No test files found in " & exerciseDir ); + } + + for( file in testFiles ) { + testBox.addBundles( "exercise." & file.listFirst( "." ) ); + } + + results = testBox.runRaw(); + new testbox.system.reports.ConsoleReporter().runReport( results, testBox, {}, true ); + + if( results.getTotalFail() > 0 || results.getTotalError() > 0 ) { + exitCode = 1; + } +} catch( any e ) { + println( "ERROR: " & e.message ); + if( len( e.detail ?: "" ) ) { + println( e.detail ); + } + exitCode = 1; +} finally { + if( testBoxWasHidden && directoryExists( hiddenTestBox ) ) { + directoryRename( hiddenTestBox, localTestBox ); + } +} + +CLIExit( exitCode ); diff --git a/tasks/exercise_template/boxlang.json b/tasks/exercise_template/boxlang.json new file mode 100644 index 0000000..7b084f8 --- /dev/null +++ b/tasks/exercise_template/boxlang.json @@ -0,0 +1,6 @@ +{ + "mappings": { + "/testbox": "${user-home}/.boxlang/modules/testbox", + "/exercise": "${user-dir}" + } +} diff --git a/tasks/exercise_template/index.cfm b/tasks/exercise_template/index.cfm deleted file mode 100644 index bb28af8..0000000 --- a/tasks/exercise_template/index.cfm +++ /dev/null @@ -1,37 +0,0 @@ - - - - - // get a list of all CFCs in this folder whose name looks like "XXXTest.cfc" - // And turn it into compnent path relative to the web root - url.bundles = directoryList( - path=expandPath( '/' ), - filter='*Test.cfc' ) - .map( function( path ) { - return path - .replaceNoCase( expandPath( '/' ), '' ) - .left( -4 ) - } ) - .toList(); - - - - - - - - Oops, you don't have TestBox installed yet! Please run box install from the root of your exercise folder and refresh this page. -