11use std:: panic:: catch_unwind;
22
3- use mlua:: { Error , Function , IntoLua , Lua , Result , Thread , ThreadStatus , Value } ;
3+ use mlua:: { Error , Function , IntoLua , Lua , Result , Thread , Value } ;
44
55#[ test]
66fn test_thread ( ) -> Result < ( ) > {
@@ -21,17 +21,17 @@ fn test_thread() -> Result<()> {
2121 . eval ( ) ?,
2222 ) ?;
2323
24- assert_eq ! ( thread. status ( ) , ThreadStatus :: Resumable ) ;
24+ assert ! ( thread. is_resumable ( ) ) ;
2525 assert_eq ! ( thread. resume:: <i64 >( 0 ) ?, 0 ) ;
26- assert_eq ! ( thread. status ( ) , ThreadStatus :: Resumable ) ;
26+ assert ! ( thread. is_resumable ( ) ) ;
2727 assert_eq ! ( thread. resume:: <i64 >( 1 ) ?, 1 ) ;
28- assert_eq ! ( thread. status ( ) , ThreadStatus :: Resumable ) ;
28+ assert ! ( thread. is_resumable ( ) ) ;
2929 assert_eq ! ( thread. resume:: <i64 >( 2 ) ?, 3 ) ;
30- assert_eq ! ( thread. status ( ) , ThreadStatus :: Resumable ) ;
30+ assert ! ( thread. is_resumable ( ) ) ;
3131 assert_eq ! ( thread. resume:: <i64 >( 3 ) ?, 6 ) ;
32- assert_eq ! ( thread. status ( ) , ThreadStatus :: Resumable ) ;
32+ assert ! ( thread. is_resumable ( ) ) ;
3333 assert_eq ! ( thread. resume:: <i64 >( 4 ) ?, 10 ) ;
34- assert_eq ! ( thread. status ( ) , ThreadStatus :: Finished ) ;
34+ assert ! ( thread. is_finished ( ) ) ;
3535
3636 let accumulate = lua. create_thread (
3737 lua. load (
@@ -50,9 +50,9 @@ fn test_thread() -> Result<()> {
5050 accumulate. resume :: < ( ) > ( i) ?;
5151 }
5252 assert_eq ! ( accumulate. resume:: <i64 >( 4 ) ?, 10 ) ;
53- assert_eq ! ( accumulate. status ( ) , ThreadStatus :: Resumable ) ;
53+ assert ! ( accumulate. is_resumable ( ) ) ;
5454 assert ! ( accumulate. resume:: <( ) >( "error" ) . is_err( ) ) ;
55- assert_eq ! ( accumulate. status ( ) , ThreadStatus :: Error ) ;
55+ assert ! ( accumulate. is_error ( ) ) ;
5656
5757 let thread = lua
5858 . load (
@@ -65,7 +65,7 @@ fn test_thread() -> Result<()> {
6565 "# ,
6666 )
6767 . eval :: < Thread > ( ) ?;
68- assert_eq ! ( thread. status ( ) , ThreadStatus :: Resumable ) ;
68+ assert ! ( thread. is_resumable ( ) ) ;
6969 assert_eq ! ( thread. resume:: <i64 >( ( ) ) ?, 42 ) ;
7070
7171 let thread: Thread = lua
@@ -92,7 +92,7 @@ fn test_thread() -> Result<()> {
9292
9393 // Already running thread must be unresumable
9494 let thread = lua. create_thread ( lua. create_function ( |lua, ( ) | {
95- assert_eq ! ( lua. current_thread( ) . status ( ) , ThreadStatus :: Running ) ;
95+ assert ! ( lua. current_thread( ) . is_running ( ) ) ;
9696 let result = lua. current_thread ( ) . resume :: < ( ) > ( ( ) ) ;
9797 assert ! (
9898 matches!( result, Err ( Error :: CoroutineUnresumable ) ) ,
@@ -123,12 +123,12 @@ fn test_thread_reset() -> Result<()> {
123123 assert ! ( thread. reset( func. clone( ) ) . is_ok( ) ) ;
124124
125125 for _ in 0 ..2 {
126- assert_eq ! ( thread. status ( ) , ThreadStatus :: Resumable ) ;
126+ assert ! ( thread. is_resumable ( ) ) ;
127127 let _ = thread. resume :: < AnyUserData > ( MyUserData ( arc. clone ( ) ) ) ?;
128- assert_eq ! ( thread. status ( ) , ThreadStatus :: Resumable ) ;
128+ assert ! ( thread. is_resumable ( ) ) ;
129129 assert_eq ! ( Arc :: strong_count( & arc) , 2 ) ;
130130 thread. resume :: < ( ) > ( ( ) ) ?;
131- assert_eq ! ( thread. status ( ) , ThreadStatus :: Finished ) ;
131+ assert ! ( thread. is_finished ( ) ) ;
132132 thread. reset ( func. clone ( ) ) ?;
133133 lua. gc_collect ( ) ?;
134134 assert_eq ! ( Arc :: strong_count( & arc) , 1 ) ;
@@ -138,21 +138,21 @@ fn test_thread_reset() -> Result<()> {
138138 let func: Function = lua. load ( r#"function(ud) error("test error") end"# ) . eval ( ) ?;
139139 let thread = lua. create_thread ( func. clone ( ) ) ?;
140140 let _ = thread. resume :: < AnyUserData > ( MyUserData ( arc. clone ( ) ) ) ;
141- assert_eq ! ( thread. status ( ) , ThreadStatus :: Error ) ;
141+ assert ! ( thread. is_error ( ) ) ;
142142 assert_eq ! ( Arc :: strong_count( & arc) , 2 ) ;
143143 #[ cfg( any( feature = "lua55" , feature = "lua54" ) ) ]
144144 {
145145 assert ! ( thread. reset( func. clone( ) ) . is_err( ) ) ;
146146 // Reset behavior has changed in Lua v5.4.4
147147 // It's became possible to force reset thread by popping error object
148- assert ! ( matches! ( thread. status ( ) , ThreadStatus :: Finished ) ) ;
148+ assert ! ( thread. is_finished ( ) ) ;
149149 assert ! ( thread. reset( func. clone( ) ) . is_ok( ) ) ;
150- assert_eq ! ( thread. status ( ) , ThreadStatus :: Resumable ) ;
150+ assert ! ( thread. is_resumable ( ) ) ;
151151 }
152152 #[ cfg( any( feature = "lua55" , feature = "lua54" , feature = "luau" ) ) ]
153153 {
154154 assert ! ( thread. reset( func. clone( ) ) . is_ok( ) ) ;
155- assert_eq ! ( thread. status ( ) , ThreadStatus :: Resumable ) ;
155+ assert ! ( thread. is_resumable ( ) ) ;
156156 }
157157
158158 // Try reset running thread
0 commit comments