about summary refs log tree commit diff stats
path: root/resources
Commit message (Expand)AuthorAgeFilesLines
* Read from file if passed, modify USAGEAndinus2021-01-201-0/+4
* Re-structure for CPAN upload, include a dictionary file v0.1.0Andinus2021-01-192-0/+355136
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92



























































































                                                                                                             
# Getting Started

These exercises lean on Test-Driven Development (TDD), but they're not
an exact match.

The following steps assume that you are in the same directory as the exercise.

You must have Rust installed.
Follow the [Installation chapter in the Rust book](https://doc.rust-lang.org/book/ch01-01-installation.html).
The [Rust language section](http://exercism.io/languages/rust)
section from exercism is also useful.

## Step 1

Run the test suite. It can be run with `cargo`, which is installed with Rust.

```sh
$ cargo test
```

This will compile the `hello-world` crate and run the test, which fails.

```sh
running 1 test
test test_hello_world ... FAILED

failures:

---- test_hello_world stdout ----
thread 'test_hello_world' panicked at 'assertion failed: `(left == right)`
(left: `"Hello, World!"`, right: `"Goodbye, World!"`)', tests/hello-world.rs:5

failures:
    test_hello_world

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured
```

### Understanding Test Failures

The `test_hello_world` failure states that it is expecting the value,
`"Hello, World!"`, to be returned from `hello()`.
The left side of the assertion (at line 5) should be equal to the right side.

```sh
---- test_hello_world stdout ----
thread 'test_hello_world' panicked at 'assertion failed: `(left == right)`
(left: `"Hello, World!"`, right: `"Goodbye, World!"`)', tests/hello-world.rs:5
```

### Fixing the Error

To fix it, open up `src/lib.rs` and change the `hello` function to return
`"Hello, World!"` instead of `"Goodbye, World!"`.

```rust
pub fn hello() -> &'static str {
    "Hello, World!"
}
```

## Step 2

Run the test again. This time, it will pass.

```sh
running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured

     Running target/debug/deps/hello_world-bd1f06dc726ef14f

running 1 test
test test_hello_world ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured

   Doc-tests hello-world

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
```

## Submit

Once the test is passing, you can submit your code with the following
command:

```sh
$ exercism submit src/lib.rs
```