chore(curriculum): replace find_case_body helper (#61107)

This commit is contained in:
Dario-DC
2025-06-28 20:41:15 +02:00
committed by GitHub
parent b2ea6bdea3
commit 4865efb3fa
7 changed files with 13 additions and 13 deletions

View File

@@ -38,7 +38,7 @@ You should create a new `case` with the pattern `0`.
You should assign a list containing `'No real roots'` to `result_list` inside the `case` body.
```js
({ test: () => assert(runPython(`_Node(_code).find_function("solver").find_matches()[0].find_match_cases()[0].find_case_body().is_equivalent("result_list = ['No real roots']")`)) })
({ test: () => assert(runPython(`_Node(_code).find_function("solver").find_matches()[0].find_match_cases()[0].find_body().is_equivalent("result_list = ['No real roots']")`)) })
```
# --seed--

View File

@@ -23,7 +23,7 @@ You should not modify your existing `case` block.
({ test: () => runPython(`
case = _Node(_code).find_function("solver").find_matches()[0].find_match_cases()[0]
assert case.find_case_pattern().is_equivalent("0")
assert case.find_case_body().is_equivalent("result_list = ['No real roots']")
assert case.find_body().is_equivalent("result_list = ['No real roots']")
`) })
```
@@ -36,7 +36,7 @@ You should create a new `case` with the pattern `1` after the existing `case` bl
You should assign a list containing `f'x = {results[0]:+}'` to `result_list` inside your new `case` body.
```js
({ test: () => assert(runPython(`_Node(_code).find_function("solver").find_matches()[0].find_match_cases()[1].find_case_body().is_equivalent("result_list = [f'x = {results[0]:+}']")`)) })
({ test: () => assert(runPython(`_Node(_code).find_function("solver").find_matches()[0].find_match_cases()[1].find_body().is_equivalent("result_list = [f'x = {results[0]:+}']")`)) })
```
# --seed--

View File

@@ -23,10 +23,10 @@ You should not modify your existing `case` blocks.
({ test: () => runPython(`
case0 = _Node(_code).find_function("solver").find_matches()[0].find_match_cases()[0]
assert case0.find_case_pattern().is_equivalent("0")
assert case0.find_case_body().is_equivalent("result_list = ['No real roots']")
assert case0.find_body().is_equivalent("result_list = ['No real roots']")
case1 = _Node(_code).find_function("solver").find_matches()[0].find_match_cases()[1]
assert case1.find_case_pattern().is_equivalent("1")
assert case1.find_case_body().is_equivalent("result_list = [f'x = {results[0]:+}']")
assert case1.find_body().is_equivalent("result_list = [f'x = {results[0]:+}']")
`) })
```
@@ -39,7 +39,7 @@ You should create a new `case` with the pattern `2` after the existing `case` bl
You should assign a list containing two strings with the format `x1 = <root1>` and `x2 = <root2>` to `result_list` inside your new `case` body. Display both positive and negative signs for the results.
```js
({ test: () => assert(runPython(`_Node(_code).find_function("solver").find_matches()[0].find_match_cases()[2].find_case_body().is_equivalent("result_list = [f'x1 = {results[0]:+}', f'x2 = {results[1]:+}']")`)) })
({ test: () => assert(runPython(`_Node(_code).find_function("solver").find_matches()[0].find_match_cases()[2].find_body().is_equivalent("result_list = [f'x1 = {results[0]:+}', f'x2 = {results[1]:+}']")`)) })
```
# --seed--

View File

@@ -16,13 +16,13 @@ Within the curly braces of the f-strings contained inside `result_list`, write t
You should modify the string contained in `result_list` in your `case 1` block into `f'x = {results[0]:+.3f}'`.
```js
({ test: () => assert(runPython(`_Node(_code).find_function("solver").find_matches()[0].find_match_cases()[1].find_case_body().is_equivalent("result_list = [f'x = {results[0]:+.3f}']")`)) })
({ test: () => assert(runPython(`_Node(_code).find_function("solver").find_matches()[0].find_match_cases()[1].find_body().is_equivalent("result_list = [f'x = {results[0]:+.3f}']")`)) })
```
You should modify the strings contained in `result_list` in your `case 2` block so that the results are displayed with `3` decimal digits.
```js
({ test: () => assert(runPython(`_Node(_code).find_function("solver").find_matches()[0].find_match_cases()[2].find_case_body().is_equivalent("result_list = [f'x1 = {results[0]:+.3f}', f'x2 = {results[1]:+.3f}']")`)) })
({ test: () => assert(runPython(`_Node(_code).find_function("solver").find_matches()[0].find_match_cases()[2].find_body().is_equivalent("result_list = [f'x1 = {results[0]:+.3f}', f'x2 = {results[1]:+.3f}']")`)) })
```
# --seed--

View File

@@ -38,7 +38,7 @@ You should modify your first `case` to use the pattern `[]`.
You should not modify your first `case` body.
```js
({ test: () => assert(runPython(`_Node(_code).find_function("solver").find_matches()[0].find_match_cases()[0].find_case_body().is_equivalent("result_list = ['No real roots']")`)) })
({ test: () => assert(runPython(`_Node(_code).find_function("solver").find_matches()[0].find_match_cases()[0].find_body().is_equivalent("result_list = ['No real roots']")`)) })
```
You should modify your second `case` to use the pattern `[x]`.
@@ -50,7 +50,7 @@ You should modify your second `case` to use the pattern `[x]`.
You should modify the f-string contained inside `result_list` to use `x` in place of `result[0]`.
```js
({ test: () => assert(runPython(`_Node(_code).find_function("solver").find_matches()[0].find_match_cases()[1].find_case_body().is_equivalent("result_list = [f'x = {x:+.3f}']")`)) })
({ test: () => assert(runPython(`_Node(_code).find_function("solver").find_matches()[0].find_match_cases()[1].find_body().is_equivalent("result_list = [f'x = {x:+.3f}']")`)) })
```
You should modify your third `case` to use a list containing `x1` and `x2` as the pattern.
@@ -62,7 +62,7 @@ You should modify your third `case` to use a list containing `x1` and `x2` as th
You should modify the f-strings contained inside `result_list` to use the bound variables from your pattern.
```js
({ test: () => assert(runPython(`_Node(_code).find_function("solver").find_matches()[0].find_match_cases()[2].find_case_body().is_equivalent("result_list = [f'x1 = {x1:+.3f}', f'x2 = {x2:+.3f}']")`)) })
({ test: () => assert(runPython(`_Node(_code).find_function("solver").find_matches()[0].find_match_cases()[2].find_body().is_equivalent("result_list = [f'x1 = {x1:+.3f}', f'x2 = {x2:+.3f}']")`)) })
```
# --seed--

View File

@@ -30,7 +30,7 @@ You should create a new `case` with the pattern `{'slope': slope, 'intercept': i
You should assign a list containing two f-strings having the form `slope = <slope>` and `y-intercept = <intercept>` to `details_list` inside the `case` body. Remember to format the numerical values to display `3` decimal digits.
```js
({ test: () => assert(runPython(`_Node(_code).find_function("solver").find_matches()[1].find_match_cases()[0].find_case_body().is_equivalent("details_list = [f'slope = {slope:.3f}', f'y-intercept = {intercept:.3f}']")`)) })
({ test: () => assert(runPython(`_Node(_code).find_function("solver").find_matches()[1].find_match_cases()[0].find_body().is_equivalent("details_list = [f'slope = {slope:.3f}', f'y-intercept = {intercept:.3f}']")`)) })
```
# --seed--

View File

@@ -27,7 +27,7 @@ You should not modify your existing `case` block.
({ test: () => runPython(`
case = _Node(_code).find_function("solver").find_matches()[1].find_match_cases()[0]
assert case.find_case_pattern().is_equivalent("{'slope': slope, 'intercept': intercept}")
assert case.find_case_body().is_equivalent("details_list = [f'slope = {slope:.3f}', f'y-intercept = {intercept:.3f}']")
assert case.find_body().is_equivalent("details_list = [f'slope = {slope:.3f}', f'y-intercept = {intercept:.3f}']")
`) })
```