-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7ec058f
commit 43a00e5
Showing
24 changed files
with
91 additions
and
4 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions
1
tests/exercises/echo-function-file-output/evaluation/contents.txt
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 @@ | ||
Hallo |
7 changes: 7 additions & 0 deletions
7
tests/exercises/echo-function-file-output/evaluation/one.yaml
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,7 @@ | ||
- tab: "Test" | ||
testcases: | ||
- statement: echo_function("result.txt", "Hallo") | ||
file: | ||
content: "contents.txt" | ||
location: "result.txt" | ||
oracle: builtin |
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,7 @@ | ||
#include <stdio.h> | ||
|
||
void echo_function(const char *filename, const char *string) { | ||
FILE *file = fopen(filename, "w"); | ||
fprintf(file, "%s\n", string); | ||
fclose(file); | ||
} |
12 changes: 12 additions & 0 deletions
12
tests/exercises/echo-function-file-output/solution/correct.cs
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,12 @@ | ||
using System.IO; | ||
|
||
class Submission | ||
{ | ||
public static void EchoFunction(string filename, string stringToWrite) | ||
{ | ||
using (StreamWriter writer = new StreamWriter(filename)) | ||
{ | ||
writer.WriteLine(stringToWrite); | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
tests/exercises/echo-function-file-output/solution/correct.hs
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,7 @@ | ||
import System.IO (writeFile) | ||
|
||
echoFunction :: FilePath -> String -> IO () | ||
echoFunction filename content = do | ||
let contentWithNewline = content ++ "\n" | ||
writeFile filename contentWithNewline | ||
return () |
15 changes: 15 additions & 0 deletions
15
tests/exercises/echo-function-file-output/solution/correct.java
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 @@ | ||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
|
||
public class Submission { | ||
|
||
public static void echoFunction(String filename, String stringToWrite) { | ||
try (FileWriter writer = new FileWriter(filename)) { | ||
writer.write(stringToWrite); | ||
writer.write(System.lineSeparator()); // Add a newline | ||
} catch (IOException e) { | ||
System.err.println("Error writing to file: " + e.getMessage()); | ||
} | ||
} | ||
} | ||
|
5 changes: 5 additions & 0 deletions
5
tests/exercises/echo-function-file-output/solution/correct.js
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,5 @@ | ||
const fs = require('fs'); | ||
|
||
function echoFunction(filename, stringToWrite) { | ||
fs.writeFileSync(filename, stringToWrite + '\n', { flag: 'w' }); | ||
} |
5 changes: 5 additions & 0 deletions
5
tests/exercises/echo-function-file-output/solution/correct.kt
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,5 @@ | ||
import java.io.File | ||
|
||
fun echoFunction(filename: String, stringToWrite: String) { | ||
File(filename).writeText(stringToWrite + "\n") | ||
} |
3 changes: 3 additions & 0 deletions
3
tests/exercises/echo-function-file-output/solution/correct.py
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,3 @@ | ||
def echo_function(filename, string_to_write): | ||
with open(filename, 'w') as file: | ||
file.write(string_to_write + '\n') # Write the string and a newline) |
4 changes: 4 additions & 0 deletions
4
tests/exercises/echo-function-file-output/solution/correct.sh
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,4 @@ | ||
echo_function() { | ||
echo "$2" > "$1" | ||
} | ||
|
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 |
---|---|---|
|
@@ -3,4 +3,3 @@ | |
- testcases: | ||
- expression: 'echo("input-1")' | ||
return: !object {} | ||
|
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