8000 Add cfg(test) to line domain impl by andrewmilson · Pull Request #969 · starkware-libs/stwo-cairo · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add cfg(test) to line domain impl #969

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions stwo_cairo_verifier/crates/verifier_core/src/poly/line.cairo
< 10000 tr data-hunk="bc2897fceebe5d601599ba27fa29cba0b423a4a79f8704fa5eb4c554c487b33d" class="show-top-border">
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,9 @@ pub struct LineDomain {
pub coset: Coset,
}

#[cfg(test)]
#[generate_trait]
pub impl LineDomainImpl of LineDomainTrait {
pub impl LineDomainNewImpl of LineDomainNewTrait {
/// Returns a domain comprising of the x-coordinates of points in a coset.
fn new(coset: Coset) -> LineDomain {
let coset_size = coset.size();
Expand All @@ -197,10 +198,13 @@ pub impl LineDomainImpl of LineDomainTrait {
}
LineDomain { coset: coset }
}
}

#[generate_trait]
pub impl LineDomainImpl of LineDomainTrait {
/// Returns a domain comprising of the x-coordinates of points in a coset.
///
/// # Saftey
/// # Safety
///
/// All coset points must have unique `x` coordinates.
fn new_unchecked(coset: Coset) -> LineDomain {
Expand Down Expand Up @@ -272,12 +276,14 @@ mod tests {
use core::iter::{IntoIterator, Iterator};
use crate::circle::{CirclePointIndexImpl, CosetImpl};
use crate::fields::qm31::qm31_const;
use super::{LineDomain, LineDomainImpl, LineDomainIterator, LinePoly, LinePolyTrait};
use super::{
LineDomain, LineDomainImpl, LineDomainIterator, LineDomainNewImpl, LinePoly, LinePolyTrait,
};

#[test]
fn test_evaluate() {
let log_size = 3;
let domain = LineDomainImpl::new(CosetImpl::half_odds(log_size));
let domain = LineDomainImpl::new_unchecked(CosetImpl::half_odds(log_size));
let poly = LinePoly {
coeffs: array![
qm31_const::<1, 8, 0, 1>(), qm31_const::<2, 7, 1, 2>(), qm31_const::<3, 6, 0, 1>(),
Expand All @@ -298,7 +304,7 @@ mod tests {
#[test]
fn test_evaluate_with_large_domain() {
let log_size = 3;
let domain = LineDomainImpl::new(CosetImpl::half_odds(log_size + 2));
let domain = LineDomainImpl::new_unchecked(CosetImpl::half_odds(log_size + 2));
let poly = LinePoly {
coeffs: array![
qm31_const::<1, 8, 0, 1>(), qm31_const::<2, 7, 1, 2>(), qm31_const::<3, 6, 0, 1>(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ use crate::poly::line::{LineDomainImpl, LinePoly, LinePolyTrait};
#[test]
fn line_domain_of_size_two_works() {
let coset = CosetImpl::new(CirclePointIndexImpl::new(0), 1);
LineDomainImpl::new(coset);
LineDomainImpl::new_unchecked(coset);
}

#[test]
fn line_domain_of_size_one_works() {
let coset = CosetImpl::new(CirclePointIndexImpl::new(0), 0);
LineDomainImpl::new(coset);
LineDomainImpl::new_unchecked(coset);
}

#[test]
Expand Down
Loading
0