
# create some blocks of code to be analyzed

# =======================================================
# legal code blocks
# =======================================================

code1 = <<-EndCode1
   mid = 3
EndCode1

code2 = <<-EndCode2
   print x
EndCode2

code3 = <<-EndCode3
   print 5
EndCode3

code4 = <<-EndCode4
   print " hello "
EndCode4

code5 = <<-EndCode5
   print " hello there "
EndCode5

code6 = <<-EndCode6
   x = y + 1 + y - 4
EndCode6

code7 = <<-EndCode7
   if ( x == y ) {
      y = 4
   }
EndCode7

code8 = <<-EndCode8
   while ( x == y ) {
      y = 4
   }
EndCode8

code9 = <<-EndCode9
   x = 3
   y = 10 - x
   print z
EndCode9

code10 = <<-EndCode10
print " Welcome! "
mid = 3
x = -4
y = 10
while ( x < y ) {
   if ( x == mid ) {
      print " mid point reached "
   }
   print " x is "
   print x
   x = x + 1
}
EndCode10

# =======================================================
#   buggy code blocks
# =======================================================

error1 = <<-Error1
prnt x
Error1

error2 = <<-Error2
prnt ' hi '
Error2

error3 = <<-Error3
x = 3.5
Error3

error4 = <<-Error4
4 = 3
Error4

error5 = <<-Error5
if x < y {
   y = x
}
Error5

error6 = <<-Error6
while ( x < y )
   y = x
Error6

error7 = <<-Error7
if ( x < y) {
   y = x
}
Error7

error8 = <<-Error8
if ( x < y) {
   y = x
}
Error8

# =======================================================
# Global test arrays
# =======================================================

# store the valid code blocks in one array, the invalid ones in another
ValidTests = [
     [ code1,  "assign an int" ],
     [ code2,  "print a var" ],
     [ code3,  "print an int" ],
     [ code4,  "print a word" ],
     [ code5,  "print two words" ],
     [ code6,  "assign an expression" ],
     [ code7,  "simple if" ],
     [ code8,  "simple while" ],
     [ code9,  "three statements" ],
     [ code10,  "combo all features" ]]

ErrorTests = [
     [ error1,  "bad keyword prnt" ],
     [ error2,  "bad quotes" ],
     [ error3,  "used float not int" ],
     [ error4,  "assign to int" ],
     [ error5,  "condition missing ( )" ],
     [ error6,  "loop missing { }" ],
     [ error7,  "missing space before )" ],
     [ error8,  "no statements" ]]

