2017-08-15
This commit is contained in:
31
r/hello-world/README.md
Normal file
31
r/hello-world/README.md
Normal file
@@ -0,0 +1,31 @@
|
||||
# Hello World
|
||||
|
||||
The classical introductory exercise. Just say "Hello, World!".
|
||||
|
||||
["Hello, World!"](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program) is
|
||||
the traditional first program for beginning programming in a new language
|
||||
or environment.
|
||||
|
||||
The objectives are simple:
|
||||
|
||||
- Write a function that returns the string "Hello, World!".
|
||||
- Run the test suite and make sure that it succeeds.
|
||||
- Submit your solution and check it at the website.
|
||||
|
||||
If everything goes well, you will be ready to fetch your first real exercise.
|
||||
|
||||
## Installation
|
||||
See [this guide](https://github.com/exercism/xr/blob/master/docs/INSTALLATION.md) for instructions on how to setup your local R environment.
|
||||
|
||||
## How to implement your solution
|
||||
In each problem folder, there is a file named `<exercise_name>.R` containing a function that returns a `NULL` value. Place your implementation inside the body of the function.
|
||||
|
||||
## How to run tests
|
||||
Inside of RStudio, simply execute the `test_<exercise_name>.R` script. This can be conveniently done with [testthat's `auto_test` function](https://www.rdocumentation.org/packages/testthat/topics/auto_test). Because exercism code and tests are in the same folder, use this same path for both `code_path` and `test_path` parameters. On the command-line, you can also run `Rscript test_<exercise_name>.R`.
|
||||
|
||||
## Source
|
||||
|
||||
This is an exercise to introduce users to using Exercism [http://en.wikipedia.org/wiki/%22Hello,_world!%22_program](http://en.wikipedia.org/wiki/%22Hello,_world!%22_program)
|
||||
|
||||
## Submitting Incomplete Solutions
|
||||
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
|
3
r/hello-world/hello-world.R
Normal file
3
r/hello-world/hello-world.R
Normal file
@@ -0,0 +1,3 @@
|
||||
hello_world <- function() {
|
||||
|
||||
}
|
16
r/hello-world/test_hello-world.R
Normal file
16
r/hello-world/test_hello-world.R
Normal file
@@ -0,0 +1,16 @@
|
||||
source("./hello-world.R")
|
||||
library(testthat)
|
||||
|
||||
test_that("no name", {
|
||||
expect_equal(hello_world(), "Hello, World!")
|
||||
})
|
||||
|
||||
test_that("sample name", {
|
||||
expect_equal(hello_world("Alice"), "Hello, Alice!")
|
||||
})
|
||||
|
||||
test_that("other sample name", {
|
||||
expect_equal(hello_world("Bob"), "Hello, Bob!")
|
||||
})
|
||||
|
||||
message("All tests passed for exercise: hello-world")
|
Reference in New Issue
Block a user