Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- test("cond test 1"){
- assertResult(NumV(1)){
- interp(desugar(parse("(cond((num< 1 0) 0)(else 1))")))
- }
- }
- test("interp cond test 2 "){
- assertResult(NumV(15)){
- interp(desugar(parse("(cond((num> 5 1) 15)((num< 1 0) 2))")))
- }
- }
- test("interp cond test 3 "){
- assertResult(NumV(100)){
- interp(desugar(parse("(cond((num> 0 1) 15)((num< 1 0) 2)(else 100))")))
- }
- }
- test("interp cond test 4 "){
- assertResult(NumV(2)){
- interp(desugar(parse("(cond((num> 0 1) 15)((num< -5 0) 2)(else 100))")))
- }
- }
- test("condExt") {
- assertResult(CondExt(List((BinOpExt("num>", NumExt(1), NumExt(0)), NumExt(1))))) {
- parse("(cond ((num> 1 0) 1))")
- }
- intercept[InterpException] {
- interp(desugar(parse("(cond ((num< 1 0) 1))")))
- }
- intercept[PException] {
- interp(desugar(parse("(cond ((else 1)))")))
- }
- intercept[PException] {
- interp(desugar(parse("(cond ((num< 0 1) ))")))
- }
- intercept[PException] {
- interp(desugar(parse("(cond (()))")))
- }
- intercept[PException] {
- interp(desugar(parse("(cond ((nil) 1) (else 0))")))
- }
- intercept[PException] {
- interp(desugar(parse("(cond (else 0))")))
- }
- intercept[PException] {
- interp(desugar(parse("(cond ((num< 1 0) 0) (else 1) ((num> 1 0) 2))")))
- }
- intercept[PException] {
- interp(desugar(parse("(cond((5) 0))")))
- }
- intercept[ParseException]{
- interp(desugar(parse("(cond((num< 5 0)))")))
- }
- intercept[ParseException]{
- interp(desugar(parse("(cond((else 1)))")))
- }
- intercept[ParseException]{
- interp(desugar(parse("(cond((else 1)((num< 5 0) 2)))")))
- }
- intercept[PException] {
- interp(desugar(parse("(cond ((num< 1 0) 0) (else omae 1))")))
- }
- }
- test("condExt multiple conditions") {
- assertResult(NumV(0)) {
- interp(desugar(parse("(cond ((num< 0 1) 0))")))
- }
- assertResult(NumV(1)) {
- interp(desugar(parse("(cond ((num> 0 1) 0) ((and true false) 50) ((and true true) 1))")))
- }
- intercept[InterpException] {
- interp(desugar(parse("(cond ((num> 0 1) 0) ((and true false) 50) ((or false false) 1))")))
- }
- }
- test("condEExt") {
- assertResult(CondEExt(List((BinOpExt("num>", NumExt(1), NumExt(0)), NumExt(1))), NumExt(1))) {
- parse("(cond ((num> 1 0) 1) (else 1))")
- }
- assertResult(NumV(1)) {
- interp(desugar(parse("(cond ((num< 1 0) 0) (else 1))")))
- }
- assertResult(NumV(1)) {
- interp(desugar(parse("(cond ((num< 1 0) 0) ((num= 1 0) -1) ((num> 1 2) 2) (else 1))")))
- }
- assertResult(NumV(2)) {
- interp(desugar(parse("(cond ((num< 1 0) 0) ((num= 1 0) -1) ((num> 3 2) 2) (else 1))")))
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement