Skip to content
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

Bug: cairo tests fmt_test fails #470

Closed
edg-l opened this issue Mar 12, 2024 · 5 comments · Fixed by #549
Closed

Bug: cairo tests fmt_test fails #470

edg-l opened this issue Mar 12, 2024 · 5 comments · Fixed by #549
Assignees
Labels
bug Something isn't working odhack
Milestone

Comments

@edg-l
Copy link
Member

edg-l commented Mar 12, 2024

// ./cairo-tests/src/fmt_test.cairo

// TODO: fails
#[test]
#[ignore]
fn test_format() {
    let ba: ByteArray = "hello";
    assert(format!("{}", ba) == ba, 'byte array bad formatting');
    assert(format!("{}", 97_felt252) == "97", 'felt252 bad formatting');
    assert(format!("{}", 97_usize) == "97", 'usize bad formatting');
    assert(format!("{}", 34 - 5) == "29", 'expression bad formatting');
    assert(format!("no_format") == "no_format", 'no args bad formatting');
    assert(format!("{}{}", 12_usize, 14_u32) == "1214", 'two args bad formatting');
    assert(format!("{0}{0}", 12_usize) == "1212", 'positional bad formatting');
    assert(format!("{}{1}", 12_usize, 14_u32) == "1214", 'positional mix bad formatting');
    assert(format!("{ba}_{}_{}_{1}", 12, 14_u32) == "hello_12_14_14", 'full mix bad formatting');
    assert(format!("{{{{}}}}") == "{{}}", 'special cases bad formatting');
    let nz_value: NonZero<felt252> = 1.try_into().unwrap();
    assert(format!("{}", nz_value) == "1", 'non zero bad formatting');
}

// TODO: fails
#[test]
#[ignore]
fn test_format_debug() {
    let ba: ByteArray = "hello";
    assert(format!("{:?}", ba) == "\"hello\"", 'byte array bad formatting');
    assert(format!("{:?}", 97_felt252) == "97", 'felt252 bad formatting');
    assert(format!("{:?}", 97_usize) == "97", 'usize bad formatting');
    assert(format!("{:?}{:?}", 12_usize, 14_u32) == "1214", 'two args bad formatting');
    assert(format!("{0:?}{0:?}", 12_usize) == "1212", 'positional bad formatting');
    assert(format!("{:?}{1:?}", 12_usize, 14_u32) == "1214", 'positional mix bad formatting');
    assert(
        format!("{ba:?}_{:?}_{:?}_{1:?}", 12, 14_u32) == "\"hello\"_12_14_14",
        'full mix bad formatting'
    );
    assert(
        format!("{:?}", EnumExample::Empty) == "EnumExample::Empty(())", 'bad enum empty derive fmt'
    );
    assert(
        format!("{:?}", EnumExample::FeltValue(4)) == "EnumExample::FeltValue(4)",
        'bad derive enum fmt'
    );
    assert(
        format!(
            "{:?}",
            StructExample {
                felt_value: 6,
                bool_value: false,
                byte_array_value: "ByteArray",
                enum_value: EnumExample::BoolValue(true)
            }
        ) == "StructExample { felt_value: 6, bool_value: false, byte_array_value: \"ByteArray\", enum_value: EnumExample::BoolValue(true) }",
        'bad derive struct formatting'
    );
    assert(
        format!("{:?}", ((), (1,), (2, 3), (4, 5, 6))) == "((), (1,), (2, 3), (4, 5, 6))",
        'bad tuple fmt'
    );
    assert(format!("{:?}", core::box::BoxTrait::new(1)) == "&1", 'bad box fmt');
    assert(
        format!("{:?}", core::nullable::NullableTrait::new(1)) == "&1", 'bad nullable value fmt'
    );
    assert(format!("{:?}", core::nullable::null::<felt252>()) == "null", 'bad null fmt');
}

// TODO: fails
#[test]
#[ignore]
fn test_array_debug() {
    let arr = array![1, 2, 3];
    assert(format!("{:?}", arr) == "[1, 2, 3]", 'bad array fmt');
}
@edg-l edg-l added the bug Something isn't working label Mar 12, 2024
@igaray igaray added this to Starknet Mar 12, 2024
@igaray igaray added this to the 0.1 milestone Mar 12, 2024
@igaray igaray moved this to Backlog in Starknet Mar 13, 2024
@igaray igaray moved this from Backlog to Todo in Starknet Mar 13, 2024
@igaray igaray added the odhack label Mar 18, 2024
@Immanuelolivia1
Copy link

Please can I be assigned this?
I'm sure i can handle this.

@igaray
Copy link
Collaborator

igaray commented Mar 18, 2024

I'd wait until tomorrow just in case @edg-l has something for this, but otherwise go for it.

@Immanuelolivia1
Copy link

Hi @igaray any telegram group where i can direct my questions to ?
i'm having issues running and building

@azteca1998
Copy link
Collaborator

Hello, you can ask them here. There's a telegram group but I can't guarantee I'll see your questions there.

@Immanuelolivia1
Copy link

Immanuelolivia1 commented Mar 26, 2024 via email

@azteca1998 azteca1998 linked a pull request Apr 25, 2024 that will close this issue
5 tasks
@github-project-automation github-project-automation bot moved this from Todo to Done in Starknet Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working odhack
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants