# HG changeset patch # User Christian Urban # Date 1572515373 0 # Node ID 3f34da7a3094d0098461c21cab98d9edf43019ca # Parent 7a945c3b86c72e99219c455583dd807890778b48 updated diff -r 7a945c3b86c7 -r 3f34da7a3094 templates3/bf.scala --- a/templates3/bf.scala Thu Oct 31 09:20:43 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,151 +0,0 @@ -// Part 2 about an Interpreter for the Brainf*** language -//======================================================== - -object CW8b { - -type Mem = Map[Int, Int] - -// (2a) Complete the functions for safely reading -// and writing brainf*** memory. Safely read should -// Return the value stored in the Map for a given memory -// pointer, if it exists; otherwise it Returns 0. The -// writing function generates a new Map with the -// same data, except at the given memory pointer the -// value v is stored. - - -//def sread(mem: Mem, mp: Int) : Int = ... - -//def write(mem: Mem, mp: Int, v: Int) : Mem = ... - - -// (2b) Implement the two jumping instructions in the -// brainf*** language. In jumpRight, given a program and -// a program counter move the counter to the right -// until the command after the *matching* ]-command. Similarly, -// jumpLeft implements the move to the left to just after -// the *matching* [-command. The levels are used to find the -// *matching* bracket. - -//def jumpRight(prog: String, pc: Int, level: Int) : Int = ... - -//def jumpLeft(prog: String, pc: Int, level: Int) : Int = ... - - - -// (2c) Complete the run function that interprets (runs) a brainf*** -// program: the arguments are a program, a program counter, -// a memory counter and a brainf*** memory. It Returns the -// memory at the stage when the execution of the brainf*** program -// finishes. The interpretation finishes once the program counter -// pc is pointing to something outside the program string. -// If the pc points to a character inside the program, the pc, -// memory pointer and memory need to be updated according to -// rules of the brainf*** language. Then, recursively, the run -// function continues with the command at the new program -// counter. -// -// Implement the start function that calls run with the program -// counter and memory counter set to 0. - -//def run(prog: String, pc: Int, mp: Int, mem: Mem) : Mem = ... - -//def start(prog: String, mem: Mem) = ... - - - - - - -// some sample bf programs collected from the Internet -//================================================== - - -/* -// first some contrived (small) programs - -// clears the 0-cell -start("[-]", Map(0 -> 100)) - -// copies content of the 0-cell to 1-cell -start("[->+<]", Map(0 -> 10)) - -// copies content of the 0-cell to 2-cell and 4-cell -start("[>>+>>+<<<<-]", Map(0 -> 42)) - -start("+++[>+++++<-]", Map(0 -> 10)) - - -// prints out numbers 0 to 9 -start("""+++++[->++++++++++<]>--<+++[->>++++++++++<<]>>++<<----------[+>.>.<+<]""", Map()) - - -// some more "useful" programs - -// hello world program 1 -start("""++++++++[>++++[>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]>>.>---.+++++++ - ..+++.>>.<-.<.+++.------.--------.>>+.>++.""", Map()) - -// hello world program 2 -start("""++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>+ - +.<<+++++++++++++++.>.+++.------.--------.>+.>.""", Map()) - - -// draws the Sierpinski triangle -start("""++++++++[>+>++++<<-]>++>>+<[-[>>+<<-]+>>]>+[-<<<[ - ->[+[-]+>++>>>-<<]<[<]>>++++++[<<+++++>>-]+<<++.[-]<< - ]>.>+[>>]>+]""", Map()) - -//Fibonacci numbers below 100 -start("""+++++++++++ - >+>>>>++++++++++++++++++++++++++++++++++++++++++++ - >++++++++++++++++++++++++++++++++<<<<<<[>[>>>>>>+> - +<<<<<<<-]>>>>>>>[<<<<<<<+>>>>>>>-]<[>++++++++++[- - <-[>>+>+<<<-]>>>[<<<+>>>-]+<[>[-]<[-]]>[<<[>>>+<<< - -]>>[-]]<<]>>>[>>+>+<<<-]>>>[<<<+>>>-]+<[>[-]<[-]] - >[<<+>>[-]]<<<<<<<]>>>>>[+++++++++++++++++++++++++ - +++++++++++++++++++++++.[-]]++++++++++<[->-<]>++++ - ++++++++++++++++++++++++++++++++++++++++++++.[-]<< - <<<<<<<<<<[>>>+>+<<<<-]>>>>[<<<<+>>>>-]<-[>>.>.<<< - [-]]<<[>>+>+<<<-]>>>[<<<+>>>-]<<[<+>-]>[<+>-]<<<-]""", Map()) - - -//outputs the square numbers up to 10000 -start("""++++[>+++++<-]>[<+++++>-]+<+[ - >[>+>+<<-]++>>[<<+>>-]>>>[-]++>[-]+ - >>>+[[-]++++++>>>]<<<[[<++++++++<++>>-]+<.<[>----<-]<] - <<[>>>>>[>>>[-]+++++++++<[>-<-]+++++++++>[-[<->-]+[<<<]]<[>+<-]>]<<-]<<-]""", Map()) - - -//Collatz numbers (need to be typed in) -start(""">,[[----------[ - >>>[>>>>]+[[-]+<[->>>>++>>>>+[>>>>]++[->+<<<<<]]<<<] - ++++++[>------<-]>--[>>[->>>>]+>+[<<<<]>-],<]>]>>>++>+>>[ - <<[>>>>[-]+++++++++<[>-<-]+++++++++>[-[<->-]+[<<<<]]<[>+<-]>] - >[>[>>>>]+[[-]<[+[->>>>]>+<]>[<+>[<<<<]]+<<<<]>>>[->>>>]+>+[<<<<]] - >[[>+>>[<<<<+>>>>-]>]<<<<[-]>[-<<<<]]>>>>>>> - ]>>+[[-]++++++>>>>]<<<<[[<++++++++>-]<.[-]<[-]<[-]<]<,]""", Map()) - - -// infinite Collatz (never stops) -start(""">>+>+<[[->>[>>]>>>[>>]+[<<]<<<[<<]>[>[>>]>>+>[>>]<+<[<<]<<<[< - <]>-]>[>>]>>[<<<<[<<]>+>[>>]>>-]<<<<[<<]+>>]<<[+++++[>+++++++ - +<-]>.<++++++[>--------<-]+<<]>>[>>]+[>>>>[<<+>+>-]<-[>+<-]+< - [<<->>-[<<+>>[-]]]>>>[<<<+<<+>>>>>-]<<<[>>>+<<<-]<<[[-]>+>>-> - [<+<[<<+>>-]<[>+<-]<[>+<-]>>>>-]<[>+<-]+<[->[>>]<<[->[<+++>-[ - <+++>-[<+++>-[<[-]++>>[-]+>+<<-[<+++>-[<+++>-[<[-]+>>>+<<-[<+ - ++>-[<+++>-]]]]]]]]]<[>+<-]+<<]>>>+<[->[<+>-[<+>-[<+>-[<+>-[< - +>-[<+>-[<+>-[<+>-[<+>-[<[-]>>[-]+>+<<-[<+>-]]]]]]]]]]]<[>+<- - ]+>>]<<[<<]>]<[->>[->+>]<[-[<+>-[<->>+<-[<+>-[<->>+<-[<+>-[<- - >>+<-[<+>-[<->>+<-[<+>-[<->>+<-[<+>-[<->>+<-[<+>-[<->>+<-[<+> - -[<->>+<-[<+>-[<->>+<-[<+>-]]]]]]]]]]]]]]]]]]]>[<+>-]<+<[<+++ - +++++++>-]<]>>[<+>->>]<<[>+>+<<-]>[<+>-]+>[<->[-]]<[-<<-]<<[< - <]]++++++[>+++++++<-]>++.------------.[-]>[>>]<<[+++++[>+++++ - +++<-]>.<++++++[>--------<-]+<<]+<]>[<+>-]<]>>>[>>]<<[>[-]<-< - <]++++++++++.[-]<<<[<<]>>>+<[->[<+>-[<+>-[<+>-[<+>-[<+>-[<+>- - [<+>-[<+>-[<+>-[<[-]>>[-]+>+<<-]]]]]]]]]]<[>+<-]+>>]<<[<<]>>]""", Map()) - - -*/ - -} diff -r 7a945c3b86c7 -r 3f34da7a3094 templates3/re.scala --- a/templates3/re.scala Thu Oct 31 09:20:43 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,127 +0,0 @@ -// Part 1 about Regular Expression Matching -//========================================== - - -object CW8a { - -abstract class Rexp -case object ZERO extends Rexp -case object ONE extends Rexp -case class CHAR(c: Char) extends Rexp -case class ALT(r1: Rexp, r2: Rexp) extends Rexp // alternative -case class SEQ(r1: Rexp, r2: Rexp) extends Rexp // sequence -case class STAR(r: Rexp) extends Rexp // star - - -// some convenience for typing in regular expressions - -import scala.language.implicitConversions -import scala.language.reflectiveCalls - -def charlist2rexp(s: List[Char]): Rexp = s match { - case Nil => ONE - case c::Nil => CHAR(c) - case c::s => SEQ(CHAR(c), charlist2rexp(s)) -} -implicit def string2rexp(s: String): Rexp = charlist2rexp(s.toList) - -implicit def RexpOps (r: Rexp) = new { - def | (s: Rexp) = ALT(r, s) - def % = STAR(r) - def ~ (s: Rexp) = SEQ(r, s) -} - -implicit def stringOps (s: String) = new { - def | (r: Rexp) = ALT(s, r) - def | (r: String) = ALT(s, r) - def % = STAR(s) - def ~ (r: Rexp) = SEQ(s, r) - def ~ (r: String) = SEQ(s, r) -} - -// (1a) Complete the function nullable according to -// the definition given in the coursework; this -// function checks whether a regular expression -// can match the empty string and Returns a boolean -// accordingly. - -//def nullable (r: Rexp) : Boolean = ... - - -// (1b) Complete the function der according to -// the definition given in the coursework; this -// function calculates the derivative of a -// regular expression w.r.t. a character. - -//def der (c: Char, r: Rexp) : Rexp = ... - - -// (1c) Complete the simp function according to -// the specification given in the coursework; this -// function simplifies a regular expression from -// the inside out, like you would simplify arithmetic -// expressions; however it does not simplify inside -// STAR-regular expressions. - -//def simp(r: Rexp) : Rexp = ... - - -// (1d) Complete the two functions below; the first -// calculates the derivative w.r.t. a string; the second -// is the regular expression matcher taking a regular -// expression and a string and checks whether the -// string matches the regular expression - -//def ders (s: List[Char], r: Rexp) : Rexp = ... - -//def matcher(r: Rexp, s: String): Boolean = ... - - -// (1e) Complete the size function for regular -// expressions according to the specification -// given in the coursework. - -//def size(r: Rexp): Int = ... - - -// some testing data - -/* -matcher(("a" ~ "b") ~ "c", "abc") // => true -matcher(("a" ~ "b") ~ "c", "ab") // => false - -// the supposedly 'evil' regular expression (a*)* b -val EVIL = SEQ(STAR(STAR(CHAR('a'))), CHAR('b')) - -matcher(EVIL, "a" * 1000 ++ "b") // => true -matcher(EVIL, "a" * 1000) // => false - -// size without simplifications -size(der('a', der('a', EVIL))) // => 28 -size(der('a', der('a', der('a', EVIL)))) // => 58 - -// size with simplification -size(simp(der('a', der('a', EVIL)))) // => 8 -size(simp(der('a', der('a', der('a', EVIL))))) // => 8 - -// Java needs around 30 seconds for matching 28 a's with EVIL. -// -// Lets see how long it takes to match strings with -// 0.5 Million a's...it should be in the range of some -// seconds. - -def time_needed[T](i: Int, code: => T) = { - val start = System.nanoTime() - for (j <- 1 to i) code - val end = System.nanoTime() - (end - start)/(i * 1.0e9) -} - -for (i <- 0 to 5000000 by 500000) { - println(i + " " + "%.5f".format(time_needed(2, matcher(EVIL, "a" * i)))) -} - -*/ - - -} diff -r 7a945c3b86c7 -r 3f34da7a3094 testing3/knight1_test.sh --- a/testing3/knight1_test.sh Thu Oct 31 09:20:43 2019 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,166 +0,0 @@ -#!/bin/bash -set -euo pipefail - -out=${1:-output} - -echo -e "" > $out - -echo -e "Below is the feedback for your submission of CW 8, Preliminary Part" >> $out -echo -e "" >> $out - - -# compilation tests - -function scala_compile { - (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala "$1" 2>> $out 1>> $out) -} - -# functional tests - -function scala_assert_slow { - (ulimit -t 120; JAVA_OPTS="-Xmx1g" scala -i "$1" "-- $2" 2> /dev/null 1> /dev/null) -} - -function scala_assert_thirty { - (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" 2> /dev/null 1> /dev/null) -} - -function scala_assert_quick { - (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" 2> /dev/null 1> /dev/null) -} - -# purity test - -function scala_vars { - (egrep '\bvar\b|\breturn\b|\.par|ListBuffer|mutable|new Array' "$1" 2> /dev/null 1> /dev/null) -} - - -# knights1: purity test - -echo -e "knight1.scala does not contain vars, returns etc?" >> $out - -if (scala_vars knight1.scala) -then - echo -e " --> FAIL (make triple-sure your program conforms to the required format)" >> $out - tsts0=$(( 0 )) -else - echo -e " --> success" >> $out - tsts0=$(( 0 )) -fi - - -# compilation test - -if [ $tsts0 -eq 0 ] -then - echo -e "knight1.scala runs?" >> $out - - if (scala_compile knight1.scala) - then - echo -e " --> success " >> $out - tsts1=$(( 0 )) - else - echo -e " --> SCALA DID NOT RUN KNIGHT1.SCALA\n" >> $out - tsts1=$(( 1 )) - fi -else - tsts1=$(( 1 )) -fi - -### knight1 test - -if [ $tsts1 -eq 0 ] -then - echo -e "Takes 10 seconds or less to execute: " >> $out - echo -e " is_legal(8, Nil, (3, 4)) == true " >> $out - echo -e " is_legal(8, List((4, 1), (1, 0)), (4, 1)) == false " >> $out - echo -e " is_legal(2, Nil, (0, 0)) == true" >> $out - - if (scala_assert_quick "knight1.scala" "knight_test1.scala") - then - echo -e " --> success" >> $out - else - echo -e " --> \n ONE TEST FAILED\n" >> $out - fi -fi - -### knight2 test - -if [ $tsts1 -eq 0 ] -then - echo -e "Takes 10 seconds or less to execute: " >> $out - echo -e " legal_moves(8, Nil, (2,2)) == List((3,4), (4,3), (4,1), (3,0), (1,0), (0,1), (0,3), (1,4))" >> $out - echo -e " legal_moves(8, Nil, (7,7)) == List((6,5), (5,6))" >> $out - echo -e " legal_moves(8, List((4,1), (1,0)), (2,2)) == List((3,4), (4,3), (3,0), (0,1), (0,3), (1,4))" >> $out - echo -e " legal_moves(8, List((6,6)), (7,7)) == List((6,5), (5,6))" >> $out - echo -e " legal_moves(1, Nil, (0,0)) == Nil" >> $out - echo -e " legal_moves(2, Nil, (0,0)) == Nil" >> $out - echo -e " legal_moves(3, Nil, (0,0)) == List((1,2), (2,1))" >> $out - - if (scala_assert_quick "knight1.scala" "knight_test2.scala") - then - echo -e " --> success" >> $out - else - echo -e " --> \n ONE TEST FAILED\n" >> $out - fi -fi - - -### knight3 test - -if [ $tsts1 -eq 0 ] -then - echo -e "Takes 10 seconds or less to execute: " >> $out - echo -e " count_tours from every position on the board" >> $out - echo -e " dim = 1: 1" >> $out - echo -e " 2: 0,0,0,0" >> $out - echo -e " 3: 0,0,0,0,0,0,0,0,0" >> $out - echo -e " 4: 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" >> $out - #echo -e " 5: 304,0,56,0,304,0,56,0,56,0,56,0,64,0,56,0,56,0,56,0,304,0,56,0,304" >> $out - echo -e " enum_tours(5, List((0,0)) ) == 304 and all correct?" >> $out - echo -e " enum_tours(5, List((0,1)) ) == 0" >> $out - echo -e " enum_tours(5, List((0,2)) ) == 56 and all correct?" >> $out - - if (scala_assert_quick "knight1.scala" "knight_test3.scala") - then - echo -e " --> success" >> $out - else - echo -e " --> \n ONE TEST FAILED\n" >> $out - fi -fi - -### knight4 test - -if [ $tsts1 -eq 0 ] -then - echo -e "Takes 10 seconds or less to execute: " >> $out - echo -e " Let f = (x:(Int, Int)) => if (x._1 > 3) Some(List(x)) else None " >> $out - echo -e " first(List((1,0),(2,0),(3,0),(4,0)), f) == Some(List((4,0)))" >> $out - echo -e " first(List((1,0),(2,0),(3,0)), f) == None" >> $out - - if (scala_assert_quick "knight1.scala" "knight_test4.scala") - then - echo -e " --> success" >> $out - else - echo -e " --> \n ONE TEST FAILED\n" >> $out - fi -fi - - -### knight5 test - -if [ $tsts1 -eq 0 ] -then - echo -e "Takes 10 seconds or less to execute: " >> $out - echo -e " is first_tour(6, List((0, 0))) ok? " >> $out - echo -e " is first_tour(4, List((0, 0))) == None " >> $out - - if (scala_assert_quick "knight1.scala" "knight_test5.scala") - then - echo -e " --> success" >> $out - else - echo -e " --> \n ONE TEST FAILED\n" >> $out - fi -fi - diff -r 7a945c3b86c7 -r 3f34da7a3094 testing3/knight2_test.sh --- a/testing3/knight2_test.sh Thu Oct 31 09:20:43 2019 +0000 +++ b/testing3/knight2_test.sh Thu Oct 31 09:49:33 2019 +0000 @@ -8,7 +8,7 @@ echo "" > $out -echo -e "Below is the feedback for your submission of CW 8, Advanced Part 2." >> $out +echo -e "Below is the feedback for your submission of CW 8, Core Part." >> $out echo -e "" >> $out @@ -21,11 +21,17 @@ # functional tests - -function scala_assert { - (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" "$2" -e "" 2> /dev/null 1> /dev/null) +function scala_assert_slow { + (ulimit -t 120; JAVA_OPTS="-Xmx1g" scala -i "$1" "-- $2" 2> /dev/null 1> /dev/null) } +function scala_assert_thirty { + (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" 2> /dev/null 1> /dev/null) +} + +function scala_assert_quick { + (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" 2> /dev/null 1> /dev/null) +} # purity test @@ -35,6 +41,12 @@ } + + + + + + # knights2: purity test # echo -e "knight2.scala does not contain vars, returns, Arrays, ListBuffers etc?" >> $out diff -r 7a945c3b86c7 -r 3f34da7a3094 testing3/knight_test.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/testing3/knight_test.sh Thu Oct 31 09:49:33 2019 +0000 @@ -0,0 +1,166 @@ +#!/bin/bash +set -euo pipefail + +out=${1:-output} + +echo -e "" > $out + +echo -e "Below is the feedback for your submission of CW 8" >> $out +echo -e "" >> $out + + +# compilation tests + +function scala_compile { + (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala "$1" 2>> $out 1>> $out) +} + +# functional tests + +function scala_assert_slow { + (ulimit -t 120; JAVA_OPTS="-Xmx1g" scala -i "$1" "-- $2" 2> /dev/null 1> /dev/null) +} + +function scala_assert_thirty { + (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" 2> /dev/null 1> /dev/null) +} + +function scala_assert_quick { + (ulimit -t 30; JAVA_OPTS="-Xmx1g" scala -i "$1" -- "$2" 2> /dev/null 1> /dev/null) +} + +# purity test + +function scala_vars { + (egrep '\bvar\b|\breturn\b|\.par|ListBuffer|mutable|new Array' "$1" 2> /dev/null 1> /dev/null) +} + + +# knights1: purity test + +echo -e "knight1.scala does not contain vars, returns etc?" >> $out + +if (scala_vars knight1.scala) +then + echo -e " --> FAIL (make triple-sure your program conforms to the required format)" >> $out + tsts0=$(( 0 )) +else + echo -e " --> success" >> $out + tsts0=$(( 0 )) +fi + + +# compilation test + +if [ $tsts0 -eq 0 ] +then + echo -e "knight1.scala runs?" >> $out + + if (scala_compile knight1.scala) + then + echo -e " --> success " >> $out + tsts1=$(( 0 )) + else + echo -e " --> SCALA DID NOT RUN KNIGHT1.SCALA\n" >> $out + tsts1=$(( 1 )) + fi +else + tsts1=$(( 1 )) +fi + +### knight1 test + +if [ $tsts1 -eq 0 ] +then + echo -e "For testing needs to take 10 seconds or less to execute: " >> $out + echo -e " is_legal(8, Nil, (3, 4)) == true " >> $out + echo -e " is_legal(8, List((4, 1), (1, 0)), (4, 1)) == false " >> $out + echo -e " is_legal(2, Nil, (0, 0)) == true" >> $out + + if (scala_assert_quick "knight1.scala" "knight_test1.scala") + then + echo -e " --> success" >> $out + else + echo -e " --> \n ONE TEST FAILED\n" >> $out + fi +fi + +### knight2 test + +if [ $tsts1 -eq 0 ] +then + echo -e "For testing needs to take 10 seconds or less to execute: " >> $out + echo -e " legal_moves(8, Nil, (2,2)) == List((3,4), (4,3), (4,1), (3,0), (1,0), (0,1), (0,3), (1,4))" >> $out + echo -e " legal_moves(8, Nil, (7,7)) == List((6,5), (5,6))" >> $out + echo -e " legal_moves(8, List((4,1), (1,0)), (2,2)) == List((3,4), (4,3), (3,0), (0,1), (0,3), (1,4))" >> $out + echo -e " legal_moves(8, List((6,6)), (7,7)) == List((6,5), (5,6))" >> $out + echo -e " legal_moves(1, Nil, (0,0)) == Nil" >> $out + echo -e " legal_moves(2, Nil, (0,0)) == Nil" >> $out + echo -e " legal_moves(3, Nil, (0,0)) == List((1,2), (2,1))" >> $out + + if (scala_assert_quick "knight1.scala" "knight_test2.scala") + then + echo -e " --> success" >> $out + else + echo -e " --> \n ONE TEST FAILED\n" >> $out + fi +fi + + +### knight3 test + +if [ $tsts1 -eq 0 ] +then + echo -e "For testing needs to take 10 seconds or less to execute: " >> $out + echo -e " count_tours from every position on the board" >> $out + echo -e " dim = 1: 1" >> $out + echo -e " 2: 0,0,0,0" >> $out + echo -e " 3: 0,0,0,0,0,0,0,0,0" >> $out + echo -e " 4: 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0" >> $out + #echo -e " 5: 304,0,56,0,304,0,56,0,56,0,56,0,64,0,56,0,56,0,56,0,304,0,56,0,304" >> $out + echo -e " enum_tours(5, List((0,0)) ) == 304 and all correct?" >> $out + echo -e " enum_tours(5, List((0,1)) ) == 0" >> $out + echo -e " enum_tours(5, List((0,2)) ) == 56 and all correct?" >> $out + + if (scala_assert_quick "knight1.scala" "knight_test3.scala") + then + echo -e " --> success" >> $out + else + echo -e " --> \n ONE TEST FAILED\n" >> $out + fi +fi + +### knight4 test + +if [ $tsts1 -eq 0 ] +then + echo -e "Takes 10 seconds or less to execute: " >> $out + echo -e " Let f = (x:(Int, Int)) => if (x._1 > 3) Some(List(x)) else None " >> $out + echo -e " first(List((1,0),(2,0),(3,0),(4,0)), f) == Some(List((4,0)))" >> $out + echo -e " first(List((1,0),(2,0),(3,0)), f) == None" >> $out + + if (scala_assert_quick "knight1.scala" "knight_test4.scala") + then + echo -e " --> success" >> $out + else + echo -e " --> \n ONE TEST FAILED\n" >> $out + fi +fi + + +### knight5 test + +if [ $tsts1 -eq 0 ] +then + echo -e "Takes 10 seconds or less to execute: " >> $out + echo -e " is first_tour(6, List((0, 0))) ok? " >> $out + echo -e " is first_tour(4, List((0, 0))) == None " >> $out + + if (scala_assert_quick "knight1.scala" "knight_test5.scala") + then + echo -e " --> success" >> $out + else + echo -e " --> \n ONE TEST FAILED\n" >> $out + fi +fi +