@@ -51,6 +51,15 @@ fn test_variables(rt: &RuntimeServices) {
51
51
info ! ( "First variable: {}" , key) ;
52
52
}
53
53
54
+ // Test that the `runtime::variable_keys` iterator gives exactly the same
55
+ // list as the `RuntimeServices::variable_keys` function.
56
+ assert_eq ! (
57
+ runtime:: variable_keys( )
58
+ . map( |k| k. unwrap( ) )
59
+ . collect:: <alloc:: vec:: Vec <_>>( ) ,
60
+ variable_keys
61
+ ) ;
62
+
54
63
info ! ( "Testing delete_variable()" ) ;
55
64
rt. delete_variable ( NAME , VENDOR )
56
65
. expect ( "failed to delete variable" ) ;
@@ -86,6 +95,15 @@ fn test_variables_freestanding() {
86
95
assert_eq ! ( & * data, VALUE ) ;
87
96
assert_eq ! ( attrs, ATTRS ) ;
88
97
98
+ // Test that the variable is present in the `variable_keys` iterator.
99
+ let find_by_key = || {
100
+ runtime:: variable_keys ( ) . any ( |k| {
101
+ let k = k. as_ref ( ) . unwrap ( ) ;
102
+ k. name ( ) . unwrap ( ) == NAME && & k. vendor == VENDOR
103
+ } )
104
+ } ;
105
+ assert ! ( find_by_key( ) ) ;
106
+
89
107
// Delete the variable and verify it can no longer be read.
90
108
runtime:: delete_variable ( NAME , VENDOR ) . expect ( "failed to delete variable" ) ;
91
109
assert_eq ! (
@@ -94,6 +112,8 @@ fn test_variables_freestanding() {
94
112
. status( ) ,
95
113
Status :: NOT_FOUND
96
114
) ;
115
+ // Variable is no longer present in the `variable_keys` iterator.
116
+ assert ! ( !find_by_key( ) ) ;
97
117
}
98
118
99
119
fn test_variable_info ( rt : & RuntimeServices ) {
0 commit comments