From e3e8580f58f3b892f1f0aeffee87d1876f58c15b Mon Sep 17 00:00:00 2001 From: Nenad Date: Tue, 18 Jun 2024 06:20:05 +0200 Subject: [PATCH] add hello-world exercise + format config.json --- .../hello-world/.docs/instructions.md | 16 +++++++++++++++ .../practice/hello-world/.meta/config.json | 20 +++++++++++++++++++ .../practice/hello-world/.meta/example.cairo | 3 +++ .../practice/hello-world/.meta/tests.toml | 13 ++++++++++++ exercises/practice/hello-world/Scarb.toml | 4 ++++ exercises/practice/hello-world/src/lib.cairo | 4 ++++ .../practice/hello-world/src/tests.cairo | 7 +++++++ 7 files changed, 67 insertions(+) create mode 100644 exercises/practice/hello-world/.docs/instructions.md create mode 100644 exercises/practice/hello-world/.meta/config.json create mode 100644 exercises/practice/hello-world/.meta/example.cairo create mode 100644 exercises/practice/hello-world/.meta/tests.toml create mode 100644 exercises/practice/hello-world/Scarb.toml create mode 100644 exercises/practice/hello-world/src/lib.cairo create mode 100644 exercises/practice/hello-world/src/tests.cairo diff --git a/exercises/practice/hello-world/.docs/instructions.md b/exercises/practice/hello-world/.docs/instructions.md new file mode 100644 index 00000000..c9570e48 --- /dev/null +++ b/exercises/practice/hello-world/.docs/instructions.md @@ -0,0 +1,16 @@ +# Instructions + +The classical introductory exercise. +Just say "Hello, World!". + +["Hello, World!"][hello-world] is the traditional first program for beginning programming in a new language or environment. + +The objectives are simple: + +- Modify the provided code so that it produces 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. + +[hello-world]: https://en.wikipedia.org/wiki/%22Hello,_world!%22_program diff --git a/exercises/practice/hello-world/.meta/config.json b/exercises/practice/hello-world/.meta/config.json new file mode 100644 index 00000000..c7e88cfb --- /dev/null +++ b/exercises/practice/hello-world/.meta/config.json @@ -0,0 +1,20 @@ +{ + "authors": [ + "misicnenad" + ], + "files": { + "solution": [ + "src/lib.cairo", + "Scarb.toml" + ], + "test": [ + "src/tests.cairo" + ], + "example": [ + ".meta/example.cairo" + ] + }, + "blurb": "Exercism's classic introductory exercise. Just say \"Hello, World!\".", + "source": "This is an exercise to introduce users to using Exercism", + "source_url": "https://en.wikipedia.org/wiki/%22Hello,_world!%22_program" +} diff --git a/exercises/practice/hello-world/.meta/example.cairo b/exercises/practice/hello-world/.meta/example.cairo new file mode 100644 index 00000000..d203326b --- /dev/null +++ b/exercises/practice/hello-world/.meta/example.cairo @@ -0,0 +1,3 @@ +fn hello() -> ByteArray { + "Hello, World!" +} diff --git a/exercises/practice/hello-world/.meta/tests.toml b/exercises/practice/hello-world/.meta/tests.toml new file mode 100644 index 00000000..73466d67 --- /dev/null +++ b/exercises/practice/hello-world/.meta/tests.toml @@ -0,0 +1,13 @@ +# This is an auto-generated file. +# +# Regenerating this file via `configlet sync` will: +# - Recreate every `description` key/value pair +# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications +# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) +# - Preserve any other key/value pair +# +# As user-added comments (using the # character) will be removed when this file +# is regenerated, comments can be added via a `comment` key. + +[af9ffe10-dc13-42d8-a742-e7bdafac449d] +description = "Say Hi!" diff --git a/exercises/practice/hello-world/Scarb.toml b/exercises/practice/hello-world/Scarb.toml new file mode 100644 index 00000000..c09a6b38 --- /dev/null +++ b/exercises/practice/hello-world/Scarb.toml @@ -0,0 +1,4 @@ +[package] +name = "hello_world" +version = "0.1.0" +edition = "2023_11" diff --git a/exercises/practice/hello-world/src/lib.cairo b/exercises/practice/hello-world/src/lib.cairo new file mode 100644 index 00000000..e69c7b64 --- /dev/null +++ b/exercises/practice/hello-world/src/lib.cairo @@ -0,0 +1,4 @@ +// ByteArray is a string that's not limited to 31 characters, you'll learn more about this later +fn hello() -> ByteArray { + "Goodbye, Mars!" +} diff --git a/exercises/practice/hello-world/src/tests.cairo b/exercises/practice/hello-world/src/tests.cairo new file mode 100644 index 00000000..babf4ce3 --- /dev/null +++ b/exercises/practice/hello-world/src/tests.cairo @@ -0,0 +1,7 @@ +#[cfg(test)] +mod tests { + #[test] + fn hello_world() { + assert_eq!(hello_world::hello(), "Hello, World!"); + } +}