Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more tests to Satellite #2058

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

tamireinhorn
Copy link

As discussed on #3114 on the Python Track, the Sattelite exercise has very few tests, and the trees used in the example don't even seem to follow an understandable logic for comparison, thus making the exercise not as clear to the student. I've thus added a few tests based on the Binary Search Tree exercise.

exercises/satellite/canonical-data.json Outdated Show resolved Hide resolved
exercises/satellite/canonical-data.json Outdated Show resolved Hide resolved
@petertseng
Copy link
Member

I'd like to discuss the value of having the values be strings that happen to contain numbers. Since these are just strings and the contents of them are unimportant, it doesn't seem to matter or be necessary to add tests with such strings.

If these tests catch some class of mistake that students usually make in their implementations, let's hear what those mistakes are and see what to do from there.

If the goal of these tests is just more coverage for different code paths that might arise when constructing the trees, I would suggest it's better to use letters as the other tests do; to introduce numbers when they are not the point of the test would obscure the point of the test and make them harder for students to understand.

We should also think about test ordering. Simpler tests first, I'd think.

@tamireinhorn
Copy link
Author

tamireinhorn commented Jun 15, 2022 via email

tamireinhorn and others added 3 commits June 15, 2022 12:41
Co-authored-by: Peter Tseng <petertseng@users.noreply.github.com>
Fixed wrong answer for complex tree.
@petertseng petertseng dismissed their stale review June 16, 2022 10:09

the new test cases are correct

@petertseng petertseng removed their request for review June 27, 2022 19:49
@jiegillet
Copy link
Contributor

I'm all for having more test cases for this exercise, but I also don't see the point of introducing integers.
If they are meant to be treated as strings, nothing changes other than the possibility of adding "confusing" cases such as "100" being smaller than "2".
If they are meant to be treated as actual integers, this would possibly complicate things for some typed languages that would have to keep the input polymorphic, and that is not the point of the exercise.

Please also mind @petertseng's advice about ordering the exercises in order of difficulty.

Other than that, I'll happily approve.

@tamireinhorn
Copy link
Author

@jiegillet Upon revisiting this, I'm 100% with you. Integers are unnecessary to the exercise, and I think we could just have more varied examples with letters just like the cases we already have, because just 2 exercises is not much.

@glennj
Copy link
Contributor

glennj commented Sep 7, 2022

I think we also need a test where the validations succeed initially, but fail further down the tree:

This input is the existing "Tree with many items" data with the last 2 preorder elements swapped:

      {
        "preorder": ["a", "i", "x", "r", "f"],
        "inorder": ["i", "a", "f", "x", "r"]
      }

At the top level we have this which passes all the assertions

{
  "v": "a",
  "l": build_tree({"preorder": ["i"], "inorder": ["i"]}),
  "r": build_tree({"preorder": ["x", "r", "f"], "inorder": ["f", "x", "r"]})
}

When we get to building the right child, rooted at "x", we have

{
  "v": "x",
  "l": build_tree({"preorder": ["r"], "inorder": ["f"]}),
  "r": build_tree({"preorder": ["f"], "inorder": ["r"]})
}

Those recursive calls should fail the "traversals must have the same elements" assertion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants