2017-08-15

This commit is contained in:
2017-08-15 10:04:10 -05:00
parent 63b955575a
commit 88b47de8c8
24 changed files with 3100 additions and 0 deletions

31
r/hello-world/README.md Normal file
View 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.

View File

@@ -0,0 +1,3 @@
hello_world <- function() {
}

View 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")