<commit_before>use core::float::consts::pi;

use angle::*;
use mat::Mat4;
use vec::{Vec3, Vec4};

#[test]
fn test_radians() {
    assert Radians(0.0).to_degrees()            == Degrees(0.0);
    assert *Radians(pi / 4.0).to_degrees()      == *Degrees(45.0);   // Removing the unwrap operators causes an ICE.
    assert *Radians(pi / 2.0).to_degrees()      == *Degrees(90.0);   // I think it only happens on operations where
    assert *Radians(pi).to_degrees()            == *Degrees(180.0);  // Rust has to do a bit of type inference.
    assert *Radians(2.0 * pi).to_degrees()      == *Degrees(360.0);
    assert *Radians(5.0 * pi).to_degrees()      == *Degrees(900.0);
    assert *Radians(-pi).to_degrees()           == *Degrees(-180.0);
    
    assert Radians(0.0).to_radians()            == Radians(0.0);
    assert *Radians(5.0 * pi).to_radians()      == *Radians(5.0 * pi);
    assert *Radians(-pi).to_radians()           == *Radians(-pi);
    
    assert *Radians(pi).wrap()                  == *Radians(pi);
    assert *Radians(3.0 * pi).wrap()            == *Radians(pi);
    assert *Radians(2.0 * pi).wrap()            == *Radians(0.0);
    assert *Radians(-pi).wrap()                 == *Radians(-pi);   // FIXME: should be in the domain of 0 to two_pi
    assert *Radians(-3.0 * pi).wrap()           == *Radians(-pi);   // FIXME: should be in the domain of 0 to two_pi
    assert *Radians(-2.0 * pi).wrap()           == *Radians(0.0);
    
    assert *Radians(0.0).opposite()             == *Radians(pi as float);
    assert *Radians(pi / 2.0).opposite()        == *Radians((pi / 2.0) * 3.0);
    assert *Radians(pi * 3.0).opposite()        == *Radians(0.0);
    assert *Radians(-2.0 * pi).opposite()       == *Radians(-pi);   // FIXME: should be in the domain of 0 to two_pi
    
    assert *(Radians(pi) + Radians(pi))         == *Radians(2.0 * pi);
    assert *(Radians(2.0 * pi) - Radians(pi))   == *Radians(pi);
    assert *(Radians(pi) * 2.0)                 == *Radians(2.0 * pi);
    assert *(Radians(pi) / 2.0)                 == *Radians(pi / 2.0);
    assert *(Radians(3.0 * pi) % (2.0 * pi))    == *Radians(pi);
    assert *(-Radians(pi))                      == *Radians(-pi);
    
    assert fmt!("%s", Radians(1).to_str())      == ~"1 rad";
}

#[test]
fn test_degrees() {
    assert Degrees(0.0).to_radians()            == Radians(0.0);
    assert Degrees(45.0).to_radians()           == Radians(pi / 4.0 as float);  // Rust can't infer these types
    assert Degrees(90.0).to_radians()           == Radians(pi / 2.0 as float);
    assert Degrees(180.0).to_radians()          == Radians(pi       as float);
    assert Degrees(360.0).to_radians()          == Radians(2.0 * pi as float);
    assert Degrees(900.0).to_radians()          == Radians(5.0 * pi as float);
    assert Degrees(-180.0).to_radians()         == Radians(-pi      as float);
    
    assert Degrees(0.0).to_degrees()            == Degrees(0.0);
    assert Degrees(900.0).to_degrees()          == Degrees(900.0);
    assert Degrees(-180.0).to_degrees()         == Degrees(-180.0);
    
    assert Degrees(90.0).wrap()                 == Degrees(90.0);
    assert Degrees(450.0).wrap()                == Degrees(90.0);
    assert Degrees(360.0).wrap()                == Degrees(0.0);
    assert Degrees(-90.0).wrap()                == Degrees(-90.0);   // FIXME: should be in the domain of 0 to 360
    assert Degrees(-450.0).wrap()               == Degrees(-90.0);   // FIXME: should be in the domain of 0 to 360
    assert Degrees(-360.0).wrap()               == Degrees(0.0);
    
    assert Degrees(0.0).opposite()             == Degrees(180.0);
    assert Degrees(90.0).opposite()            == Degrees(270.0);
    assert Degrees(540.0).opposite()           == Degrees(0.0);
    assert Degrees(-360.0).opposite()          == Degrees(-180.0);   // FIXME: should be in the domain of 0 to 360
    
    assert (Degrees(180.0) + Degrees(180.0))    == Degrees(360.0);
    assert (Degrees(360.0) - Degrees(180.0))    == Degrees(180.0);
    assert (Degrees(360.0) * 2.0)               == Degrees(720.0);
    assert (Degrees(180.0) / 2.0)               == Degrees(90.0);
    assert (Degrees(540.0) % (360.0))           == Degrees(180.0);
    assert (-Degrees(180.0))                    == Degrees(-180.0);
    
    assert fmt!("%s", Degrees(180.0).to_str())  == ~"180°";
}
<commit_msg>Remove unwrap operators<commit_after>use core::float::consts::pi;

use angle::*;
use mat::Mat4;
use vec::{Vec3, Vec4};

#[test]
fn test_radians() {
    assert Radians(0.0).to_degrees()            == Degrees(0.0);
    assert Radians(pi / 4.0).to_degrees()       == Degrees(45.0);
    assert Radians(pi / 2.0).to_degrees()       == Degrees(90.0);
    assert Radians(pi).to_degrees()             == Degrees(180.0);
    assert Radians(2.0 * pi).to_degrees()       == Degrees(360.0);
    assert Radians(5.0 * pi).to_degrees()       == Degrees(900.0);
    assert Radians(-pi).to_degrees()            == Degrees(-180.0);
    
    assert Radians(0.0).to_radians()            == Radians(0.0);
    assert Radians(5.0 * pi).to_radians()       == Radians(5.0 * pi);
    assert Radians(-pi).to_radians()            == Radians(-pi);
    
    assert Radians(pi).wrap()                   == Radians(pi);
    assert Radians(3.0 * pi).wrap()             == Radians(pi);
    assert Radians(2.0 * pi).wrap()             == Radians(0.0);
    assert Radians(-pi).wrap()                  == Radians(-pi);   // FIXME: should be in the domain of 0 to two_pi
    assert Radians(-3.0 * pi).wrap()            == Radians(-pi);   // FIXME: should be in the domain of 0 to two_pi
    assert Radians(-2.0 * pi).wrap()            == Radians(0.0);
    
    assert Radians(0.0).opposite()              == Radians(pi as float);
    assert Radians(pi / 2.0).opposite()         == Radians((pi / 2.0) * 3.0);
    assert Radians(pi * 3.0).opposite()         == Radians(0.0);
    assert Radians(-2.0 * pi).opposite()        == Radians(-pi);   // FIXME: should be in the domain of 0 to two_pi
    
    assert Radians(pi) + Radians(pi)            == Radians(2.0 * pi);
    assert Radians(2.0 * pi) - Radians(pi)      == Radians(pi);
    assert Radians(pi) * 2.0                    == Radians(2.0 * pi);
    assert Radians(pi) / 2.0                    == Radians(pi / 2.0);
    assert Radians(3.0 * pi) % (2.0 * pi)       == Radians(pi);
    assert -Radians(pi)                         == Radians(-pi);
    
    assert fmt!("%s", Radians(1).to_str())      == ~"1 rad";
}

#[test]
fn test_degrees() {
    assert Degrees(0.0).to_radians()            == Radians(0.0);
    assert Degrees(45.0).to_radians()           == Radians(pi / 4.0 as float);  // Rust can't infer these types
    assert Degrees(90.0).to_radians()           == Radians(pi / 2.0 as float);
    assert Degrees(180.0).to_radians()          == Radians(pi       as float);
    assert Degrees(360.0).to_radians()          == Radians(2.0 * pi as float);
    assert Degrees(900.0).to_radians()          == Radians(5.0 * pi as float);
    assert Degrees(-180.0).to_radians()         == Radians(-pi      as float);
    
    assert Degrees(0.0).to_degrees()            == Degrees(0.0);
    assert Degrees(900.0).to_degrees()          == Degrees(900.0);
    assert Degrees(-180.0).to_degrees()         == Degrees(-180.0);
    
    assert Degrees(90.0).wrap()                 == Degrees(90.0);
    assert Degrees(450.0).wrap()                == Degrees(90.0);
    assert Degrees(360.0).wrap()                == Degrees(0.0);
    assert Degrees(-90.0).wrap()                == Degrees(-90.0);   // FIXME: should be in the domain of 0 to 360
    assert Degrees(-450.0).wrap()               == Degrees(-90.0);   // FIXME: should be in the domain of 0 to 360
    assert Degrees(-360.0).wrap()               == Degrees(0.0);
    
    assert Degrees(0.0).opposite()              == Degrees(180.0);
    assert Degrees(90.0).opposite()             == Degrees(270.0);
    assert Degrees(540.0).opposite()            == Degrees(0.0);
    assert Degrees(-360.0).opposite()           == Degrees(-180.0);   // FIXME: should be in the domain of 0 to 360
    
    assert Degrees(180.0) + Degrees(180.0)      == Degrees(360.0);
    assert Degrees(360.0) - Degrees(180.0)      == Degrees(180.0);
    assert Degrees(360.0) * 2.0                 == Degrees(720.0);
    assert Degrees(180.0) / 2.0                 == Degrees(90.0);
    assert Degrees(540.0) % (360.0)             == Degrees(180.0);
    assert -Degrees(180.0)                      == Degrees(-180.0);
    
    assert fmt!("%s", Degrees(180.0).to_str())  == ~"180°";
}

{'fraction_non_alphanumeric': 0.1830019765143588, 'fraction_numerical': 0.06813161260318568, 'mean_word_length': 1.934834527465029, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1321752', 'n_tokens_mistral': 3268, 'n_tokens_neox': 3022, 'n_words': 614}