Skip to content

not:Assigns expectation fails when assignment has same name as method #342

@julian-berbel

Description

@julian-berbel

We have a not assigns expectation in an exercise where the student is expected to return the result of filtering a list. Some of the students however are doing something to the effect of:

module Juegoteca
  ...

  def self.juegos_violentos
    juegos_violentos = juegos.select { ... }
  end
end

The expectation is defined as Expectation "juegos_violentos" "Not:Assigns", however, we've noticed that when the assignment carries the same name as the method that contains it, the expectation does not fail. Changing the assignment to anything else will cause it to work properly.

The following test showcases this behavior:

it "Detects assignment when name is the same as method" $ do
    let notAssigns = Expectation "juegos_violentos" "Not:Assigns"
    let code = Object "Juegoteca" $
                SimpleMethod "juegos_violentos" [] $
                  Assignment "juegos_violentos" (MuNumber 123)

    runAst code [notAssigns] `shouldReturn` (result [failed notAssigns] [])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions