11use assert_fs:: TempDir ;
22use assert_fs:: fixture:: { FileWriteStr , PathChild } ;
3- use indoc:: indoc;
3+ use indoc:: { formatdoc , indoc} ;
44use scarb_test_support:: command:: Scarb ;
55use scarb_test_support:: project_builder:: ProjectBuilder ;
6-
7- #[ test]
8- fn standalone_can_take_big_number_as_arg ( ) {
9- let t = TempDir :: new ( ) . unwrap ( ) ;
10-
11- ProjectBuilder :: start ( )
12- . name ( "hello" )
13- . version ( "0.1.0" )
14- . manifest_extra ( indoc ! { r#"
15- [executable]
16-
17- [cairo]
18- enable-gas = false
19- "# } )
20- . dep_cairo_execute ( )
21- . lib_cairo ( indoc ! { r#"
22- #[executable]
23- fn main(a: felt252, b: felt252) -> felt252 {
24- b
25- }
26- "# } )
27- . build ( & t) ;
28-
29- Scarb :: quick_command ( )
30- . arg ( "execute" )
31- . arg ( "--print-program-output" )
32- . arg ( "--arguments" )
33- . arg ( r#"1,1129815197211541481934112806673325772687763881719835256646064516195041515616"# )
34- . current_dir ( & t)
35- . assert ( )
36- . success ( )
37- . stdout_eq ( indoc ! { r#"
38- [..]Compiling hello v0.1.0 ([..]/Scarb.toml)
39- [..]Finished `dev` profile target(s) in [..]
40- [..]Executing hello
41- Program output:
42- 1129815197211541481934112806673325772687763881719835256646064516195041515616
43- Saving output to: target/execute/hello/execution1
44- "# } ) ;
45- }
46-
47- #[ test]
48- fn standalone_can_read_arguments_from_file ( ) {
6+ use test_case:: test_case;
7+
8+ #[ test_case(
9+ "standalone" ,
10+ "1129815197211541481934112806673325772687763881719835256646064516195041515616"
11+ ) ]
12+ #[ test_case(
13+ "bootloader" ,
14+ "1\n 3\n -1272769738511508193392446484420387256363817420616635924344207712676117344847\n 1129815197211541481934112806673325772687763881719835256646064516195041515616"
15+ ) ]
16+ fn can_take_big_number_as_arg ( target : & str , output : & str ) {
4917 let t = TempDir :: new ( ) . unwrap ( ) ;
5018
5119 ProjectBuilder :: start ( )
@@ -66,73 +34,34 @@ fn standalone_can_read_arguments_from_file() {
6634 "# } )
6735 . build ( & t) ;
6836
69- t. child ( "args.txt" )
70- . write_str ( r#"["0x1","0x27F73E6C94FA8249EC9F2F4EEC607ACC97FA632C9E8FB6C49437E62390D9860"]"# )
71- . unwrap ( ) ;
72-
73- Scarb :: quick_command ( )
74- . arg ( "execute" )
75- . arg ( "--print-program-output" )
76- . args ( [ "--arguments-file" , "args.txt" ] )
77- . current_dir ( & t)
78- . assert ( )
79- . success ( )
80- . stdout_eq ( indoc ! { r#"
81- [..]Compiling hello v0.1.0 ([..]/Scarb.toml)
82- [..]Finished `dev` profile target(s) in [..]
83- [..]Executing hello
84- Program output:
85- 1129815197211541481934112806673325772687763881719835256646064516195041515616
86- Saving output to: target/execute/hello/execution1
87- "# } ) ;
88- }
89-
90- #[ test]
91- fn bootloader_can_take_big_number_as_arg ( ) {
92- let t = TempDir :: new ( ) . unwrap ( ) ;
93-
94- ProjectBuilder :: start ( )
95- . name ( "hello" )
96- . version ( "0.1.0" )
97- . manifest_extra ( indoc ! { r#"
98- [executable]
99-
100- [cairo]
101- enable-gas = false
102- "# } )
103- . dep_cairo_execute ( )
104- . lib_cairo ( indoc ! { r#"
105- #[executable]
106- fn main(a: felt252, b: felt252) -> felt252 {
107- b
108- }
109- "# } )
110- . build ( & t) ;
111-
11237 Scarb :: quick_command ( )
11338 . arg ( "execute" )
11439 . arg ( "--print-program-output" )
115- . arg ( "--target=bootloader" )
40+ . arg ( format ! ( "--target={target}" ) )
11641 . arg ( "--arguments" )
11742 . arg ( r#"1,1129815197211541481934112806673325772687763881719835256646064516195041515616"# )
11843 . current_dir ( & t)
11944 . assert ( )
12045 . success ( )
121- . stdout_eq ( indoc ! { r#"
46+ . stdout_eq ( formatdoc ! { r#"
12247 [..]Compiling hello v0.1.0 ([..]/Scarb.toml)
12348 [..]Finished `dev` profile target(s) in [..]
12449 [..]Executing hello
12550 Program output:
126- 1
127- 3
128- -1272769738511508193392446484420387256363817420616635924344207712676117344847
129- 1129815197211541481934112806673325772687763881719835256646064516195041515616
51+ {output}
13052 Saving output to: target/execute/hello/execution1
13153 "# } ) ;
13254}
13355
134- #[ test]
135- fn bootloader_can_read_arguments_from_file ( ) {
56+ #[ test_case(
57+ "standalone" ,
58+ "1129815197211541481934112806673325772687763881719835256646064516195041515616"
59+ ) ]
60+ #[ test_case(
61+ "bootloader" ,
62+ "1\n 3\n -1272769738511508193392446484420387256363817420616635924344207712676117344847\n 1129815197211541481934112806673325772687763881719835256646064516195041515616"
63+ ) ]
64+ fn can_read_arguments_from_file ( target : & str , output : & str ) {
13665 let t = TempDir :: new ( ) . unwrap ( ) ;
13766
13867 ProjectBuilder :: start ( )
@@ -159,21 +88,18 @@ fn bootloader_can_read_arguments_from_file() {
15988
16089 Scarb :: quick_command ( )
16190 . arg ( "execute" )
162- . arg ( "--target=bootloader" )
16391 . arg ( "--print-program-output" )
92+ . arg ( format ! ( "--target={target}" ) )
16493 . args ( [ "--arguments-file" , "args.txt" ] )
16594 . current_dir ( & t)
16695 . assert ( )
16796 . success ( )
168- . stdout_eq ( indoc ! { r#"
97+ . stdout_eq ( formatdoc ! { r#"
16998 [..]Compiling hello v0.1.0 ([..]/Scarb.toml)
17099 [..]Finished `dev` profile target(s) in [..]
171100 [..]Executing hello
172101 Program output:
173- 1
174- 3
175- -1272769738511508193392446484420387256363817420616635924344207712676117344847
176- 1129815197211541481934112806673325772687763881719835256646064516195041515616
102+ {output}
177103 Saving output to: target/execute/hello/execution1
178104 "# } ) ;
179105}
0 commit comments