-
-
Notifications
You must be signed in to change notification settings - Fork 2
Two fer #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Two fer #4
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
cdf2792
allow multiple assertions to be loaded from assertions library
TheRealOwenRees fc1b5c6
update arguments in test generator functions
TheRealOwenRees aaf57ea
copy test generators to new exercise
TheRealOwenRees a47fe05
update formatting when multiple tests are needed
TheRealOwenRees 06ec025
updated test formatting
TheRealOwenRees b5b45cd
add two-fer
TheRealOwenRees 3be9210
update test imports
TheRealOwenRees 6b7a83e
new test template for two-fer, with options
TheRealOwenRees 4d8098f
update assertionFunction to accept an array of assertions to use in t…
TheRealOwenRees dacec9f
add two-fer exercise
TheRealOwenRees 55c545f
fix formatting
TheRealOwenRees 8865f17
change difficulty rating of two-fer
TheRealOwenRees 1de39e8
add exercise code stub for student
TheRealOwenRees 18539f1
get slug name from filepath
TheRealOwenRees e64d5b6
move generateTests out of .meta folder and into the test generator fo…
TheRealOwenRees f26effc
reduce test generator files and expose single function from testGener…
TheRealOwenRees File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,17 @@ | ||
| export const slug = 'hello-world'; | ||
| import path from 'node:path'; | ||
| import { fileURLToPath } from 'node:url'; | ||
| import { stringEqual } from "../../../../test_generator/assertions.js"; | ||
| import { generateTests } from '../../../../test_generator/testGenerator.js'; | ||
|
|
||
| export const assertionFunctions = `let stringEqual = (~message=?, a: string, b: string) => | ||
| assertion(~message?, ~operator="stringEqual", (a, b) => a == b, a, b)`; | ||
| const __dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
| const slug = path.basename(path.resolve(__dirname, '..')) | ||
|
|
||
| export const template = (c, moduleName) => { | ||
| return `stringEqual(~message="${c.description}", ${moduleName}.hello(), "${c.expected}")` | ||
| } | ||
| // EDIT THIS WITH YOUR ASSERTIONS | ||
| export const assertionFunctions = [ stringEqual ] | ||
|
|
||
| // EDIT THIS WITH YOUR TEST TEMPLATES | ||
| export const template = (c) => { | ||
| return `stringEqual(~message="${c.description}", hello(), "${c.expected}")` | ||
| } | ||
|
|
||
| generateTests(__dirname, slug, assertionFunctions, template) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,9 @@ | ||
| open Test | ||
| open HelloWorld | ||
|
|
||
| let stringEqual = (~message=?, a: string, b: string) => | ||
| assertion(~message?, ~operator="stringEqual", (a, b) => a == b, a, b) | ||
| let stringEqual = (~message=?, a: string, b: string) => assertion(~message?, ~operator="stringEqual", (a, b) => a == b, a, b) | ||
|
|
||
| test("Say Hi!", () => { | ||
| stringEqual(~message="Say Hi!", HelloWorld.hello(), "Hello, World!") | ||
| }) | ||
| stringEqual(~message="Say Hi!", hello(), "Hello, World!") | ||
| }) | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # Instructions | ||
|
|
||
| Your task is to determine what you will say as you give away the extra cookie. | ||
|
|
||
| If you know the person's name (e.g. if they're named Do-yun), then you will say: | ||
|
|
||
| ```text | ||
| One for Do-yun, one for me. | ||
| ``` | ||
|
|
||
| If you don't know the person's name, you will say _you_ instead. | ||
|
|
||
| ```text | ||
| One for you, one for me. | ||
| ``` | ||
|
|
||
| Here are some examples: | ||
|
|
||
| | Name | Dialogue | | ||
| | :----- | :-------------------------- | | ||
| | Alice | One for Alice, one for me. | | ||
| | Bohdan | One for Bohdan, one for me. | | ||
| | | One for you, one for me. | | ||
| | Zaphod | One for Zaphod, one for me. | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| # Introduction | ||
|
|
||
| In some English accents, when you say "two for" quickly, it sounds like "two fer". | ||
| Two-for-one is a way of saying that if you buy one, you also get one for free. | ||
| So the phrase "two-fer" often implies a two-for-one offer. | ||
|
|
||
| Imagine a bakery that has a holiday offer where you can buy two cookies for the price of one ("two-fer one!"). | ||
| You take the offer and (very generously) decide to give the extra cookie to someone else in the queue. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| let twoFer = name => { | ||
| switch name { | ||
| | None => "One for you, one for me." | ||
| | Some(nameString) => "One for " ++ nameString ++ ", one for me." | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| { | ||
| "authors": [ | ||
| "tejasbubane", | ||
| "therealowenrees" | ||
| ], | ||
| "files": { | ||
| "solution": [ | ||
| "src/TwoFer.res" | ||
| ], | ||
| "test": [ | ||
| "tests/TwoFer_test.res" | ||
| ], | ||
| "example": [ | ||
| ".meta/TwoFer.res" | ||
| ], | ||
| "editor": [ | ||
| "src/TwoFer.resi" | ||
| ] | ||
| }, | ||
| "blurb": "Create a sentence of the form \"One for X, one for me.\".", | ||
| "source_url": "https://github.com/exercism/problem-specifications/issues/757" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import path from 'node:path'; | ||
| import { fileURLToPath } from 'node:url'; | ||
| import { stringEqual } from "../../../../test_generator/assertions.js"; | ||
| import { generateTests } from '../../../../test_generator/testGenerator.js'; | ||
|
|
||
| const __dirname = path.dirname(fileURLToPath(import.meta.url)); | ||
| const slug = path.basename(path.resolve(__dirname, '..')) | ||
|
|
||
| // EDIT THIS WITH YOUR ASSERTIONS | ||
| export const assertionFunctions = [ stringEqual ] | ||
|
|
||
| // EDIT THIS WITH YOUR TEST TEMPLATES | ||
| export const template = (c) => { | ||
| if (c.input.name) { | ||
| return `stringEqual(~message="${c.description}", twoFer(Some("${c.input.name}")), "${c.expected}")` | ||
| } else { | ||
| return `stringEqual(~message="${c.description}", twoFer(None), "${c.expected}")` | ||
| } | ||
| } | ||
|
|
||
| generateTests(__dirname, slug, assertionFunctions, template) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| # 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. | ||
|
|
||
| [1cf3e15a-a3d7-4a87-aeb3-ba1b43bc8dce] | ||
| description = "no name given" | ||
|
|
||
| [b4c6dbb8-b4fb-42c2-bafd-10785abe7709] | ||
| description = "a name given" | ||
|
|
||
| [3549048d-1a6e-4653-9a79-b0bda163e8d5] | ||
| description = "another name given" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "name": "@exercism/rescript", | ||
| "sources": [ | ||
| { "dir": "src", "subdirs": true, "type": "dev" }, | ||
| { "dir": "tests", "subdirs": true, "type": "dev" } | ||
| ], | ||
| "package-specs": [ | ||
| { | ||
| "module": "esmodule", | ||
| "in-source": true | ||
| } | ||
| ], | ||
| "suffix": ".res.js", | ||
| "dev-dependencies": ["rescript-test"] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| let twoFer = _ => panic("'twoFer not yet implemented") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| let twoFer: option<string> => string |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| open Test | ||
| open TwoFer | ||
|
|
||
| let stringEqual = (~message=?, a: string, b: string) => assertion(~message?, ~operator="stringEqual", (a, b) => a == b, a, b) | ||
|
|
||
| test("no name given", () => { | ||
| stringEqual(~message="no name given", twoFer(None), "One for you, one for me.") | ||
| }) | ||
|
|
||
| test("a name given", () => { | ||
| stringEqual(~message="a name given", twoFer(Some("Alice")), "One for Alice, one for me.") | ||
| }) | ||
|
|
||
| test("another name given", () => { | ||
| stringEqual(~message="another name given", twoFer(Some("Bob")), "One for Bob, one for me.") | ||
| }) | ||
|
|
Submodule problem-specifications
added at
0ebef3
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
TheRealOwenRees marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.