🎉 Exercism Research is now launched. Help Exercism, help science and have some fun at research.exercism.io 🎉
Avatar of cedricvaneer

cedricvaneer's solution

to Acronym in the CFML Track

Published at Dec 03 2019 · 0 comments
Test suite

Convert a phrase to its acronym.

Techies love their TLA (Three Letter Acronyms)!

Help generate some jargon by writing a program that converts a long name like Portable Network Graphics to its acronym (PNG).

To run the code in this exercise, you will only need to have CommandBox CLI installed. This binary runs CFML code from the command line.

To run the tests, cd into the exercise folder and run the following:

box task run TestRunner
# Or start up a test watcher that will rerun when files change
box task run TestRunner --:watcher

The tests leverage a library called TestBox which supports xUnit and BDD style of testing. All test suites will be written in the BDD style which uses closures to define test specs. You won't need to worry about installing TestBox. The CLI test runner will take care of that for you. You just need to be connected to the internet the first time you run it. You can read more about it here:



Julien Vanier https://github.com/monkbroc

Submitting Incomplete Solutions

It's possible to submit an incomplete solution so you can see how others have completed the exercise.


component extends="testbox.system.BaseSpec" {

	function beforeAll(){
	  SUT = createObject( 'Acronym' );

	function run(){
		describe( "My Acronym class", function(){			

			describe( 'Abbreviate a phrase', function(){

				it( 'basic', function(){
					expect( SUT.abbreviate( phrase='Portable Network Graphics' ) ).toBe( 'PNG' );

				it( 'lowercase words', function(){
					expect( SUT.abbreviate( phrase='Ruby on Rails' ) ).toBe( 'ROR' );

				it( 'punctuation', function(){
					expect( SUT.abbreviate( phrase='First In,  First Out' ) ).toBe( 'FIFO' );

				it( 'all caps word', function(){
					expect( SUT.abbreviate( phrase='GNU Image Manipulation Program' ) ).toBe( 'GIMP' );

				it( 'punctuation without whitespace', function(){
					expect( SUT.abbreviate( phrase='Complementary metal-oxide semiconductor' ) ).toBe( 'CMOS' );




component extends="AcronymTest" {

	function beforeAll(){
	  SUT = createObject( 'Solution' );

* Your implmentation of the Acronym exercise
component {
	* @phrase phrase to abbreviate
	* @returns acronym of the @phrase
	public string function abbreviate( required string phrase ) {
		var acronym = "";
		var arrayOfWords = listToArray(arguments.phrase, " ,.-_?!':;")
		for (var word in arrayOfWords){
			acronym &= left(word, 1);

		return uCase(acronym);

Community comments

Find this solution interesting? Ask the author a question to learn more.

What can you learn from this solution?

A huge amount can be learned from reading other people’s code. This is why we wanted to give exercism users the option of making their solutions public.

Here are some questions to help you reflect on this solution and learn the most from it.

  • What compromises have been made?
  • Are there new concepts here that you could read more about to improve your understanding?