Skip to content

Commit

Permalink
update example with more languages
Browse files Browse the repository at this point in the history
  • Loading branch information
ettoreleandrotognoli committed Jun 28, 2023
1 parent fc3090c commit 10d9a41
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion example/src/quiz.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
[[questions]]
type = "MultipleChoice"
prompt.prompt = "What does it mean if a variable `x` is immutable?"
prompt.prompt = """
What does it mean if a variable `x` is immutable?
Rust:
```rust
let x = 0;
```
C++:
```cpp
const int x = 0;
```
Java:
```java
final int x = 0;
```
"""
answer.answer = "`x` cannot be changed after being assigned to a value."
prompt.distractors = [
"`x` is stored in the immutable region of memory.",
Expand Down Expand Up @@ -34,4 +51,24 @@ answer.doesCompile = false
answer.lineNumber = 4
context = """
This is a compiler error because line 4 tries to mutate `x` when `x` is not marked as `mut`.
"""

[[questions]]
type = "Tracing"
prompt.language="cpp"
prompt.program = """
#include <iostream>
int main() {
const int x = 1;
std::cout << x << std::endl;
x += 1;
std::cout << x << std::endl;
}
"""
answer.doesCompile = false
answer.lineNumber = 6
context = """
This is a compiler error because line 64 tries to mutate `x` when `x` is marked as `const`.
"""

0 comments on commit 10d9a41

Please sign in to comment.