diff --git a/exercises/hello-world/example.lua b/exercises/hello-world/example.lua index 0529ddfe..801765a5 100644 --- a/exercises/hello-world/example.lua +++ b/exercises/hello-world/example.lua @@ -1,8 +1,7 @@ local hello_world = {} -function hello_world.hello( name ) - if not name or name == '' then name = 'world' end - return 'Hello, ' .. name .. '!' +function hello_world.hello() + return 'Hello, World!' end return hello_world diff --git a/exercises/hello-world/hello-world.lua b/exercises/hello-world/hello-world.lua new file mode 100644 index 00000000..47479c8d --- /dev/null +++ b/exercises/hello-world/hello-world.lua @@ -0,0 +1,18 @@ +-- This is a "stub" file. It's a little start on your solution. +-- It's not a complete solution though; you have to write some code. + +-- Table to be returned by the hello-world module. +local hello_world = {} + +-- Add the hello() function to the table returned by this module. +function hello_world.hello() + -- Write some code here to pass the test suite. + + -- When you have a working solution, REMOVE ALL THE STOCK COMMENTS. + -- They're here to help you get started but they only clutter a finished solution. + -- If you leave them in, reviewers will protest! + return '' +end + +-- Return the hello_world table to make it accessible as a module. +return hello_world diff --git a/exercises/hello-world/hello-world_spec.lua b/exercises/hello-world/hello-world_spec.lua index 5bca2578..bffee5cd 100644 --- a/exercises/hello-world/hello-world_spec.lua +++ b/exercises/hello-world/hello-world_spec.lua @@ -1,18 +1,12 @@ +-- Require the hello-world module local hello_world = require('hello-world') +-- Define a module named hello-world. This module should return a single +-- function named hello that takes no arguments and returns a string. + describe('hello-world', function() - it('says hello world with no name', function() + it('says hello world', function() local result = hello_world.hello() - assert.are.equal('Hello, world!', result) - end) - - it('says hello to Bob', function() - local result = hello_world.hello('Bob') - assert.are.equal('Hello, Bob!', result) - end) - - it('says hello to Sally', function() - local result = hello_world.hello('Sally') - assert.are.equal('Hello, Sally!', result) + assert.are.equal('Hello, World!', result) end) end)