Last active
November 4, 2022 17:09
-
-
Save adetaylor/b1e20d59a78e1e1433fd22ad69cff7c1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[gtest(RustValuesTest, TypeConfusion)] | |
fn test_type_confusion() { | |
let mut v = NewValueSlotForTesting(); | |
let mut v = ValueSlotRef::from(&mut v); | |
let mut l = v.construct_list(); | |
// l.set_integer_key("a", 3); // does not compile | |
} | |
#[gtest(RustValuesTest, DataRace)] | |
fn test_data_race() { | |
let mut v = NewValueSlotForTesting(); | |
let mut v = ValueSlotRef::from(&mut v); | |
let mut parent_list = v.construct_list(); | |
parent_list.append_integer(1); | |
parent_list.append_integer(2); | |
parent_list.append_integer(3); | |
// No .iter() API, but if we had one, the returned | |
// iterator would have a reference to parent_list | |
//for item in parent_list.iter() { | |
//if item == 2 { | |
// parent_list.reserve(4); // not yet a 'reserve' API | |
// Would not compile due to & list reference still owned | |
// by iterator. | |
//} | |
//} | |
} | |
#[gtest(RustValuesTest, UseAfterFree)] | |
fn test_use_after_free() { | |
let mut v = NewValueSlotForTesting(); | |
let mut v = ValueSlotRef::from(&mut v); | |
let mut parent_list = v.construct_list(); | |
let mut child_list = parent_list.append_list(); | |
// parent_list.append_string("oops"); // does not compile | |
child_list.append_string("oh dear"); | |
} | |
#[gtest(RustValuesTest, Overflow)] | |
fn test_overflow() { | |
let mut v = NewValueSlotForTesting(); | |
let mut v = ValueSlotRef::from(&mut v); | |
let mut parent_list = v.construct_list(); | |
parent_list.append_integer(1); | |
parent_list.append_integer(2); | |
parent_list.append_integer(3); | |
// parent_list.get(4); // no such API right now; less common | |
// with Rust usage patterns? | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment