Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Advanced return type (tuple) - how to use? #5531

Closed
DieterPi opened this issue May 12, 2024 · 2 comments
Closed

Advanced return type (tuple) - how to use? #5531

DieterPi opened this issue May 12, 2024 · 2 comments
Assignees

Comments

@DieterPi
Copy link

According to the docs TESTed has support for the immutable sequence tuple. Does this mean I can test if my pupils have a function which properly returns tuples instead of lists?

I've tried (mimicking the full example)

- expression: RGB( (0,128,128) )
  return: "tuple( (255, 127, 127) )"

instead of

- expression: RGB( (0,128,128) )
  return:
  - 255
  - 127
  - 127

since the last example would also approve of a list with the values...

@niknetniko
Copy link
Member

Does this mean I can test if my pupils have a function which properly returns tuples instead of lists?

Yes, this is possible.

I've tried (mimicking the full example)

It seems these docs are slightly out-of-date: they are missing a required YAML tag. My apologies for that.

There are a few equivalent ways of doing this:

- expression: RGB((0, 128, 128))
  return: !expression "(255, 127, 127)"
- expression: RGB((0, 128, 128))
  return: !expression "tuple((255, 127, 127))"
- expression: RGB((0, 128, 128))
  return: !tuple [255, 127, 127]
- expression: RGB((0, 128, 128))
  return: !tuple
    - 255
    - 127
    - 127

You are correct that your last example will accept both list and tuple in Python (and e.g. List and array in Java).

@niknetniko
Copy link
Member

It seems this has been resolved, so I'll close the issue.

(A small tip: consider posting questions like this in our Discussions in the future, this makes it more discoverable for others as well)

@bmesuere bmesuere transferred this issue from dodona-edu/universal-judge May 15, 2024
@dodona-edu dodona-edu locked and limited conversation to collaborators May 15, 2024
@bmesuere bmesuere converted this issue into discussion #5532 May 15, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants