-
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.
Merge pull request #535 from dodona-edu/feature/files-in-dsl
Add support for file evaluation in DSL
- Loading branch information
Showing
29 changed files
with
362 additions
and
20 deletions.
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
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()); | ||
} | ||
} | ||
} | ||
|
Oops, something went wrong.