Compare commits
11 Commits
acbc62a170
...
handwritte
| Author | SHA1 | Date | |
|---|---|---|---|
| c66d860542 | |||
| cfeffb7f24 | |||
| 01d8ff3123 | |||
| 3b24fd1d05 | |||
| dd402d13c7 | |||
| 0ea2fa03f5 | |||
| 3fd0ef52b9 | |||
| d597cacb2d | |||
| dfb88f0dd7 | |||
| e6422d22e0 | |||
| 60c0dcf35f |
62
.github/workflows/builder.yml
vendored
62
.github/workflows/builder.yml
vendored
@@ -1,26 +1,64 @@
|
|||||||
name: Matrix
|
name: Matrix
|
||||||
on:
|
on:
|
||||||
- pull_request
|
push:
|
||||||
- push
|
branches:
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
main:
|
format:
|
||||||
|
name: Format
|
||||||
|
runs-on: native
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: dtolnay/rust-toolchain@stable
|
||||||
|
with:
|
||||||
|
components: rustfmt, clippy
|
||||||
|
- run: cargo fmt --all -- --check
|
||||||
|
|
||||||
|
clippy:
|
||||||
|
name: Clippy check
|
||||||
|
runs-on: native
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: dtolnay/rust-toolchain@stable
|
||||||
|
with:
|
||||||
|
components: rustfmt, clippy
|
||||||
|
- run: cargo clippy --all-targets -- -D warnings
|
||||||
|
|
||||||
|
build:
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
rust:
|
rust:
|
||||||
- stable
|
- stable
|
||||||
- beta
|
- beta
|
||||||
- nightly
|
- nightly
|
||||||
name: ${{matrix.rust}}
|
|
||||||
runs-on: x86_64-linux
|
name: Build - ${{matrix.rust}}
|
||||||
|
runs-on: native
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
- uses: dtolnay/rust-toolchain@v1
|
- uses: dtolnay/rust-toolchain@master
|
||||||
with:
|
with:
|
||||||
toolchain: ${{matrix.rust}}
|
toolchain: ${{matrix.rust}}
|
||||||
components: rustfmt, clippy
|
components: rustfmt, clippy
|
||||||
- run: rustup --version
|
- run: cargo build
|
||||||
- run: rustc -vV
|
|
||||||
|
test:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
rust:
|
||||||
|
- stable
|
||||||
|
- beta
|
||||||
|
- nightly
|
||||||
|
|
||||||
|
name: Test - ${{matrix.rust}}
|
||||||
|
runs-on: native
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v6
|
||||||
|
- uses: dtolnay/rust-toolchain@master
|
||||||
|
with:
|
||||||
|
toolchain: ${{matrix.rust}}
|
||||||
|
components: rustfmt, clippy
|
||||||
|
- run: cargo build
|
||||||
|
|
||||||
- run: cargo clippy -- --deny clippy::pedantic
|
|
||||||
- run: cargo fmt --all -- --check
|
|
||||||
- run: cargo test
|
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
use std::fmt::Arguments;
|
|
||||||
|
|
||||||
use crate::syntax::ast::{ConstantValue, IntegerWithBase, Type};
|
use crate::syntax::ast::{ConstantValue, IntegerWithBase, Type};
|
||||||
use crate::syntax::location::Location;
|
use crate::syntax::location::Location;
|
||||||
use crate::syntax::name::Name;
|
use crate::syntax::name::Name;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use proptest::arbitrary::Arbitrary;
|
use proptest::arbitrary::Arbitrary;
|
||||||
use proptest::prelude::{BoxedStrategy, Rng};
|
use proptest::prelude::{BoxedStrategy, Rng};
|
||||||
use proptest::prop_oneof;
|
|
||||||
use proptest::strategy::{NewTree, Strategy, ValueTree};
|
use proptest::strategy::{NewTree, Strategy, ValueTree};
|
||||||
use proptest::test_runner::TestRunner;
|
use proptest::test_runner::TestRunner;
|
||||||
|
|
||||||
@@ -24,39 +21,53 @@ pub struct TypeGenerationContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl TypeGenerationContext {
|
impl TypeGenerationContext {
|
||||||
fn generate_type(&mut self, runner: &mut TestRunner, depth: usize) -> Type {
|
fn generate_type(&self, runner: &mut TestRunner, depth: usize) -> Type {
|
||||||
let mut leaf_options = vec![];
|
let mut leaf_options = vec![];
|
||||||
|
|
||||||
if !self.available_constructors.is_empty() {
|
if !self.available_constructors.is_empty() {
|
||||||
for name in self.available_constructors.iter() {
|
for name in self.available_constructors.iter() {
|
||||||
leaf_options.push(Type::Constructor(
|
leaf_options.push(Type::Constructor(Location::manufactured(), name.clone()));
|
||||||
Location::manufactured(),
|
|
||||||
name.clone(),
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !self.available_variables.is_empty() {
|
if !self.available_variables.is_empty() {
|
||||||
for name in self.available_variables.iter() {
|
for name in self.available_variables.iter() {
|
||||||
leaf_options.push(Type::Variable(
|
leaf_options.push(Type::Variable(Location::manufactured(), name.clone()));
|
||||||
Location::manufactured(),
|
|
||||||
name.clone(),
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for prim in PRIMITIVE_TYPES.iter() {
|
for prim in PRIMITIVE_TYPES.iter() {
|
||||||
leaf_options.push(Type::Primitive(
|
leaf_options.push(Type::Primitive(
|
||||||
Location::manufactured(),
|
Location::manufactured(),
|
||||||
Name::new(Location::manufactured(), prim.to_string()),
|
Name::new(Location::manufactured(), prim.to_string()),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut possibilities = leaf_options.len();
|
||||||
|
|
||||||
if depth < MAXIMUM_TYPE_DEPTH && runner.rng().random_bool(0.5) {
|
if depth < MAXIMUM_TYPE_DEPTH && runner.rng().random_bool(0.5) {
|
||||||
|
possibilities += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
let index = runner.rng().random_range(0..leaf_options.len());
|
let index = runner.rng().random_range(0..possibilities);
|
||||||
leaf_options.remove(index)
|
|
||||||
|
if index >= leaf_options.len() {
|
||||||
|
let argument_count = runner.rng().random_range(0..MAXIMUM_TYPE_WIDTH);
|
||||||
|
let final_type = self.generate_type(runner, depth + 1);
|
||||||
|
let mut args = vec![];
|
||||||
|
|
||||||
|
for _ in 0..argument_count {
|
||||||
|
args.push(self.generate_type(runner, depth + 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
if index - leaf_options.len() == 0 {
|
||||||
|
Type::Function(args, Box::new(final_type))
|
||||||
|
} else {
|
||||||
|
Type::Application(Box::new(final_type), args)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
leaf_options.remove(index)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,10 +90,6 @@ impl TypeGenerationTree {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn generate_powerset(_: &[Type]) -> Vec<Vec<Type>> {
|
|
||||||
vec![]
|
|
||||||
}
|
|
||||||
|
|
||||||
fn simplify_type(incoming: &Type) -> Vec<Type> {
|
fn simplify_type(incoming: &Type) -> Vec<Type> {
|
||||||
match incoming {
|
match incoming {
|
||||||
Type::Primitive(_, _) => vec![],
|
Type::Primitive(_, _) => vec![],
|
||||||
@@ -282,8 +289,14 @@ impl Strategy for TypeGenerationContext {
|
|||||||
type Tree = TypeGenerationTree;
|
type Tree = TypeGenerationTree;
|
||||||
type Value = Type;
|
type Value = Type;
|
||||||
|
|
||||||
fn new_tree(&self, _runner: &mut TestRunner) -> NewTree<Self> {
|
fn new_tree(&self, runner: &mut TestRunner) -> NewTree<Self> {
|
||||||
unimplemented!()
|
let initial_type = self.generate_type(runner, 0);
|
||||||
|
|
||||||
|
Ok(TypeGenerationTree {
|
||||||
|
current_value: initial_type,
|
||||||
|
parent: None,
|
||||||
|
untried_simplified_items: None,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user