Skip to content

Commit 367c381

Browse files
authored
Merge pull request #92 from codecrafters-io/ryan-branch
Remove Closure use, before it's introduced
2 parents 8065253 + 9704c6f commit 367c381

File tree

3 files changed

+12
-38
lines changed

3 files changed

+12
-38
lines changed

internal/test_helpers/fixtures/pass_functions

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,9 @@ Debug = true
372372
[tester::#EY3] [test-4.lox] // This program creates a function that returns
373373
[tester::#EY3] [test-4.lox] // another function
374374
[tester::#EY3] [test-4.lox] // and uses it to filter a list of numbers
375-
[tester::#EY3] [test-4.lox] fun makeFilter(min) {
375+
[tester::#EY3] [test-4.lox] fun makeFilter() {
376376
[tester::#EY3] [test-4.lox]  fun filter(n) {
377-
[tester::#EY3] [test-4.lox]  if (n < min) {
377+
[tester::#EY3] [test-4.lox]  if (n < 54) {
378378
[tester::#EY3] [test-4.lox]  return false;
379379
[tester::#EY3] [test-4.lox]  }
380380
[tester::#EY3] [test-4.lox]  return true;
@@ -394,14 +394,10 @@ Debug = true
394394
[tester::#EY3] [test-4.lox]  }
395395
[tester::#EY3] [test-4.lox] }
396396
[tester::#EY3] [test-4.lox] 
397-
[tester::#EY3] [test-4.lox] var greaterThanX = makeFilter(54);
398-
[tester::#EY3] [test-4.lox] var greaterThanY = makeFilter(44);
397+
[tester::#EY3] [test-4.lox] var greaterThanX = makeFilter();
399398
[tester::#EY3] [test-4.lox] 
400399
[tester::#EY3] [test-4.lox] print "Numbers >= 54:";
401400
[tester::#EY3] [test-4.lox] applyToNumbers(greaterThanX, 54 + 6);
402-
[tester::#EY3] [test-4.lox] 
403-
[tester::#EY3] [test-4.lox] print "Numbers >= 44:";
404-
[tester::#EY3] [test-4.lox] applyToNumbers(greaterThanY, 44 + 6);
405401
[tester::#EY3] [test-4] $ ./your_program.sh run test.lox
406402
[your_program] Numbers >= 54:
407403
[your_program] 54
@@ -410,14 +406,7 @@ Debug = true
410406
[your_program] 57
411407
[your_program] 58
412408
[your_program] 59
413-
[your_program] Numbers >= 44:
414-
[your_program] 44
415-
[your_program] 45
416-
[your_program] 46
417-
[your_program] 47
418-
[your_program] 48
419-
[your_program] 49
420-
[tester::#EY3] [test-4] ✓ 14 line(s) match on stdout
409+
[tester::#EY3] [test-4] ✓ 7 line(s) match on stdout
421410
[tester::#EY3] [test-4] ✓ Received exit code 0.
422411
[tester::#EY3] Test passed.
423412

internal/test_helpers/fixtures/pass_functions_final

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,9 @@ Debug = true
372372
[tester::#EY3] [test-4.lox] // This program creates a function that returns
373373
[tester::#EY3] [test-4.lox] // another function
374374
[tester::#EY3] [test-4.lox] // and uses it to filter a list of numbers
375-
[tester::#EY3] [test-4.lox] fun makeFilter(min) {
375+
[tester::#EY3] [test-4.lox] fun makeFilter() {
376376
[tester::#EY3] [test-4.lox]  fun filter(n) {
377-
[tester::#EY3] [test-4.lox]  if (n < min) {
377+
[tester::#EY3] [test-4.lox]  if (n < 54) {
378378
[tester::#EY3] [test-4.lox]  return false;
379379
[tester::#EY3] [test-4.lox]  }
380380
[tester::#EY3] [test-4.lox]  return true;
@@ -394,14 +394,10 @@ Debug = true
394394
[tester::#EY3] [test-4.lox]  }
395395
[tester::#EY3] [test-4.lox] }
396396
[tester::#EY3] [test-4.lox] 
397-
[tester::#EY3] [test-4.lox] var greaterThanX = makeFilter(54);
398-
[tester::#EY3] [test-4.lox] var greaterThanY = makeFilter(44);
397+
[tester::#EY3] [test-4.lox] var greaterThanX = makeFilter();
399398
[tester::#EY3] [test-4.lox] 
400399
[tester::#EY3] [test-4.lox] print "Numbers >= 54:";
401400
[tester::#EY3] [test-4.lox] applyToNumbers(greaterThanX, 54 + 6);
402-
[tester::#EY3] [test-4.lox] 
403-
[tester::#EY3] [test-4.lox] print "Numbers >= 44:";
404-
[tester::#EY3] [test-4.lox] applyToNumbers(greaterThanY, 44 + 6);
405401
[tester::#EY3] [test-4] $ ./your_program.sh run test.lox
406402
[your_program] Numbers >= 54:
407403
[your_program] 54
@@ -410,14 +406,7 @@ Debug = true
410406
[your_program] 57
411407
[your_program] 58
412408
[your_program] 59
413-
[your_program] Numbers >= 44:
414-
[your_program] 44
415-
[your_program] 45
416-
[your_program] 46
417-
[your_program] 47
418-
[your_program] 48
419-
[your_program] 49
420-
[tester::#EY3] [test-4] ✓ 14 line(s) match on stdout
409+
[tester::#EY3] [test-4] ✓ 7 line(s) match on stdout
421410
[tester::#EY3] [test-4] ✓ Received exit code 0.
422411
[tester::#EY3] Test passed.
423412

test_programs/f6/4.lox

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ expected_error_type: none
44
// This program creates a function that returns
55
// another function
66
// and uses it to filter a list of numbers
7-
fun makeFilter(min) {
7+
fun makeFilter() {
88
fun filter(n) {
9-
if (n < min) {
9+
if (n < <<RANDOM_INTEGER_1>>) {
1010
return false;
1111
}
1212
return true;
@@ -26,11 +26,7 @@ fun applyToNumbers(f, count) {
2626
}
2727
}
2828

29-
var greaterThanX = makeFilter(<<RANDOM_INTEGER_1>>);
30-
var greaterThanY = makeFilter(<<RANDOM_INTEGER_2>>);
29+
var greaterThanX = makeFilter();
3130

3231
print "Numbers >= <<RANDOM_INTEGER_1>>:";
33-
applyToNumbers(greaterThanX, <<RANDOM_INTEGER_1>> + <<RANDOM_DIGIT>>);
34-
35-
print "Numbers >= <<RANDOM_INTEGER_2>>:";
36-
applyToNumbers(greaterThanY, <<RANDOM_INTEGER_2>> + <<RANDOM_DIGIT>>);
32+
applyToNumbers(greaterThanX, <<RANDOM_INTEGER_1>> + <<RANDOM_DIGIT>>);

0 commit comments

Comments
 (0)