public static void ValidateReturnType(Type expectedType, IRacketObject argument) { if (argument is RacketExpression expression && expression.ReturnType != null) { if (!expression.ReturnType.IsAssignableFrom(expectedType) && !expression.ReturnType.IsSubclassOf(expectedType)) { throw new ContractViolationException(expectedType, expression.ReturnType); } }
public override RacketBoolean Evaluate() { IRacketObject obj = arguments[0].Evaluate(); if (obj is RacketBoolean) { return(new RacketBoolean(true)); } return(new RacketBoolean(false)); }
public override RacketBoolean Evaluate() { IRacketObject obj = arguments[0].Evaluate(); if (obj is RacketNumber racketNumber) { return(new RacketBoolean(racketNumber.IsRational)); } return(new RacketBoolean(false)); }