qc_pyext

QuickCheck and reference testing extension for Python programs

python
quickcheck
testing
property-based testing
moon add CAIMEOX/qc_pyext@0.1.1
Download zip
Author
Version
0.1.1
License
Apache-2.0
Last updated
6 months ago
Downloads
1K
README

#QuickCheck Extension for Python

An extension for MoonBit's QuickCheck library to facilitate reference testing of Python implementations against MoonBit implementations (WIP).

#Idea

Reference Testing: suppose you have a function (in MoonBit) and (in Python) that you want to verify are equivalent on a domain , but currently they have different data representations.

testing overview

Here we define essential componenets for reference testing between MoonBit and Python implementations using QuickCheck.

  • : Embedding from MoonBit data representation to Python data representation (The reverse is not always possible nor easy)
  • : Convert python data into string for comparison
  • : Equivalence relation on strings (in python)

The equivalence of implementation and (denoted as ) on domain can be defined as follows:

#
PyEnumFrom

pub trait PyEnumFrom {
from_py_object(obj :
PyObjectEnum
?) -> Self raise ConvError
}

#
PyObjectInto

pub trait PyObjectInto {
to_py_object(Self) ->
PyObject

}

impl PyObjectInto for Int

#
CallError

pub suberror CallError {
MtdNotFound(String)
UnexpectedReturnType(String)
RuntimeError(
PyRuntimeError
)
}

#
ConvError

pub suberror ConvError {
TypeError(String)
UnexpectedEmpty
}

#
TypedCallable

type TypedCallable[A, R]

#
TypedCallable::new

#
TypedCallable::run

fn[A : PyObjectInto, R : PyEnumFrom] TypedCallable::run(self : TypedCallable[A, R], a : A) -> R raise

#
TypedPyDict

type TypedPyDict[V]

impl Show for TypedPyDict[V]

#
TypedPyDict::new

fn[V : PyObjectInto] TypedPyDict::new(kvs : Array[(String, V)]) -> TypedPyDict[V]

#
TypedPyList

type TypedPyList[T]

#
TypedPyTuple2

type TypedPyTuple2[A, B]

#
TypedPyTuple3

type TypedPyTuple3[A, B, C]

#
invoke_binary

#
py_equal

fn[A : PyObjectInto, B : PyObjectInto] py_equal(sel : A, other : B) -> Bool raise
PyRuntimeError

Checks equality between two Python objects using the __eq__ method of the first object.

#
py_repr

fn[A : PyObjectInto] py_repr(sel : A) -> String raise CallError

#
py_str

fn[A : PyObjectInto] py_str(sel : A) -> String raise CallError

Powered by MoonBit

Site sourceReport issuePackagesBuild queueSkillsStatistics

© 2026 mooncakes.io