216217218219220221222223
"match(y): \n" + " X => 15 \n" + " Y => 23 \n" + " default => 50 \n"; TypedAST ast = getAST(input); evaluateExpecting(ast, 23); }
239240241242243244245246247
" X => 15 \n" + " Y => 23 \n" + " Y => 34 \n" + // Y given twice; error " default => 50 \n"; TypedAST res = getAST(input); typeCheckfailWith(res, ErrorMessage.DUPLICATE_TAG); }
263264265266267268269270271
" X => 15 \n" + " Y => 23 \n" + " Z => 34 \n" + // Z is not declared anywhere; error " default => 50 \n"; TypedAST res = getAST(input); typeCheckfailWith(res, ErrorMessage.UNKNOWN_TAG); }
291292293294295296297298299
" X => 15 \n" + " Y => 23 \n" + " Z => 34 \n" + // Z is declared but not a tagged type; error " default => 50 \n"; TypedAST ast = getAST(input); typeCheckfailWith(ast, ErrorMessage.NOT_TAGGED); }
314315316317318319320321322
"match(x): \n" + " X => 15 \n" + " default => 23 \n" + " Y => 50 \n"; TypedAST res = getAST(input); typeCheckfailWith(res, ErrorMessage.DEFAULT_NOT_LAST); }
338339340341342343344345346
" X => 15 \n" + " default => 23 \n" + " Y => 50 \n" + " default => 23 \n"; TypedAST res = getAST(input); typeCheckfailWith(res, ErrorMessage.MULTIPLE_DEFAULTS); }
369370371372373374375376377
"match(i): \n" + " DynInt => 10 \n" + " DynChar => 15 \n"; // DynByte not specified; error TypedAST res = getAST(input); typeCheckfailWith(res, ErrorMessage.DEFAULT_NOT_PRESENT); }
403404405406407408409410
" DynByte => 20 \n" + " Dyn => 25 \n" + " default => 30 \n"; // default specified with exhaustive search; error TypedAST ast = getAST(input); typeCheckfailWith(ast, ErrorMessage.DEFAULT_PRESENT); }
486487488489490491492493494
" DynChar => 15 \n" + " Dyn => 5 \n" + " default => 20 \n"; TypedAST res = getAST(input); typeCheckfailWith(res, ErrorMessage.DEFAULT_PRESENT); }
513514515516517518519520521522
"match(i): \n" + " DynInt => 10 \n" + " DynChar => 15 \n" + " default => 15 \n"; TypedAST ast = getAST(input); // Should be 15 because D is a subclass of B and will match that evaluateExpecting(ast, 15); }