Skip to content

Commit c7a6d89

Browse files
committed
test: update fixtures
1 parent 0533fa3 commit c7a6d89

File tree

2 files changed

+36
-38
lines changed

2 files changed

+36
-38
lines changed

internal/test_helpers/fixtures/pass_functions

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ Debug = true
55
[stage-9] [test-1] Writing contents to ./test.lox:
66
[stage-9] [test-1] [test.lox] print clock() + 23;
77
[stage-9] [test-1] $ ./your_program.sh run test.lox
8-
[your_program] 1.731520035676E9
9-
[stage-9] [test-1] ✓ 1731520035.676000
8+
[your_program] 1.731566537833E9
9+
[stage-9] [test-1] ✓ 1731566537.833000
1010
[stage-9] [test-1] ✓ 1 line(s) match on stdout
1111
[stage-9] [test-1] ✓ Received exit code 0.
1212
[stage-9] [test-2] Running test case: 2
1313
[stage-9] [test-2] Writing contents to ./test.lox:
1414
[stage-9] [test-2] [test.lox] print clock() / 1000;
1515
[stage-9] [test-2] $ ./your_program.sh run test.lox
16-
[your_program] 1731520.012833
17-
[stage-9] [test-2] ✓ 1731520.012833
16+
[your_program] 1731566.514949
17+
[stage-9] [test-2] ✓ 1731566.514949
1818
[stage-9] [test-2] ✓ 1 line(s) match on stdout
1919
[stage-9] [test-2] ✓ Received exit code 0.
2020
[stage-9] [test-3] Running test case: 3
@@ -83,24 +83,23 @@ Debug = true
8383
[stage-8] [test-3] ✓ Received exit code 0.
8484
[stage-8] [test-4] Running test case: 4
8585
[stage-8] [test-4] Writing contents to ./test.lox:
86-
[stage-8] [test-4] [test.lox] // This program demonstrates the use of recursive functions to determine if a number is even or odd.
87-
[stage-8] [test-4] [test.lox] // This is a classic example of mutual recursion.
88-
[stage-8] [test-4] [test.lox] fun isEven(n) {
89-
[stage-8] [test-4] [test.lox] if (n == 0) return true;
90-
[stage-8] [test-4] [test.lox] return isOdd(n - 1);
86+
[stage-8] [test-4] [test.lox] // This program calculates the cumulative sum of numbers from 1 to n.
87+
[stage-8] [test-4] [test.lox] fun cumulative_sum() {
88+
[stage-8] [test-4] [test.lox] var n = 10; // Fixed value
89+
[stage-8] [test-4] [test.lox] var total = 0;
90+
[stage-8] [test-4] [test.lox] var i = 1;
91+
[stage-8] [test-4] [test.lox] while (i <= n) {
92+
[stage-8] [test-4] [test.lox] total = total + i;
93+
[stage-8] [test-4] [test.lox] i = i + 1;
94+
[stage-8] [test-4] [test.lox] }
95+
[stage-8] [test-4] [test.lox] print "The cumulative sum from 1 to 10 is: ";
96+
[stage-8] [test-4] [test.lox] print total;
9197
[stage-8] [test-4] [test.lox] }
9298
[stage-8] [test-4] [test.lox]
93-
[stage-8] [test-4] [test.lox] fun isOdd(n) {
94-
[stage-8] [test-4] [test.lox] if (n == 0) return false;
95-
[stage-8] [test-4] [test.lox] return isEven(n - 1);
96-
[stage-8] [test-4] [test.lox] }
97-
[stage-8] [test-4] [test.lox]
98-
[stage-8] [test-4] [test.lox] print isEven(19);
99-
[stage-8] [test-4] [test.lox] print isOdd(43);
100-
[stage-8] [test-4] [test.lox]
99+
[stage-8] [test-4] [test.lox] cumulative_sum();
101100
[stage-8] [test-4] $ ./your_program.sh run test.lox
102-
[your_program] false
103-
[your_program] true
101+
[your_program] The cumulative sum from 1 to 10 is:
102+
[your_program] 55
104103
[stage-8] [test-4] ✓ 2 line(s) match on stdout
105104
[stage-8] [test-4] ✓ Received exit code 0.
106105
[stage-8] Test passed.

internal/test_helpers/fixtures/pass_functions_final

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ Debug = true
55
[stage-9] [test-1] Writing contents to ./test.lox:
66
[stage-9] [test-1] [test.lox] print clock() + 23;
77
[stage-9] [test-1] $ ./your_program.sh run test.lox
8-
[your_program] 1.731520075985E9
9-
[stage-9] [test-1] ✓ 1731520075.985000
8+
[your_program] 1.731566502731E9
9+
[stage-9] [test-1] ✓ 1731566502.731000
1010
[stage-9] [test-1] ✓ 1 line(s) match on stdout
1111
[stage-9] [test-1] ✓ Received exit code 0.
1212
[stage-9] [test-2] Running test case: 2
1313
[stage-9] [test-2] Writing contents to ./test.lox:
1414
[stage-9] [test-2] [test.lox] print clock() / 1000;
1515
[stage-9] [test-2] $ ./your_program.sh run test.lox
16-
[your_program] 1731520.053144
17-
[stage-9] [test-2] ✓ 1731520.053144
16+
[your_program] 1731566.4798410002
17+
[stage-9] [test-2] ✓ 1731566.479841
1818
[stage-9] [test-2] ✓ 1 line(s) match on stdout
1919
[stage-9] [test-2] ✓ Received exit code 0.
2020
[stage-9] [test-3] Running test case: 3
@@ -83,24 +83,23 @@ Debug = true
8383
[stage-8] [test-3] ✓ Received exit code 0.
8484
[stage-8] [test-4] Running test case: 4
8585
[stage-8] [test-4] Writing contents to ./test.lox:
86-
[stage-8] [test-4] [test.lox] // This program demonstrates the use of recursive functions to determine if a number is even or odd.
87-
[stage-8] [test-4] [test.lox] // This is a classic example of mutual recursion.
88-
[stage-8] [test-4] [test.lox] fun isEven(n) {
89-
[stage-8] [test-4] [test.lox] if (n == 0) return true;
90-
[stage-8] [test-4] [test.lox] return isOdd(n - 1);
86+
[stage-8] [test-4] [test.lox] // This program calculates the cumulative sum of numbers from 1 to n.
87+
[stage-8] [test-4] [test.lox] fun cumulative_sum() {
88+
[stage-8] [test-4] [test.lox] var n = 10; // Fixed value
89+
[stage-8] [test-4] [test.lox] var total = 0;
90+
[stage-8] [test-4] [test.lox] var i = 1;
91+
[stage-8] [test-4] [test.lox] while (i <= n) {
92+
[stage-8] [test-4] [test.lox] total = total + i;
93+
[stage-8] [test-4] [test.lox] i = i + 1;
94+
[stage-8] [test-4] [test.lox] }
95+
[stage-8] [test-4] [test.lox] print "The cumulative sum from 1 to 10 is: ";
96+
[stage-8] [test-4] [test.lox] print total;
9197
[stage-8] [test-4] [test.lox] }
9298
[stage-8] [test-4] [test.lox]
93-
[stage-8] [test-4] [test.lox] fun isOdd(n) {
94-
[stage-8] [test-4] [test.lox] if (n == 0) return false;
95-
[stage-8] [test-4] [test.lox] return isEven(n - 1);
96-
[stage-8] [test-4] [test.lox] }
97-
[stage-8] [test-4] [test.lox]
98-
[stage-8] [test-4] [test.lox] print isEven(19);
99-
[stage-8] [test-4] [test.lox] print isOdd(43);
100-
[stage-8] [test-4] [test.lox]
99+
[stage-8] [test-4] [test.lox] cumulative_sum();
101100
[stage-8] [test-4] $ ./your_program.sh run test.lox
102-
[your_program] false
103-
[your_program] true
101+
[your_program] The cumulative sum from 1 to 10 is:
102+
[your_program] 55
104103
[stage-8] [test-4] ✓ 2 line(s) match on stdout
105104
[stage-8] [test-4] ✓ Received exit code 0.
106105
[stage-8] Test passed.

0 commit comments

Comments
 (0)