All Downloads are FREE. Search and download functionalities are using the official Maven repository.

verifiers.Comparable.kt Maven / Gradle / Ivy

There is a newer version: 2024.9.0
Show newest version
@file:Suppress("unused")

package edu.illinois.cs.cs125.questioner.lib.verifiers

import edu.illinois.cs.cs125.jenisol.core.One
import edu.illinois.cs.cs125.jenisol.core.TestResult
import edu.illinois.cs.cs125.jenisol.core.TestResult.Differs

fun  verify(results: TestResult>) {
    val solutionThrew = results.solution.threw
    val submissionThrew = results.submission.threw
    if (solutionThrew != null) {
        if (submissionThrew == null) {
            results.differs.add(Differs.THREW)
        } else if (solutionThrew is AssertionError) {
            if (!(submissionThrew is AssertionError
                        || submissionThrew is ClassCastException
                        || submissionThrew is NullPointerException)
            ) {
                results.differs.add(Differs.THREW)
            }
        } else if (solutionThrew.javaClass != submissionThrew.javaClass) {
            results.differs.add(Differs.THREW)
        }
        return
    }
    if (submissionThrew != null) {
        results.differs.add(Differs.THREW)
        return
    }
    val solutionReturn = results.solution.returned!!
    val submissionReturn = results.submission.returned!!
    if (solutionReturn > 0) {
        if (submissionReturn <= 0) {
            results.differs.add(Differs.RETURN)
            results.message = "Submission did not return a positive value"
        }
    } else if (solutionReturn < 0) {
        if (submissionReturn >= 0) {
            results.differs.add(Differs.RETURN)
            results.message = "Submission did not return a negative value"
        }
    } else if (submissionReturn != 0) {
        results.differs.add(Differs.RETURN)
        results.message = "Submission did not return zero"
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy