Assignment 2

Moderator: Type Systems of Programming Languages

daehn
Erstie
Erstie
Beiträge: 16
Registriert: 5. Okt 2010 13:42

Assignment 2

Beitrag von daehn »

Heyho,

A Question regarding the current Assignment, first Task ("Adding If-Then-Else"):
After Implementing the rules etc. the compilation fails with

Code: Alles auswählen

Status: CompilationFailure
test.scala:9: error: not found: type LStrings
  object lang extends LStrings
                      ^
test.scala:13: error: not found: value Num
    expect (Num(1)) { If(Not(False()), Num(1), Num(2)).normalize }
            ^
I think there might be a mistake in the test source, namely line 8, which should read

Code: Alles auswählen

object lang extends LIf
instead of

Code: Alles auswählen

object lang extends LStrings
Is that correct?

erdweg
Moderator
Moderator
Beiträge: 60
Registriert: 28. Mär 2013 10:08

Re: Assignment 2

Beitrag von erdweg »

correct, thanks for pointing out. I fixed the test template.
Sebastian

GNut
Mausschubser
Mausschubser
Beiträge: 45
Registriert: 7. Okt 2010 19:58

Re: Assignment 2

Beitrag von GNut »

In task 2 (termination proof of boolean expressions)
Can we assume size(e) as already given (as in the lecture)?

erdweg
Moderator
Moderator
Beiträge: 60
Registriert: 28. Mär 2013 10:08

Re: Assignment 2

Beitrag von erdweg »

yes.

daehn
Erstie
Erstie
Beiträge: 16
Registriert: 5. Okt 2010 13:42

Re: Assignment 2

Beitrag von daehn »

Another question regarding the first task:

How to test for not well-behaved programs? In the repository code for L03_Cond we use something like (simplified)

Code: Alles auswählen

import org.scalatest.FunSuite
import lang.L03_Cond._
import test.scala.test.NormalizeTestHelper

class L03_Cond_Test extends FunSuite with NormalizeTestHelper  {
  val language = L03_Cond
  def p = And(Num(1), Num(2))
  stuckTest (p)
}
However

Code: Alles auswählen

import test.scala.test.NormalizeTestHelper
seems to fail in Weblab.

Also what is the difference between

Code: Alles auswählen

import org.scalatest.FunSuite
and

Code: Alles auswählen

import org.scalatest.Suite
(in the test template in weblab).

pSub
Mausschubser
Mausschubser
Beiträge: 61
Registriert: 21. Sep 2009 22:56

Re: Assignment 2

Beitrag von pSub »

daehn hat geschrieben:How to test for not well-behaved programs? In the repository code for L03_Cond we use something like (simplified)
I checked whether the normalization results in the correct stuck term. Something like this should work (replacing everything in <> with scala terms):

Code: Alles auswählen

  def test {
    expect ( <Stuckterm> ) { <TermToNormalize>.normalize }
  }
Zuletzt geändert von pSub am 26. Okt 2013 17:05, insgesamt 1-mal geändert.

GNut
Mausschubser
Mausschubser
Beiträge: 45
Registriert: 7. Okt 2010 19:58

Re: Assignment 2

Beitrag von GNut »

Edit:
Lol to late :D. Did it the same way as described by pSub and it worked fine.
However

Code: Alles auswählen

  import test.scala.test.NormalizeTestHelper
seems to fail in Weblab.
I would guess NormalizeTestHelper is just not available in weblab. Maybe
it could be moved to main.scala.base ?
Also what is the difference between

Code: Alles auswählen

import org.scalatest.FunSuite
and

Code: Alles auswählen

import org.scalatest.Suite
(in the test template in weblab).
FunSuite is an extension of Suite, which offers another(/better?) style of writing tests:
Moreover, test in ScalaTest does not necessarily mean test method. A test can be anything that can be given a name, that starts and either succeeds or fails, and can be ignored. In org.scalatest.FunSuite, for example, tests are represented as function values. This approach might look foreign to JUnit users, but may feel more natural to programmers with a functional programming background. To facilitate this style of writing tests, FunSuite overrides testNames, runTest, and run such that you can define tests as function values.
also it says:
One benefit of FunSuite compared to Suite is you need not name all your tests starting with "test". In addition, you can more easily give long names to your tests, because you need not encode them in camel case.
Found the information here:
http://www.scalatest.org/

With a bunch of documentation for all versions of scalatest =)

Antworten

Zurück zu „Type Systems of Programming Languages“