# test the main variants of contract layout - these should be all OK class ContractParsing # this was the failure case def dedentError(x as int) as char require x < 3 test assert true body return c'z' # to here # contract and test clauses def dedent1(x as int) as char require x < 3 test assert true body return c'z' # 1 stmt contract and unindented body only def dedent2(x as int) as char require x < 3 #test # assert true return c'z' #should we allow this even though body not necessary? def dedent2a(x as int) as char require x < 3 body return c'z' # no test clause def dedent3(x as int) as char require x < 3 #test # assert true # indented contract clause must also have keyword and indented body body return c'z' def dedent3a(x as int) as char require x < 3 body return c'z' # no contract def dedent4(x as int) as char #require x < 3 test assert true body return c'z' def dedent4a(x as int) as char test assert true body return c'z' # stmt(s) only - none of contract/test or body def noDedent(x as int) as char return c'z' def main is shared c = ContractParsing() assert c.dedentError(1) == c'z' assert c.dedent1(1) == c'z' assert c.dedent2(1) == c'z' assert c.dedent2a(1) == c'z' assert c.dedent3(2) == c'z' assert c.dedent3a(2) == c'z' assert c.dedent4(1) == c'z' assert c.dedent4a(1) == c'z' assert c.noDedent(1) == c'z'