<commit_before>use strict;
use warnings;
use Test::More;
use Chipmunk::DampedRotarySpring;
use Chipmunk::DampedSpring;
use Chipmunk::GearJoint;
use Chipmunk::GrooveJoint;
use Chipmunk::PinJoint;
use Chipmunk::PivotJoint;
use Chipmunk::RatchetJoint;
use Chipmunk::RotaryLimitJoint;
use Chipmunk::SlideJoint;
use Chipmunk::Body;
use Chipmunk::Space;

my $space = Chipmunk::Space->new();

my @constraints;

{
    my $a = Chipmunk::Body->new( 1.0, 2.0 );
    my $b = Chipmunk::Body->new( 2.0, 3.0 );
    my ( $restAngle, $stiffness, $damping ) = ( 0.0, 1.0, 2.0 );
    my $spring
        = Chipmunk::DampedRotarySpring->new( $a, $b, $restAngle, $stiffness,
        $damping );
    $space->add_constraint($spring);
    push @constraints,
        { type => 'dampedrotaryspring', constraint => $spring };
}

{
    my $a = Chipmunk::Body->new( 1.0, 2.0 );
    my $b = Chipmunk::Body->new( 2.0, 3.0 );
    my ( $anchr1, $anchr2 ) = ( [ 4.0, 5.0 ], [ 6.0, 7.0 ] );
    my ( $restLength, $stiffness, $damping ) = ( 1.0, 2.0, 3.0 );
    my $spring
        = Chipmunk::DampedSpring->new( $a, $b, $anchr1, $anchr2, $restLength,
        $stiffness, $damping );
    $space->add_constraint($spring);
    push @constraints, { type => 'dampedspring', constraint => $spring };
}

{
    my ( $mass, $inertia ) = ( 1.1, 2.2 );
    my $a = Chipmunk::Body->new( $mass, $inertia );
    my $b = Chipmunk::Body->new( $mass, $inertia );
    my $anchr1 = [ 3.3, 4.4 ];
    my $anchr2 = [ 5.5, 6.6 ];
    my ( $phase, $ratio ) = ( 1.1, 2.2 );
    my $joint = Chipmunk::GearJoint->new( $a, $b, $phase, $ratio );
    $space->add_constraint($joint);
    push @constraints, { type => 'gearjoint', constraint => $joint };
}

{
    my ( $mass, $inertia ) = ( 1.1, 2.2 );
    my $a = Chipmunk::Body->new( $mass, $inertia );
    my $b = Chipmunk::Body->new( $mass, $inertia );
    my ( $groove_a, $groove_b ) = ( [ 3.3, 4.4 ], [ 5.5, 6.6 ] );
    my $anchr2 = [ 7.7, 8.8 ];
    my $joint
        = Chipmunk::GrooveJoint->new( $a, $b, $groove_a, $groove_b, $anchr2 );
    $space->add_constraint($joint);
    push @constraints, { type => 'groovejoint', constraint => $joint };
}

{
    my ( $mass, $inertia ) = ( 1.1, 2.2 );
    my $a = Chipmunk::Body->new( $mass, $inertia );
    my $b = Chipmunk::Body->new( $mass, $inertia );
    my $anchr1 = [ 3.3, 4.4 ];
    my $anchr2 = [ 5.5, 6.6 ];
    my $joint = Chipmunk::PinJoint->new( $a, $b, $anchr1, $anchr2 );
    $space->add_constraint($joint);
    push @constraints, { type => 'pinjoint', constraint => $joint };
}

{
    my ( $mass, $inertia ) = ( 1.0, 2.0 );
    my $a = Chipmunk::Body->new( $mass, $inertia );
    my $b = Chipmunk::Body->new( $mass, $inertia );
    my $pivot = [ 3.3, 4.4 ];
    my $joint = Chipmunk::PivotJoint->new( $a, $b, $pivot );
    $space->add_constraint($joint);
    push @constraints, { type => 'pivotjoint', constraint => $joint };
}

{
    my ( $mass, $inertia ) = ( 1.1, 2.2 );
    my $a = Chipmunk::Body->new( $mass, $inertia );
    my $b = Chipmunk::Body->new( $mass, $inertia );
    my ( $phase, $ratchet ) = ( 3.3, 4.4 );
    my $joint = Chipmunk::RatchetJoint->new( $a, $b, $phase, $ratchet );
    $space->add_constraint($joint);
    push @constraints, { type => 'ratchetjoint', constraint => $joint };
}

{
    my ( $mass, $inertia ) = ( 1.1, 2.2 );
    my $a = Chipmunk::Body->new( $mass, $inertia );
    my $b = Chipmunk::Body->new( $mass, $inertia );
    my ( $min, $max ) = ( 3.3, 4.4 );
    my $joint = Chipmunk::RotaryLimitJoint->new( $a, $b, $min, $max );
    $space->add_constraint($joint);
    push @constraints, { type => 'rotarylimitjoint', constraint => $joint };
}

# TODO: SimpleMotor

{
    my ( $mass, $inertia ) = ( 1.0, 2.0 );
    my $a = Chipmunk::Body->new( $mass, $inertia );
    my $b = Chipmunk::Body->new( $mass, $inertia );
    my $anchr1 = [ 3.3, 4.4 ];
    my $anchr2 = [ 5.5, 6.6 ];
    my ( $min, $max ) = ( 0.7, 18.8 );
    my $joint
        = Chipmunk::SlideJoint->new( $a, $b, $anchr1, $anchr2, $min, $max );
    $space->add_constraint($joint);
    push @constraints, { type => 'slidejoint', constraint => $joint };
}

for (@constraints) {
    my ( $type, $constraint ) = @$_{qw( type constraint )};

    isa_ok( $constraint, 'Chipmunk::Constraint', "new ($type)" );

    # TODO: activate_bodies

    isa_ok( $constraint->get_space(), 'Chipmunk::Space',<commit_msg>Add test<commit_after>use strict;
use warnings;
use Test::More;
use Chipmunk::DampedRotarySpring;
use Chipmunk::DampedSpring;
use Chipmunk::GearJoint;
use Chipmunk::GrooveJoint;
use Chipmunk::PinJoint;
use Chipmunk::PivotJoint;
use Chipmunk::RatchetJoint;
use Chipmunk::RotaryLimitJoint;
use Chipmunk::SimpleMotor;
use Chipmunk::SlideJoint;
use Chipmunk::Body;
use Chipmunk::Space;

my $space = Chipmunk::Space->new();

my @constraints;

{
    my $a = Chipmunk::Body->new( 1.0, 2.0 );
    my $b = Chipmunk::Body->new( 2.0, 3.0 );
    my ( $restAngle, $stiffness, $damping ) = ( 0.0, 1.0, 2.0 );
    my $spring
        = Chipmunk::DampedRotarySpring->new( $a, $b, $restAngle, $stiffness,
        $damping );
    $space->add_constraint($spring);
    push @constraints,
        { type => 'dampedrotaryspring', constraint => $spring };
}

{
    my $a = Chipmunk::Body->new( 1.0, 2.0 );
    my $b = Chipmunk::Body->new( 2.0, 3.0 );
    my ( $anchr1, $anchr2 ) = ( [ 4.0, 5.0 ], [ 6.0, 7.0 ] );
    my ( $restLength, $stiffness, $damping ) = ( 1.0, 2.0, 3.0 );
    my $spring
        = Chipmunk::DampedSpring->new( $a, $b, $anchr1, $anchr2, $restLength,
        $stiffness, $damping );
    $space->add_constraint($spring);
    push @constraints, { type => 'dampedspring', constraint => $spring };
}

{
    my ( $mass, $inertia ) = ( 1.1, 2.2 );
    my $a = Chipmunk::Body->new( $mass, $inertia );
    my $b = Chipmunk::Body->new( $mass, $inertia );
    my $anchr1 = [ 3.3, 4.4 ];
    my $anchr2 = [ 5.5, 6.6 ];
    my ( $phase, $ratio ) = ( 1.1, 2.2 );
    my $joint = Chipmunk::GearJoint->new( $a, $b, $phase, $ratio );
    $space->add_constraint($joint);
    push @constraints, { type => 'gearjoint', constraint => $joint };
}

{
    my ( $mass, $inertia ) = ( 1.1, 2.2 );
    my $a = Chipmunk::Body->new( $mass, $inertia );
    my $b = Chipmunk::Body->new( $mass, $inertia );
    my ( $groove_a, $groove_b ) = ( [ 3.3, 4.4 ], [ 5.5, 6.6 ] );
    my $anchr2 = [ 7.7, 8.8 ];
    my $joint
        = Chipmunk::GrooveJoint->new( $a, $b, $groove_a, $groove_b, $anchr2 );
    $space->add_constraint($joint);
    push @constraints, { type => 'groovejoint', constraint => $joint };
}

{
    my ( $mass, $inertia ) = ( 1.1, 2.2 );
    my $a = Chipmunk::Body->new( $mass, $inertia );
    my $b = Chipmunk::Body->new( $mass, $inertia );
    my $anchr1 = [ 3.3, 4.4 ];
    my $anchr2 = [ 5.5, 6.6 ];
    my $joint = Chipmunk::PinJoint->new( $a, $b, $anchr1, $anchr2 );
    $space->add_constraint($joint);
    push @constraints, { type => 'pinjoint', constraint => $joint };
}

{
    my ( $mass, $inertia ) = ( 1.0, 2.0 );
    my $a = Chipmunk::Body->new( $mass, $inertia );
    my $b = Chipmunk::Body->new( $mass, $inertia );
    my $pivot = [ 3.3, 4.4 ];
    my $joint = Chipmunk::PivotJoint->new( $a, $b, $pivot );
    $space->add_constraint($joint);
    push @constraints, { type => 'pivotjoint', constraint => $joint };
}

{
    my ( $mass, $inertia ) = ( 1.1, 2.2 );
    my $a = Chipmunk::Body->new( $mass, $inertia );
    my $b = Chipmunk::Body->new( $mass, $inertia );
    my ( $phase, $ratchet ) = ( 3.3, 4.4 );
    my $joint = Chipmunk::RatchetJoint->new( $a, $b, $phase, $ratchet );
    $space->add_constraint($joint);
    push @constraints, { type => 'ratchetjoint', constraint => $joint };
}

{
    my ( $mass, $inertia ) = ( 1.1, 2.2 );
    my $a = Chipmunk::Body->new( $mass, $inertia );
    my $b = Chipmunk::Body->new( $mass, $inertia );
    my ( $min, $max ) = ( 3.3, 4.4 );
    my $joint = Chipmunk::RotaryLimitJoint->new( $a, $b, $min, $max );
    $space->add_constraint($joint);
    push @constraints, { type => 'rotarylimitjoint', constraint => $joint };
}

{
    my ( $mass, $inertia ) = ( 1.1, 2.2 );
    my $a = Chipmunk::Body->new( $mass, $inertia );
    my $b = Chipmunk::Body->new( $mass, $inertia );
    my $rate = 3.3;
    my $motor = Chipmunk::SimpleMotor->new( $a, $b, $rate );
    $space->add_constraint($motor);
    push @constraints, { type => 'simplemotor', constraint => $motor };
}

{
    my ( $mass, $inertia ) = ( 1.0, 2.0 );
    my $a = Chipmunk::Body->new( $mass, $inertia );
    my $b = Chipmunk::Body->new( $mass, $inertia );
    my $anchr1 = [ 3.3, 4.4 ];
    my $anchr2 = [ 5.5, 6.6 ];
    my ( $min, $max ) = ( 0.7, 18.8 );
    my $joint
        = Chipmunk::SlideJoint->new( $a, $b, $anchr1, $anchr2, $min, $max );
    $space->add_constraint($joint);
    push @constraints, { type => 'slidejoint', constraint => $joint };
}

for (@constraints) {
    my ( $type, $constraint ) = @$_{qw( type constraint )};

    isa_ok( $constraint, 'Chipmunk::Constraint', "new ($type)" );

    # TODO: activate_bodies

    isa_ok( $constraint->get_space(), 'Chipmunk::Space',
{'fraction_non_alphanumeric': 0.21608763000663864, 'fraction_numerical': 0.03098030537729586, 'mean_word_length': 3.0588235294117645, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 121, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '712478', 'n_tokens_mistral': 3970, 'n_tokens_neox': 3695, 'n_words': 811}