Assignment03: PreprocMultiarg test issue

Moderator: Konzepte der Programmiersprachen

Locke
Neuling
Neuling
Beiträge: 8
Registriert: 26. Mai 2010 16:00
Wohnort: Rodgau

Assignment03: PreprocMultiarg test issue

Beitrag von Locke »

In the Assignment03 for the second Task (PreprocMultiarg) the second test case seems wrong:

Code: Alles auswählen

    // (testname,
    //  expected,
    //  actual),
    
    // first case [...]

    ("preproc app zero arg",
      LApp(LFun('_, 3), LNum(42)), // dummy value 42
      preprocMultiarg(MLApp(MLFun(List(), 3), List()))),
The expected result contains LNum(42) whereas that argument is never passed to preprocMultiarg. I believe the test should look like:

Code: Alles auswählen

preprocMultiarg(MLApp(MLFun(List(), 3), List(42)))),

jkapitzke
Erstie
Erstie
Beiträge: 11
Registriert: 21. Sep 2016 23:54

Re: Assignment03: PreprocMultiarg test issue

Beitrag von jkapitzke »

The test is basically testing a function without arguments. Since with MFLAE we can have multiple or no arguments (empty list) If we transform that to our language where each function must have exactly (!) one argument, we have a problem with the functions that have no arguments.

The tests solve that by introducing arbitrary dummy values and dummy argument names. A dummy argument name is '_ and a dummy value is 42. Since in the body the dummy argument name is never used, the actual value of that dummy does not matter and can be arbitrary.

Example with scala function:

Code: Alles auswählen

val f = () => 3 // function without arguments. 

// We want to transform this function into a function with exactly one argument:
---> 
val f = (x) => 3 // function transformed to contain exactly one argument

// When we apply the function to a value (e.g. 42), the value does not matter
print(f(42)) // returns 3 (value 42 is ignored)
The tests make us choose a very specific dummy value (I think it is 42 for all cases). This should be specified in the requirements or the given tests should be designed in such a way that they allow any dummy value (this would probably make the tests less readable). Again, in theory, you can choose an arbitrary value, but for the tests we probably need to agree upon a certain value.

Jonas

Antworten

Zurück zu „Konzepte der Programmiersprachen“