-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
Sync and re-implement rna-transcription #169
Merged
keiravillekode
merged 2 commits into
exercism:main
from
keiravillekode:sync-rna-transcription
Jul 28, 2024
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 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 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 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 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,29 +1,26 @@ | ||
module Main | ||
|
||
import Data.Vect | ||
import RnaTranscription | ||
import System | ||
import Tester | ||
import Tester.Runner | ||
|
||
assertCase : Eq b => (a -> b) -> (String, a, b) -> IO () | ||
assertCase fn (desc,given,expected) = do | ||
putStrLn desc | ||
if fn given == expected | ||
then putStrLn " Test Passed" | ||
else do | ||
putStrLn " Test Failed" | ||
exitFailure | ||
|
||
import RnaTranscription | ||
import Data.Vect | ||
|
||
testCases : List (n : Nat ** (String, Vect n DnaStrand, Vect n RnaStrand)) | ||
testCases = [(_ ** ("Empty RNA sequence", [], [])), | ||
(_ ** ("RNA complement of cytosine is guanine", [C], [G])), | ||
(_ ** ("RNA complement of guanine is cytosine", [G], [C])), | ||
(_ ** ("RNA complement of thymine is adenine", [T], [A])), | ||
(_ ** ("RNA complement of adenine is uracil", [A], [U])), | ||
(_ ** ("RNA complement", [A,C,G,T,G,G,T,C,T,T,A,A], [U,G,C,A,C,C,A,G,A,A,U,U]))] | ||
tests : List Test | ||
tests = | ||
[ test "Empty RNA sequence" (assertEq (toRna []) (the (Vect 0 RnaStrand) [])) | ||
, test "RNA complement of cytosine is guanine" (assertEq (toRna [C]) [G]) | ||
, test "RNA complement of guanine is cytosine" (assertEq (toRna [G]) [C]) | ||
, test "RNA complement of thymine is adenine" (assertEq (toRna [T]) [A]) | ||
, test "RNA complement of adenine is uracil" (assertEq (toRna [A]) [U]) | ||
, test "RNA complement" (assertEq (toRna [A, C, G, T, G, G, T, C, T, T, A, A]) [U, G, C, A, C, C, A, G, A, A, U, U]) | ||
] | ||
|
||
export | ||
main : IO () | ||
main = traverse_ testCase' testCases | ||
where testCase' : (n : Nat ** (String, Vect n DnaStrand, Vect n RnaStrand)) -> IO () | ||
testCase' (x ** pf) = assertCase toRna pf | ||
|
||
main = do | ||
success <- runTests tests | ||
if success | ||
then putStrLn "All tests passed" | ||
else exitFailure |
This file contains 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,5 +1,6 @@ | ||
package rna-transcription-test | ||
depends = rna-transcription | ||
, tester | ||
main = Main | ||
executable = "rna-transcription-test" | ||
sourcedir = "src" |
This file contains 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 @@ | ||
|
||
def header(): | ||
return "import Data.Vect\n" | ||
|
||
def generate_test(case): | ||
def to_vect(proteins): | ||
return str(list(proteins)).replace("'", "") | ||
|
||
property = case["property"] | ||
expected = to_vect(case["expected"]) | ||
if expected == "[]": | ||
expected = "(the (Vect 0 RnaStrand) [])" | ||
dna = to_vect(case["input"]["dna"]) | ||
|
||
return f'assertEq ({property} {dna}) {expected}' |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this, a student can change
to
and provide a solution using lists.
It isn't a major problem - when a student cheats, they are only cheating themselves - but we eliminate this kind of cheating by expecting a
Vect
There are still other ways of cheating like defining
Eq RnaStrand
to always returnTrue