text stringlengths 93 16.4k | id stringlengths 20 40 | metadata dict | input_ids listlengths 45 2.05k | attention_mask listlengths 45 2.05k | complexity int64 1 9 |
|---|---|---|---|---|---|
#[test]
fn test_params_of_vary_types() -> Result<()> {
let db = checked_memory_handle();
let sql = "BEGIN;
CREATE TABLE foo(bar TEXT, qux INTEGER);
INSERT INTO foo VALUES ('baz', 1), ('baz', 2), ('baz', 3);
END;";
db.execute_batch(sql)?;
let changed = db.execute("UPDATE foo SET qux = ? WHERE bar = ?", params![1i32, &"baz"])?;
assert_eq!(changed, 3);
Ok(())
} | rust_cleaned_test_functions.jsonl/113042 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 250
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6745,
3575,
2273,
658,
9763,
368,
1464,
5714,
71698,
341,
286,
1077,
2927,
284,
10067,
19195,
10630,
543,
286,
1077,
5704,
284,
330,
37588,
280,
4293,
30776,
14363,
15229,
54630,
15762,
11,
922,
8... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_static_bytes() {
assert_eq!(Body::from(b"test".as_ref()).size(), BodySize::Sized(4));
assert_eq!(Body::from(b"test".as_ref()).get_ref(), b"test");
assert_eq!(
Body::from_slice(b"test".as_ref()).size(),
BodySize::Sized(4)
);
assert_eq!(Body::from_slice(b"test".as_ref()).get_ref(), b"test");
assert_eq!((&b"test"[..]).size(), BodySize::Sized(4));
assert_eq!(
block_on(poll_fn(|cx| (&b"test"[..]).poll_next(cx)))
.unwrap()
.ok(),
Some(Bytes::from("test"))
);
} | rust_cleaned_test_functions.jsonl/82686 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 350
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
25360,
12524,
368,
341,
286,
2060,
10714,
10297,
5444,
486,
1499,
1883,
1,
1944,
3263,
300,
7793,
6011,
2141,
1507,
13958,
1695,
486,
50,
1506,
7,
19,
1106,
286,
2060,
10714,
10297,
5444,
486,
1... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_custom_struct() {
assert_eq!(
mem::size_of::<MyCustomStruct>(),
mem::size_of::<i32>() + mem::size_of::<u32>() + mem::size_of::<f32>()
);
let my_cust_struct = MyCustomStruct::new(1, 2, 3_f32);
assert_eq!(my_cust_struct.a, 1);
assert_eq!(my_cust_struct.b, 2);
assert_eq!(my_cust_struct.c, 3_f32);
assert_eq!(my_cust_struct.sum(), 6_f32);
let m2 = my_cust_struct.clone();
assert_eq!(format!("{:?}", m2), "MyCustomStruct { a: 1, b: 2, c: 3.0 }");
let mut m3 = my_cust_struct;
m3.a = 100;
assert_eq!(m2.a, 1);
assert_eq!(my_cust_struct.a, 1);
assert_eq!(m3.a, 100);
} | rust_cleaned_test_functions.jsonl/132324 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 414
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
15875,
15126,
368,
341,
286,
2060,
10714,
33673,
310,
1833,
486,
2141,
3575,
27638,
5050,
10268,
9422,
65766,
310,
1833,
486,
2141,
3575,
27638,
72,
18,
17,
13555,
488,
1833,
486,
2141,
3575,
2763... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_mul() {
for elm in MUL_TRIPLES.iter() {
let (a_vec, b_vec, c_vec) = *elm;
let a = BigInt::from_slice(Plus, a_vec);
let b = BigInt::from_slice(Plus, b_vec);
let c = BigInt::from_slice(Plus, c_vec);
let (na, nb, nc) = (-&a, -&b, -&c);
assert_op!(a * b == c);
assert_op!(b * a == c);
assert_op!(na * nb == c);
assert_op!(na * b == nc);
assert_op!(nb * a == nc);
assert_assign_op!(a *= b == c);
assert_assign_op!(b *= a == c);
assert_assign_op!(na *= nb == c);
assert_assign_op!(na *= b == nc);
assert_assign_op!(nb *= a == nc);
}
for elm in DIV_REM_QUADRUPLES.iter() {
let (a_vec, b_vec, c_vec, d_vec) = *elm;
let a = BigInt::from_slice(Plus, a_vec);
let b = BigInt::from_slice(Plus, b_vec);
let c = BigInt::from_slice(Plus, c_vec);
let d = BigInt::from_slice(Plus, d_vec);
assert!(a == &b * &c + &d);
assert!(a == &c * &b + &d);
}
} | rust_cleaned_test_functions.jsonl/56630 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 588
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
24944,
368,
341,
262,
369,
42205,
304,
386,
1094,
6410,
3298,
14017,
19471,
368,
341,
286,
1077,
320,
64,
13251,
11,
293,
13251,
11,
272,
13251,
8,
284,
353,
23162,
280,
286,
1077,
264,
284,
6... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_get_batch_range() {
assert_eq!(get_batch_range(None, 100), (0, 99));
assert_eq!(get_batch_range(Some(99), 50), (100, 149));
assert_eq!(get_batch_range(Some(149), 100), (150, 199));
assert_eq!(get_batch_range(Some(199), 100), (200, 299));
} | rust_cleaned_test_functions.jsonl/94282 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 144
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3062,
14534,
9698,
368,
341,
286,
2060,
10714,
10297,
455,
14534,
9698,
26717,
11,
220,
16,
15,
15,
701,
320,
15,
11,
220,
24,
24,
1106,
286,
2060,
10714,
10297,
455,
14534,
9698,
65405,
7,
24... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_insert() {
let mut m = HashMap::new();
assert!(m.insert(1, 2));
assert!(m.insert(2, 4));
assert_eq!(*m.get(&1), 2);
assert_eq!(*m.get(&2), 4);
} | rust_cleaned_test_functions.jsonl/45616 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 119
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
17678,
368,
341,
286,
1077,
5206,
296,
284,
10528,
486,
931,
543,
286,
2060,
10297,
76,
7030,
7,
16,
11,
220,
17,
1106,
286,
2060,
10297,
76,
7030,
7,
17,
11,
220,
19,
1106,
286,
2060,
10714... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_signed_sqrt_rational() {
assert_eq!(f64::from(SignedSqrt::default()), 0.0);
assert_eq!(f64::from(SignedSqrt::new(10.into(), (1, 4).into())), 5.0);
} | rust_cleaned_test_functions.jsonl/80985 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 89
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
55617,
92199,
1710,
1663,
368,
341,
262,
2060,
10714,
10297,
69,
21,
19,
486,
1499,
3759,
1542,
50,
8140,
486,
2258,
11858,
220,
15,
13,
15,
317,
262,
2060,
10714,
10297,
69,
21,
19,
486,
1499... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_issue378_escaped_arguments1() {
test_same(concat!(
"function g(callback) {\n",
" var f = callback;\n",
" h(arguments,this);\n",
" f.apply(this, arguments);\n",
"}\n",
"function h(a,b) {\n",
" a[0] = b;",
"}"
));
} | rust_cleaned_test_functions.jsonl/27721 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 179
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
53340,
18,
22,
23,
62,
65826,
43433,
16,
368,
341,
262,
1273,
33574,
96360,
33673,
286,
330,
1688,
342,
23934,
8,
28152,
77,
756,
286,
330,
220,
762,
282,
284,
4822,
17882,
77,
756,
286,
330,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_host_slaac_and_manual_address_conflict() {
// SLAAC should not overwrite any manually added addresses that may
// address has a different prefix.
let config = Ipv6::DUMMY_CONFIG;
let mut ctx = DummyEventDispatcherBuilder::default().build::<DummyEventDispatcher>();
let device =
ctx.state_mut().add_ethernet_device(config.local_mac, Ipv6::MINIMUM_LINK_MTU.into());
crate::device::initialize_device(&mut ctx, device);
let src_mac = config.remote_mac;
let src_ip = src_mac.to_ipv6_link_local().addr().get();
let prefix = Ipv6Addr::new([1, 2, 3, 4, 5, 6, 7, 8, 0, 0, 0, 0, 0, 0, 0, 0]);
let prefix_length = 64;
let mut manual_addr_sub = [1, 2, 3, 4, 5, 6, 7, 8, 0, 0, 0, 0, 0, 0, 0, 0];
manual_addr_sub[8..].copy_from_slice(&config.local_mac.to_eui64()[..]);
let manual_addr_sub = UnicastAddr::new(Ipv6Addr::new(manual_addr_sub)).unwrap();
let manual_addr_sub =
AddrSubnet::from_witness(manual_addr_sub, prefix_length + 10).unwrap();
// Manually give the device the expected address but with a different
// prefix.
add_ip_addr_subnet(&mut ctx, device, manual_addr_sub.into_witness()).unwrap();
assert_eq!(
NdpContext::<EthernetLinkDevice>::get_ipv6_addr_entries(&ctx, device.id().into())
.count(),
1
);
let entry =
NdpContext::<EthernetLinkDevice>::get_ipv6_addr_entries(&ctx, device.id().into())
.last()
.unwrap();
assert_eq!(*entry.addr_sub(), manual_addr_sub);
assert_eq!(entry.state(), AddressState::Assigned);
assert_eq!(entry.config_type(), AddrConfigType::Manual);
assert_eq!(ctx.dispatcher().timer_events().count(), 0);
// Should not get a new IP.
let mut icmpv6_packet_buf = slaac_packet_buf(
src_ip,
config.local_ip.get(),
prefix,
prefix_length,
false,
true,
10000,
9000,
);
let icmpv6_packet = icmpv6_packet_buf
.parse_with::<_, Icmpv6Packet<_>>(IcmpParseArgs::new(src_ip, config.local_ip))
.unwrap();
ctx.receive_ndp_packet(
device,
src_ip.try_into().unwrap(),
config.local_ip,
icmpv6_packet.unwrap_ndp(),
);
assert_eq!(
NdpContext::<EthernetLinkDevice>::get_ipv6_addr_entries(&ctx, device.id().into())
.count(),
1
);
let entry =
NdpContext::<EthernetLinkDevice>::get_ipv6_addr_entries(&ctx, device.id().into())
.last()
.unwrap();
// Address state and configuration type should not have changed.
assert_eq!(*entry.addr_sub(), manual_addr_sub);
assert_eq!(entry.state(), AddressState::Assigned);
assert_eq!(entry.config_type(), AddrConfigType::Manual);
// No new timers were added.
assert_eq!(ctx.dispatcher().timer_events().count(), 0);
} | rust_cleaned_test_functions.jsonl/82829 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1602
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
12848,
643,
4260,
580,
8378,
75428,
6744,
16059,
21242,
368,
341,
286,
442,
16797,
96710,
1265,
537,
32216,
894,
20083,
3694,
14230,
429,
1231,
8945,
286,
442,
2621,
702,
264,
2155,
9252,
382,
286... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_read_reports_downsampled() -> Result<(), Error> {
// The voltages and device config are all completely made up for mathematical convenience.
// the downsampling intervals.
fn get_voltages(micros: u64) -> (f32, f32) {
let seconds = micros as f32 / 1e6;
let v_shunt = seconds;
let v_bus = seconds.powi(2);
(v_shunt, v_bus)
}
let device_config = fake_device::DeviceConfiguration {
shunt_resistance: 2.0,
v_shunt_scale: 1e-4,
v_bus_scale: 1e-4,
};
let test_duration = Duration::from_secs(1);
let raw_data_interval = Duration::from_millis(1);
let reporting_interval = Duration::from_millis(100);
// Interval-average formulas follow from the definition
// Input times are in seconds.
let v_shunt_integral = |t1: f32, t2: f32| (t2.powi(2) - t1.powi(2)) / (2.0 * (t2 - t1));
let v_bus_integral = |t1: f32, t2: f32| (t2.powi(3) - t1.powi(3)) / (3.0 * (t2 - t1));
let power_integral = |t1: f32, t2: f32| {
(t2.powi(4) - t1.powi(4)) / (4.0 * device_config.shunt_resistance * (t2 - t1))
};
let report_queue =
make_report_queue(get_voltages, &device_config, test_duration, raw_data_interval);
let coordinator = fake_device::CoordinatorBuilder::new(device_config.clone())
.with_report_queue(report_queue.clone())
.build();
let interface = fake_device::FakeZedmonInterface::new(coordinator);
let zedmon = ZedmonClient::new(interface).expect("Error building ZedmonClient");
let output = run_zedmon_reporting(&zedmon, test_duration, Some(reporting_interval))?;
let mut reader =
csv::ReaderBuilder::new().has_headers(false).from_reader(output.as_slice());
// Both v_shunt and v_bus have a max value of 1. Since
// the maximum error in a raw power measurement should be roughly
let power_tolerance = (device_config.v_shunt_scale + device_config.v_bus_scale)
/ device_config.shunt_resistance;
let mut num_records = 0;
let mut prev_timestamp = 0;
for result in reader.deserialize::<ZedmonRecord>() {
let record = result?;
num_records = num_records + 1;
let t = record.timestamp_micros as f32 / 1e6;
let t_prev = prev_timestamp as f32 / 1e6;
assert_near!(
record.shunt_voltage,
v_shunt_integral(t_prev, t),
device_config.v_shunt_scale
);
assert_near!(record.bus_voltage, v_bus_integral(t_prev, t), device_config.v_bus_scale);
assert_near!(record.power, power_integral(t_prev, t), power_tolerance);
prev_timestamp = record.timestamp_micros;
}
assert_eq!(num_records, test_duration.as_millis() / reporting_interval.as_millis());
Ok(())
} | rust_cleaned_test_functions.jsonl/90582 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1457
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6443,
64423,
13998,
13611,
67,
368,
1464,
5714,
68843,
4600,
29,
341,
286,
442,
576,
16393,
1134,
323,
3671,
2193,
525,
678,
6587,
1865,
705,
369,
35972,
19132,
624,
1789,
286,
442,
279,
39191,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_mq_set_nonblocking() {
use nix::mqueue::{mq_getattr, mq_set_nonblock, mq_remove_nonblock};
const MSG_SIZE: mq_attr_member_t = 32;
let initial_attr = MqAttr::new(0, 10, MSG_SIZE, 0);
let mq_name = &CString::new(b"/attr_test_get_attr".as_ref()).unwrap();
let oflag = MQ_OFlag::O_CREAT | MQ_OFlag::O_WRONLY;
let mode = Mode::S_IWUSR | Mode::S_IRUSR | Mode::S_IRGRP | Mode::S_IROTH;
let r = mq_open(mq_name, oflag, mode, Some(&initial_attr));
if let Err(Errno::ENOSYS) = r {
println!("message queues not supported or module not loaded?");
return;
};
let mqd = r.unwrap();
mq_set_nonblock(mqd).unwrap();
let new_attr = mq_getattr(mqd);
let o_nonblock_bits = MQ_OFlag::O_NONBLOCK.bits() as mq_attr_member_t;
assert_eq!(new_attr.unwrap().flags() & o_nonblock_bits, o_nonblock_bits);
mq_remove_nonblock(mqd).unwrap();
let new_attr = mq_getattr(mqd);
assert_eq!(new_attr.unwrap().flags() & o_nonblock_bits, 0);
mq_close(mqd).unwrap();
} | rust_cleaned_test_functions.jsonl/28039 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 498
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
717,
80,
2602,
21637,
70356,
368,
341,
262,
990,
308,
941,
486,
76,
4584,
22964,
27674,
3062,
2991,
11,
72298,
2602,
21637,
4574,
11,
72298,
18193,
21637,
4574,
2440,
262,
733,
23317,
4098,
25,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_truncate_with_ellipsis_on_naughty_strings() {
let naughty_strings = vec![
"ÅÍÎÏ˝ÓÔÒÚÆ☃",
"Œ„´‰ˇÁ¨ˆØ∏”’",
"`⁄€‹›fifl‡°·‚—±",
"田中さんにあげて下さい",
"和製漢語",
"👨👩👦 👨👩👧👦 👨👨👦 👩👩👧 👨👦 👨👧👦 👩👦 👩👧👦",
];
for string in naughty_strings {
let grapheme_count = UnicodeSegmentation::graphemes(string, true).count();
for i in 0..(grapheme_count + 3) {
let _ = truncate_with_ellipsis_to_length(string, i, None);
}
}
} | rust_cleaned_test_functions.jsonl/81840 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 459
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
3547,
26900,
6615,
62,
71922,
4470,
58631,
35516,
33500,
368,
341,
1789,
286,
1077,
52943,
33500,
284,
7486,
90515,
310,
330,
144044,
52220,
71807,
144865,
145052,
39062,
131371,
171,
96,
123,
144086,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 3 |
#[test]
fn test_literal() {
assert_eq!(
"-3.14e-4".parse::<LiteralValue>().unwrap(),
LiteralValue::Float(-0.000_314)
);
assert_eq!(parse!(literal_value, "0"), LiteralValue::Integer(0));
assert_eq!(parse!(literal_value, "124"), LiteralValue::Integer(124));
assert_eq!(
parse!(literal_value, r#""""#),
LiteralValue::String(String::new())
);
assert_eq!(
parse!(literal_value, r#"''"#),
LiteralValue::String(String::new())
);
assert_eq!(
parse!(literal_value, r#""hello""#),
LiteralValue::String(String::from("hello"))
);
assert_eq!(
parse!(literal_value, r#"'hello'"#),
LiteralValue::String(String::from("hello"))
);
} | rust_cleaned_test_functions.jsonl/130540 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 452
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
34100,
368,
341,
286,
2060,
10714,
33673,
310,
6523,
18,
13,
16,
19,
68,
12,
19,
3263,
6400,
27638,
17350,
1130,
10483,
15454,
3148,
310,
49674,
1130,
486,
5442,
4080,
15,
13,
15,
15,
15,
62,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_range_filter() -> Result<()> {
let schema = DataSchemaRefExt::create(vec![
DataField::new("a", i64::to_data_type()),
DataField::new("b", i32::to_data_type()),
DataField::new("c", Vu8::to_data_type()),
]);
let mut stats: BlockStatistics = HashMap::new();
stats.insert(0u32, ColumnStatistics {
min: DataValue::Int64(1),
max: DataValue::Int64(20),
null_count: 1,
in_memory_size: 0,
});
stats.insert(1u32, ColumnStatistics {
min: DataValue::Int64(3),
max: DataValue::Int64(10),
null_count: 0,
in_memory_size: 0,
});
stats.insert(2u32, ColumnStatistics {
min: DataValue::String("abc".as_bytes().to_vec()),
max: DataValue::String("bcd".as_bytes().to_vec()),
null_count: 0,
in_memory_size: 0,
});
struct Test {
name: &'static str,
expr: Expression,
expect: bool,
error: &'static str,
}
let tests: Vec<Test> = vec![
Test {
name: "a < 1 and b > 3",
expr: col("a").lt(lit(1)).and(col("b").gt(lit(3i32))),
expect: false,
error: "",
},
Test {
name: "1 > -a or 3 >= b",
expr: lit(1).gt(neg(col("a"))).or(lit(3i32).gt_eq(col("b"))),
expect: true,
error: "",
},
Test {
name: "a = 1 and b != 3",
expr: col("a").eq(lit(1)).and(col("b").not_eq(lit(3))),
expect: true,
error: "",
},
Test {
name: "a is null",
expr: Expression::create_scalar_function("isNull", vec![col("a")]),
expect: true,
error: "",
},
Test {
name: "a is not null",
expr: Expression::create_scalar_function("isNotNull", vec![col("a")]),
expect: true,
error: "",
},
Test {
name: "null",
expr: Expression::create_literal(DataValue::Null),
expect: false,
error: "",
},
Test {
name: "b >= 0 and c like '%sys%'",
expr: col("b")
.gt_eq(lit(0))
.and(Expression::create_binary_expression("like", vec![
col("c"),
lit("%sys%".as_bytes()),
])),
expect: true,
error: "",
},
Test {
name: "c like 'ab_'",
expr: Expression::create_binary_expression("like", vec![
col("c"),
lit("ab_".as_bytes()),
]),
expect: true,
error: "",
},
Test {
name: "c like 'bcdf'",
expr: Expression::create_binary_expression("like", vec![
col("c"),
lit("bcdf".as_bytes()),
]),
expect: false,
error: "",
},
Test {
name: "c not like 'ac%'",
expr: Expression::create_binary_expression("not like", vec![
col("c"),
lit("ac%".as_bytes()),
]),
expect: true,
error: "",
},
Test {
name: "a + b > 30",
expr: add(col("a"), col("b")).gt(lit(30i32)),
expect: false,
error: "",
},
Test {
name: "a + b < 10",
expr: add(col("a"), col("b")).lt(lit(10i32)),
expect: true,
error: "",
},
Test {
name: "a - b <= -10",
expr: sub(col("a"), col("b")).lt_eq(lit(-10i32)),
expect: true,
error:
"Code: 1067, displayText = Function '-' is not monotonic in the variables range.",
},
Test {
name: "a < b",
expr: col("a").lt(col("b")),
expect: true,
error: "",
},
Test {
name: "a + 9 < b",
expr: add(col("a"), lit(9)).lt(col("b")),
expect: false,
error: "",
},
];
for test in tests {
let prune = RangeFilter::try_create(&test.expr, schema.clone())?;
match prune.eval(&stats) {
Ok(actual) => assert_eq!(test.expect, actual, "{:#?}", test.name),
Err(e) => assert_eq!(test.error, e.to_string(), "{}", test.name),
}
}
Ok(())
} | rust_cleaned_test_functions.jsonl/115767 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 2567
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
9698,
8727,
368,
1464,
5714,
71698,
341,
262,
1077,
10802,
284,
2885,
8632,
3945,
6756,
486,
3182,
25592,
90515,
286,
2885,
1877,
486,
931,
445,
64,
497,
600,
21,
19,
486,
983,
1769,
1819,
14702... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
#[test]
fn test_game_console() {
let input: Vec<String> = "nop +0
acc +1
jmp +4
acc +3
jmp -3
acc -99
acc +1
jmp -4
acc +6"
.split('\n')
.map(|x| x.trim().to_string())
.collect();
let (result, infinite) = detect_loop(&input);
assert_eq!(result, 5);
assert!(infinite);
assert_eq!(try_repair(&input), 8);
} | rust_cleaned_test_functions.jsonl/88218 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 270
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
18547,
51724,
368,
341,
286,
1077,
1946,
25,
11312,
3464,
29,
284,
330,
62813,
488,
15,
198,
286,
1029,
488,
16,
198,
286,
90369,
488,
19,
198,
286,
1029,
488,
18,
198,
286,
90369,
481,
18,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_drop_count() {
let counter = Cell::new(0);
{
let arena = TypedArena::default();
for _ in 0..100 {
arena.alloc(DropCounter { counter: &counter });
}
assert_eq!(counter.get(), 0);
}
assert_eq!(counter.get(), 100);
} | rust_cleaned_test_functions.jsonl/12325 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 133
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
29584,
3180,
368,
341,
262,
1077,
5546,
284,
13972,
486,
931,
7,
15,
317,
262,
341,
414,
1077,
24902,
284,
50554,
93937,
486,
2258,
543,
414,
369,
716,
304,
220,
15,
496,
16,
15,
15,
341,
28... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_query_string() {
let base = test_base();
let id = test_id();
let schema = test_schema();
let logger = test_logger();
let fork = SubgraphFork::new(base, id, schema, logger).unwrap();
let query = Query {
query: fork.query_string("Gravatar", &test_fields()).unwrap(),
variables: Variables {
id: "0x00".to_string(),
},
};
assert_eq!(
query,
Query {
query: r#"query Query ($id: String) {
gravatar(id: $id, subgraphError: allow) {
id owner displayName imageUrl
}
}"#
.to_string(),
variables: Variables {
id: "0x00".to_string()
},
}
);
} | rust_cleaned_test_functions.jsonl/8654 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 450
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5738,
3904,
368,
341,
286,
1077,
2331,
284,
1273,
7651,
543,
286,
1077,
877,
284,
1273,
842,
543,
286,
1077,
10802,
284,
1273,
25371,
543,
286,
1077,
5925,
284,
1273,
27413,
1428,
286,
1077,
224... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_analyze_call_multiple_object_arguments() {
let b = ast::BaseNode::default();
let pkg = ast::Package {
base: b.clone(),
path: "path".to_string(),
package: "main".to_string(),
files: vec![ast::File {
base: b.clone(),
name: "foo.flux".to_string(),
package: None,
imports: Vec::new(),
body: vec![ast::Statement::Expr(ast::ExprStmt {
base: b.clone(),
expression: ast::Expression::Call(Box::new(ast::CallExpr {
base: b.clone(),
callee: ast::Expression::Identifier(ast::Identifier {
base: b.clone(),
name: "f".to_string(),
}),
arguments: vec![
ast::Expression::Object(Box::new(ast::ObjectExpr {
base: b.clone(),
with: None,
properties: vec![ast::Property {
base: b.clone(),
key: ast::PropertyKey::Identifier(ast::Identifier {
base: b.clone(),
name: "a".to_string(),
}),
value: Some(ast::Expression::Integer(ast::IntegerLit {
base: b.clone(),
value: 0,
})),
}],
})),
ast::Expression::Object(Box::new(ast::ObjectExpr {
base: b.clone(),
with: None,
properties: vec![ast::Property {
base: b.clone(),
key: ast::PropertyKey::Identifier(ast::Identifier {
base: b.clone(),
name: "b".to_string(),
}),
value: Some(ast::Expression::Integer(ast::IntegerLit {
base: b.clone(),
value: 1,
})),
}],
})),
],
})),
})],
}],
};
let got = test_analyze(pkg).err().unwrap().to_string();
assert_eq!(
"arguments are more than one object expression".to_string(),
got
);
} | rust_cleaned_test_functions.jsonl/61565 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1973
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
12008,
55856,
13429,
45233,
5314,
43433,
368,
341,
286,
1077,
293,
284,
11763,
486,
3978,
1955,
486,
2258,
543,
286,
1077,
24793,
284,
11763,
486,
13100,
341,
310,
2331,
25,
293,
15997,
3148,
310,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_extract_with_cm() {
let cms = create_test_cm_map(vec![("meta/foo.cm".to_string(), vec![])]);
let pkg = create_test_package_with_cms(String::from("fuchsia-pkg://fuchsia.com/foo"), cms);
let served = vec![pkg];
let services = HashMap::new();
let package_getter: Box<dyn PackageGetter> = Box::new(MockPackageGetter::new());
let response = PackageDataCollector::extract(&package_getter, served, services).unwrap();
assert_eq!(1, response.components.len());
assert_eq!(response.components["fuchsia-pkg://fuchsia.com/foo#meta/foo.cm"].version, 2);
assert_eq!(1, response.manifests.len());
assert_eq!(0, response.routes.len());
assert_eq!(1, response.packages.len());
assert_eq!(None, response.zbi);
} | rust_cleaned_test_functions.jsonl/19462 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 359
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
39123,
6615,
43619,
368,
341,
286,
1077,
26270,
284,
1855,
4452,
43619,
5376,
25592,
20703,
445,
5490,
60555,
53046,
3263,
983,
3904,
1507,
7486,
0,
15793,
2558,
286,
1077,
24793,
284,
1855,
4452,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_from_iterator() {
let s = "ศไทย中华Việt Nam".to_string();
let t = "ศไทย中华";
let u = "Việt Nam";
let a: String = s.chars().collect();
assert_eq!(s, a);
let mut b = t.to_string();
b.extend(u.chars());
assert_eq!(s, b);
let c: String = vec![t, u].into_iter().collect();
assert_eq!(s, c);
let mut d = t.to_string();
d.extend(vec![u]);
assert_eq!(s, d);
} | rust_cleaned_test_functions.jsonl/3181 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 232
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
5673,
13491,
368,
341,
262,
1077,
274,
284,
330,
123863,
125451,
100849,
35544,
124382,
29974,
3263,
983,
3904,
543,
262,
1077,
259,
284,
330,
123863,
125451,
100849,
876,
262,
1077,
575,
284,
330,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_fixed_retry_strategy_error() {
let mut collection = vec![1, 2, 3, 4, 5].into_iter();
let result = retry(fixed_retry_strategy(0, 3), || match collection.next() {
Some(n) if n == 5 => Ok(n),
Some(_) => Err("not 5"),
None => Err("not 5"),
});
assert_eq!(result, Err("not 5"));
} | rust_cleaned_test_functions.jsonl/46313 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 187
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
37839,
62745,
49308,
4096,
368,
341,
286,
1077,
5206,
4426,
284,
7486,
20703,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
11,
220,
20,
936,
18122,
11723,
543,
286,
1077,
1102,
284,
22683,
955,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 4 |
#[test]
fn test_document() {
let b = Document::new()
.add_paragraph(Paragraph::new().add_run(Run::new().add_text("Hello")))
.build();
assert_eq!(
str::from_utf8(&b).unwrap(),
r#"<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:document xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:w15="http://schemas.microsoft.com/office/word/2012/wordml" mc:Ignorable="w14 wp14">
<w:body><w:p w14:paraId="12345678"><w:pPr><w:rPr /></w:pPr><w:r><w:rPr /><w:t xml:space="preserve">Hello</w:t></w:r></w:p><w:sectPr><w:pgSz w:w="11906" w:h="16838" /><w:pgMar w:top="1985" w:right="1701" w:bottom="1701" w:left="1701" w:header="851" w:footer="992" w:gutter="0" /><w:cols w:space="425" /><w:docGrid w:type="lines" w:linePitch="360" /></w:sectPr></w:body>
</w:document>"#
);
} | rust_cleaned_test_functions.jsonl/86307 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 677
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
26231,
368,
341,
286,
1077,
293,
284,
11789,
486,
931,
741,
310,
659,
718,
96713,
7,
42165,
486,
931,
1005,
718,
14007,
2785,
359,
486,
931,
1005,
718,
4326,
445,
9707,
29836,
310,
659,
5834,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_lookup_google() {
use super::testing::lookup_test;
let io_loop = Runtime::new().expect("failed to create tokio runtime");
let handle = io_loop.handle().clone();
lookup_test::<Runtime, TokioRuntime>(ResolverConfig::google(), io_loop, handle)
} | rust_cleaned_test_functions.jsonl/121528 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 121
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
27464,
47155,
368,
341,
286,
990,
2256,
486,
8840,
486,
21020,
4452,
280,
286,
1077,
6399,
17198,
284,
10954,
486,
931,
1005,
17119,
445,
16091,
311,
1855,
9628,
815,
15592,
797,
286,
1077,
3705,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_withdraw_stake() {
let recipient_address = solana_sdk::pubkey::new_rand();
let authority_address = solana_sdk::pubkey::new_rand();
let custodian_address = solana_sdk::pubkey::new_rand();
let stake_address = solana_sdk::pubkey::new_rand();
let minimum_delegation = crate::get_minimum_delegation(&FeatureSet::all_enabled());
let stake_lamports = minimum_delegation;
let stake_account = AccountSharedData::new_data_with_space(
stake_lamports,
&StakeState::Uninitialized,
StakeState::size_of(),
&id(),
)
.unwrap();
let vote_address = solana_sdk::pubkey::new_rand();
let mut vote_account =
vote_state::create_account(&vote_address, &solana_sdk::pubkey::new_rand(), 0, 100);
vote_account
.set_state(&VoteStateVersions::new_current(VoteState::default()))
.unwrap();
let mut transaction_accounts = vec![
(stake_address, stake_account),
(vote_address, vote_account),
(recipient_address, AccountSharedData::default()),
(
authority_address,
AccountSharedData::new(42, 0, &system_program::id()),
),
(custodian_address, AccountSharedData::default()),
(
sysvar::clock::id(),
account::create_account_shared_data_for_test(&Clock::default()),
),
(
sysvar::rent::id(),
account::create_account_shared_data_for_test(&Rent::free()),
),
(
sysvar::stake_history::id(),
account::create_account_shared_data_for_test(&StakeHistory::default()),
),
(
stake_config::id(),
config::create_account(0, &stake_config::Config::default()),
),
];
let mut instruction_accounts = vec![
AccountMeta {
pubkey: stake_address,
is_signer: false,
is_writable: false,
},
AccountMeta {
pubkey: recipient_address,
is_signer: false,
is_writable: false,
},
AccountMeta {
pubkey: sysvar::clock::id(),
is_signer: false,
is_writable: false,
},
AccountMeta {
pubkey: sysvar::stake_history::id(),
is_signer: false,
is_writable: false,
},
AccountMeta {
pubkey: stake_address,
is_signer: true,
is_writable: false,
},
];
instruction_accounts[4].is_signer = false;
process_instruction(
&serialize(&StakeInstruction::Withdraw(stake_lamports)).unwrap(),
transaction_accounts.clone(),
instruction_accounts.clone(),
Err(InstructionError::MissingRequiredSignature),
);
instruction_accounts[4].is_signer = true;
let accounts = process_instruction(
&serialize(&StakeInstruction::Withdraw(stake_lamports)).unwrap(),
transaction_accounts.clone(),
instruction_accounts.clone(),
Ok(()),
);
assert_eq!(accounts[0].lamports(), 0);
assert_eq!(from(&accounts[0]).unwrap(), StakeState::Uninitialized);
// initialize stake
let lockup = Lockup {
unix_timestamp: 0,
epoch: 0,
custodian: custodian_address,
};
let accounts = process_instruction(
&serialize(&StakeInstruction::Initialize(
Authorized::auto(&stake_address),
lockup,
))
.unwrap(),
transaction_accounts.clone(),
vec![
AccountMeta {
pubkey: stake_address,
is_signer: true,
is_writable: false,
},
AccountMeta {
pubkey: sysvar::rent::id(),
is_signer: false,
is_writable: false,
},
],
Ok(()),
);
transaction_accounts[0] = (stake_address, accounts[0].clone());
process_instruction(
&serialize(&StakeInstruction::Withdraw(stake_lamports + 1)).unwrap(),
transaction_accounts.clone(),
instruction_accounts.clone(),
Err(InstructionError::InsufficientFunds),
);
let accounts = process_instruction(
&serialize(&StakeInstruction::DelegateStake).unwrap(),
transaction_accounts.clone(),
vec![
AccountMeta {
pubkey: stake_address,
is_signer: true,
is_writable: false,
},
AccountMeta {
pubkey: vote_address,
is_signer: false,
is_writable: false,
},
AccountMeta {
pubkey: sysvar::clock::id(),
is_signer: false,
is_writable: false,
},
AccountMeta {
pubkey: sysvar::stake_history::id(),
is_signer: false,
is_writable: false,
},
AccountMeta {
pubkey: stake_config::id(),
is_signer: false,
is_writable: false,
},
],
Ok(()),
);
transaction_accounts[0] = (stake_address, accounts[0].clone());
// simulate rewards
transaction_accounts[0].1.checked_add_lamports(10).unwrap();
// withdrawal before deactivate works for rewards amount
process_instruction(
&serialize(&StakeInstruction::Withdraw(10)).unwrap(),
transaction_accounts.clone(),
instruction_accounts.clone(),
Ok(()),
);
// withdrawal of rewards fails if not in excess of stake
process_instruction(
&serialize(&StakeInstruction::Withdraw(11)).unwrap(),
transaction_accounts.clone(),
instruction_accounts.clone(),
Err(InstructionError::InsufficientFunds),
);
// deactivate the stake before withdrawal
let accounts = process_instruction(
&serialize(&StakeInstruction::Deactivate).unwrap(),
transaction_accounts.clone(),
vec![
AccountMeta {
pubkey: stake_address,
is_signer: true,
is_writable: false,
},
AccountMeta {
pubkey: sysvar::clock::id(),
is_signer: false,
is_writable: false,
},
],
Ok(()),
);
transaction_accounts[0] = (stake_address, accounts[0].clone());
// simulate time passing
let clock = Clock {
epoch: 100,
..Clock::default()
};
transaction_accounts[5] = (
sysvar::clock::id(),
account::create_account_shared_data_for_test(&clock),
);
// Try to withdraw more than what's available
process_instruction(
&serialize(&StakeInstruction::Withdraw(stake_lamports + 11)).unwrap(),
transaction_accounts.clone(),
instruction_accounts.clone(),
Err(InstructionError::InsufficientFunds),
);
// Try to withdraw all lamports
let accounts = process_instruction(
&serialize(&StakeInstruction::Withdraw(stake_lamports + 10)).unwrap(),
transaction_accounts.clone(),
instruction_accounts.clone(),
Ok(()),
);
assert_eq!(accounts[0].lamports(), 0);
assert_eq!(from(&accounts[0]).unwrap(), StakeState::Uninitialized);
// overflow
let rent = Rent::default();
let rent_exempt_reserve = rent.minimum_balance(StakeState::size_of());
let stake_account = AccountSharedData::new_data_with_space(
1_000_000_000,
&StakeState::Initialized(Meta {
rent_exempt_reserve,
authorized: Authorized {
staker: authority_address,
withdrawer: authority_address,
},
lockup: Lockup::default(),
}),
StakeState::size_of(),
&id(),
)
.unwrap();
transaction_accounts[0] = (stake_address, stake_account.clone());
transaction_accounts[2] = (recipient_address, stake_account);
instruction_accounts[4].pubkey = authority_address;
process_instruction(
&serialize(&StakeInstruction::Withdraw(u64::MAX - 10)).unwrap(),
transaction_accounts.clone(),
instruction_accounts.clone(),
Err(InstructionError::InsufficientFunds),
);
let stake_account = AccountSharedData::new_data_with_space(
stake_lamports,
&StakeState::RewardsPool,
StakeState::size_of(),
&id(),
)
.unwrap();
transaction_accounts[0] = (stake_address, stake_account);
process_instruction(
&serialize(&StakeInstruction::Withdraw(stake_lamports)).unwrap(),
transaction_accounts,
instruction_accounts,
Err(InstructionError::InvalidAccountData),
);
} | rust_cleaned_test_functions.jsonl/31642 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 5206
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
6615,
7633,
1261,
726,
368,
341,
286,
1077,
21713,
6744,
284,
2048,
3362,
61783,
486,
9585,
792,
486,
931,
33864,
543,
286,
1077,
11198,
6744,
284,
2048,
3362,
61783,
486,
9585,
792,
486,
931,
3... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_day19_part2_simple2() {
// only first 8 should match
assert_eq!(
8,
part2(&parse(
"\
0: 3 4 4 4
1: \"a\"
2: \"b\"
3: 1 | 1 1
4: 2 | 2 2
abbb
abbbb
abbbbb
abbbbbb
aabbb
aabbbb
aabbbbb
aabbbbbb
bbb
aaabbb
aabb
abbbbbbb
aabbbbbbb
"
))
);
} | rust_cleaned_test_functions.jsonl/84993 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 215
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
16763,
16,
24,
10495,
17,
30015,
17,
368,
341,
286,
442,
1172,
1156,
220,
23,
1265,
2432,
198,
286,
2060,
10714,
33673,
310,
220,
23,
345,
310,
949,
17,
2099,
6400,
1006,
394,
93317,
15,
25,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_conn_send_sync() {
fn is_send<T: Send>(_: &T) {}
fn is_sync<T: Sync>(_: &T) {}
let c = SyncConnection::new_session().unwrap();
is_send(&c);
is_sync(&c);
let c = Connection::new_session().unwrap();
is_send(&c);
} | rust_cleaned_test_functions.jsonl/20029 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 124
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
17241,
13565,
23008,
368,
341,
262,
5168,
374,
13565,
3125,
25,
11000,
2235,
23211,
609,
51,
8,
5613,
262,
5168,
374,
23008,
3125,
25,
28937,
2235,
23211,
609,
51,
8,
10086,
262,
1077,
272,
284,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_external() {
common::setup();
struct Foo {
a: &'static str,
}
impl Foo {
fn new(a: Option<&'static str>) -> Self {
Self {
a: a.unwrap_or("a"),
}
}
#[allow(dead_code)]
fn b(&self) -> impl Iterator<Item = &'static str> + Clone {
vec!["b"].into_iter()
}
fn c() -> &'static str {
"c"
}
fn d<X>(&self, x: X) -> X {
x
}
fn e(&self) -> Vec<u32> {
vec![1, 2, 3]
}
#[allow(dead_code)]
fn f(&self) -> impl Iterator<Item = Vec<u32>> + Clone {
vec![vec![1, 2, 3], vec![4, 5, 6], vec![7]].into_iter()
}
fn g(&self) -> std::collections::HashMap<&'static str, &'static str> {
hashmap!("hello" => "world")
}
fn h(&self) -> bool {
true
}
}
fn capital_foo() -> Foo {
Foo::new(Some("A"))
}
let mut test = OsoTest::new();
let foo_class = oso::ClassBuilder::with_constructor(capital_foo)
.name("Foo")
.add_attribute_getter("a", |receiver: &Foo| receiver.a)
.add_class_method("c", Foo::c)
.add_method::<_, _, u32>("d", Foo::d)
.add_method("e", Foo::e)
.add_method("g", Foo::g)
.add_method("h", Foo::h)
.build();
test.oso.register_class(foo_class).unwrap();
test.qvar_one("new Foo().a = x", "x", "A".to_string());
test.query_err("new Foo().a() = x");
test.qvar_one("Foo.c() = x", "x", "c".to_string());
test.qvar_one("new Foo().d(1) = x", "x", 1);
test.query_err("new Foo().d(\"1\") = x");
test.qvar_one("new Foo() = f and f.a = x", "x", "A".to_string());
test.qvar_one("new Foo().e() = x", "x", vec![1, 2, 3]);
// test.qvar_one(
test.qvar_one("new Foo().g().hello = x", "x", "world".to_string());
test.qvar_one("new Foo().h() = x", "x", true);
} | rust_cleaned_test_functions.jsonl/30387 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1113
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
47432,
368,
341,
262,
4185,
486,
15188,
1428,
262,
2036,
33428,
341,
286,
264,
25,
30136,
1978,
607,
345,
262,
555,
262,
11605,
33428,
341,
286,
5168,
501,
2877,
25,
6959,
52244,
6,
1978,
607,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_ipv4_reassembly_not_needed() {
let mut ctx = DummyCtx::<Ipv4>::default();
let mut cache = IpPacketFragmentCache::<Ipv4>::default();
// Test that we don't attempt reassembly if the packet is not
// fragmented.
let builder = get_ipv4_builder();
let body = [1, 2, 3, 4, 5];
let mut buffer =
Buf::new(body.to_vec(), ..).encapsulate(builder).serialize_vec_outer().unwrap();
let packet = buffer.parse::<Ipv4Packet<_>>().unwrap();
assert_matches::assert_matches!(
cache.process_fragment::<_, &[u8]>(&mut ctx, packet),
FragmentProcessingState::NotNeeded(unfragmented) if unfragmented.body() == body
);
} | rust_cleaned_test_functions.jsonl/52570 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 343
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
49378,
19,
1288,
14993,
7913,
57426,
368,
341,
286,
1077,
5206,
5635,
284,
50567,
23684,
27638,
80656,
19,
6831,
2258,
543,
286,
1077,
5206,
6500,
284,
35033,
16679,
9488,
8233,
27638,
80656,
19,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_circular_data() -> TestResult {
let p = polar();
qeval(&p, "x = [x] and x in x");
qeval(&p, "y = {y:y} and [\"y\", y] in y");
qruntime!("x = [x, y] and y = [y, x] and x = y", StackOverflow { .. });
Ok(())
} | rust_cleaned_test_functions.jsonl/68140 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 122
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
666,
21472,
1769,
368,
1464,
3393,
2077,
341,
262,
1077,
281,
284,
24660,
543,
262,
2804,
14170,
2099,
79,
11,
330,
87,
284,
508,
87,
60,
323,
856,
304,
856,
797,
262,
2804,
14170,
2099,
79,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_add_time() {
let now = Instant::now();
let mut rate_limiter = UpdateCheckRateLimiter::new();
for i in 0..100 {
rate_limiter.add_time(now + Duration::from_secs(i));
}
assert_eq!(rate_limiter.recent_update_check_times.len(), MAX_CHECKS_IN_LONG_PERIOD);
// This asserts that the recent update check times is in correct order.
UpdateCheckRateLimiter::with_recent_update_check_times(
rate_limiter.recent_update_check_times,
);
} | rust_cleaned_test_functions.jsonl/33323 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 240
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
2891,
3009,
368,
341,
286,
1077,
1431,
284,
18058,
486,
3328,
543,
286,
1077,
5206,
4379,
907,
17700,
284,
5549,
3973,
11564,
43,
17700,
486,
931,
543,
286,
369,
600,
304,
220,
15,
496,
16,
15... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_serialize_with_fixed_len_option_returns_correct_bytes() {
let opt = ConfigOption {
code: OptionCode::End,
value: vec![],
};
let mut bytes = Vec::new();
opt.serialize_to(&mut bytes);
assert_eq!(bytes.len(), 1);
assert_eq!(bytes[0], 255);
} | rust_cleaned_test_functions.jsonl/93675 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 170
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
88686,
6615,
37839,
6043,
9672,
58900,
31550,
12524,
368,
341,
286,
1077,
3387,
284,
5532,
5341,
341,
310,
2038,
25,
6959,
2078,
486,
3727,
345,
310,
897,
25,
7486,
20703,
1259,
286,
2605,
286,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_2() {
let instrs = parse(&vec![
"mask = 000000000000000000000000000000X1001X",
"mem[42] = 100",
"mask = 00000000000000000000000000000000X0XX",
"mem[26] = 1",
]);
assert_eq!(208, part_2(&instrs));
} | rust_cleaned_test_functions.jsonl/48507 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 157
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
62,
17,
368,
341,
286,
1077,
9491,
82,
284,
4715,
2099,
4083,
90515,
310,
330,
11258,
284,
220,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
15,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_cycle_phase_settings() {
let set: BTreeSet<MemContent> = [0, 1, 2, 3, 4].iter().cloned().collect();
let permutations = permute(&set);
assert_eq!(5 * 4 * 3 * 2 * 1, permutations.len());
} | rust_cleaned_test_functions.jsonl/66873 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 108
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
39079,
37593,
10853,
368,
341,
286,
1077,
738,
25,
425,
6533,
1649,
27,
18816,
2762,
29,
284,
508,
15,
11,
220,
16,
11,
220,
17,
11,
220,
18,
11,
220,
19,
936,
2015,
1005,
564,
19684,
1005,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_highest_qc() {
let mut inserter = TreeInserter::default();
let block_store = inserter.block_store();
// build a tree of the following form
// genesis <- a1 <- a2 <- a3
let genesis = block_store.root();
let a1 = inserter.insert_block_with_qc(certificate_for_genesis(), &genesis, 1);
assert_eq!(block_store.highest_certified_block(), genesis);
let a2 = inserter.insert_block(&a1, 2, None);
assert_eq!(block_store.highest_certified_block(), a1);
let _a3 = inserter.insert_block(&a2, 3, None);
assert_eq!(block_store.highest_certified_block(), a2);
} | rust_cleaned_test_functions.jsonl/50989 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 246
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1523,
7504,
8976,
66,
368,
341,
262,
1077,
5206,
47325,
465,
284,
8942,
641,
90727,
486,
2258,
543,
262,
1077,
2504,
14809,
284,
47325,
465,
15697,
14809,
1428,
262,
442,
1936,
264,
4916,
315,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_account_commitment_not_fulfilled() {
let GenesisConfigInfo {
genesis_config,
mint_keypair: alice,
..
} = create_genesis_config(10_000);
let bank = Bank::new(&genesis_config);
let blockhash = bank.last_blockhash();
let bank_forks = Arc::new(RwLock::new(BankForks::new(bank)));
let bob = Keypair::new();
let mut rpc = RpcSolPubSubImpl::default_with_bank_forks(bank_forks.clone());
let exit = Arc::new(AtomicBool::new(false));
let subscriptions = RpcSubscriptions::new(
&exit,
bank_forks.clone(),
Arc::new(RwLock::new(BlockCommitmentCache::new_for_tests())),
OptimisticallyConfirmedBank::locked_from_bank_forks_root(&bank_forks),
);
rpc.subscriptions = Arc::new(subscriptions);
let session = create_session();
let (subscriber, _id_receiver, receiver) = Subscriber::new_test("accountNotification");
rpc.account_subscribe(
session,
subscriber,
bob.pubkey().to_string(),
Some(RpcAccountInfoConfig {
commitment: Some(CommitmentConfig::finalized()),
encoding: None,
data_slice: None,
}),
);
let tx = system_transaction::transfer(&alice, &bob.pubkey(), 100, blockhash);
bank_forks
.write()
.unwrap()
.get(1)
.unwrap()
.process_transaction(&tx)
.unwrap();
rpc.subscriptions
.notify_subscribers(CommitmentSlots::default());
// allow 200ms for notification thread to wake
std::thread::sleep(Duration::from_millis(200));
let _panic = robust_poll_or_panic(receiver);
} | rust_cleaned_test_functions.jsonl/4703 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 894
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
13500,
36346,
478,
7913,
761,
84993,
368,
341,
286,
1077,
40788,
2648,
1731,
341,
310,
59366,
5332,
345,
310,
28337,
3097,
12670,
25,
70433,
345,
310,
54538,
286,
335,
284,
1855,
16322,
13774,
533... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_many_with_features() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.0.1"
authors = []
[dependencies]
a = { path = "a" }
[features]
foo = []
[workspace]
"#,
)
.file("src/lib.rs", "")
.file("a/Cargo.toml", &basic_manifest("a", "0.0.1"))
.file("a/src/lib.rs", "")
.build();
p.cargo("test -v -p a -p foo --features foo").run();
} | rust_cleaned_test_functions.jsonl/95369 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 356
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
22101,
6615,
14965,
368,
341,
262,
1077,
281,
284,
2390,
741,
286,
659,
1192,
1006,
310,
330,
98228,
73494,
75,
756,
310,
435,
2,
698,
310,
508,
1722,
921,
310,
829,
284,
330,
7975,
698,
310,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_p2sh_address_58() {
let addr = Address {
network: Digibyte,
payload: Payload::ScriptHash(hex_scripthash!("162c5ea71c0b23f5b9022ef047c4a86470a5b070")),
};
assert_eq!(
addr.script_pubkey(),
hex_script!("a914162c5ea71c0b23f5b9022ef047c4a86470a5b07087")
);
assert_eq!(&addr.to_string(), "33iFwdLuRpW1uK1RTRqsoi8rR4NpDzk66k");
assert_eq!(addr.address_type(), Some(AddressType::P2sh));
roundtrips(&addr);
} | rust_cleaned_test_functions.jsonl/63228 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 303
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
620,
17,
927,
6744,
62,
20,
23,
368,
341,
286,
1077,
10789,
284,
9177,
341,
310,
3922,
25,
37969,
579,
78361,
345,
310,
7729,
25,
52916,
486,
5910,
6370,
44660,
643,
740,
8490,
988,
17223,
16,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_bind() -> Result<(), Box<dyn Error + Send + Sync>> {
let foo = "f?o?o";
assert_eq!("'lol'foo?", &"?foo?".bind(&"lol"));
assert_eq!("'lol'foo10", &"?foo?".bind(&"lol").bind(&10));
assert_eq!("'lol'foo?", &"?foo?".bind(&String::from("lol")));
assert_eq!("'lol'foo?", &String::from("?foo?").bind(&"lol"));
assert_eq!("f'lol'o?o", &foo.bind(&"lol"));
assert_eq!("fo'f?o?o'o", &"fo?o".bind(&foo));
assert_eq!("fo10o", &"fo?o".bind(&10_usize));
assert_eq!("fo10o", &"fo?o".bind(&10));
assert_eq!("fo10o", &"fo?o".bind(&10_isize));
assert_eq!("foTRUEo", &"fo?o".bind(&true));
assert_eq!("foFALSEo", &"fo?o".bind(&false));
assert_eq!(
"10f'lol'o10o$3",
&"$1f$2o$1o$3".bind_num(1, &10_u8).bind_num(2, &"lol")
);
assert_eq!("f'lol'oo:def:", &"f:abc:oo:def:".bind_name(&"abc", &"lol"));
Ok(())
} | rust_cleaned_test_functions.jsonl/4400 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 534
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
27461,
368,
1464,
5714,
68843,
8261,
92846,
4600,
488,
11000,
488,
28937,
2452,
341,
286,
1077,
15229,
284,
330,
69,
30,
78,
30,
78,
3302,
286,
2060,
10714,
17223,
6,
59319,
6,
7975,
31011,
609,... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_create_vocab() {
// Given
let values: HashMap<String, i64> = HashMap::new();
let special_values: HashMap<String, i64> = HashMap::new();
let indices: HashMap<i64, String> = HashMap::new();
let special_indices: HashMap<i64, String> = HashMap::new();
let unknown_value = OpenAiGptVocab::unknown_value();
// When
let openai_gpt_vocab = OpenAiGptVocab {
values,
indices,
unknown_value,
special_indices,
special_values,
};
// Then
assert_eq!(openai_gpt_vocab.unknown_value, "<unk>");
assert_eq!(openai_gpt_vocab.unknown_value, OpenAiGptVocab::unknown_value());
assert_eq!(openai_gpt_vocab.values, *openai_gpt_vocab.values());
assert_eq!(openai_gpt_vocab.special_values, *openai_gpt_vocab.special_values());
} | rust_cleaned_test_functions.jsonl/25058 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 446
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
8657,
52823,
368,
341,
322,
286,
16246,
198,
286,
1077,
2750,
25,
10528,
3464,
11,
600,
21,
19,
29,
284,
10528,
486,
931,
543,
286,
1077,
3281,
9146,
25,
10528,
3464,
11,
600,
21,
19,
29,
28... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_next() {
let map = vec![(5, 4), (5, 5), (5, 6), (4, 5), (6, 5)];
let mut u = Universe::new(30, 11);
u.fill(Cell::Dead);
for (x, y) in map.iter() { u.toggle(*x as u32, *y as u32); }
println!("{}", &u);
let mut exp1:Option<String> = None;
let mut exp2:Option<String> = None;
for i in 0..12 {
u.next();
println!("{}.", i);
println!("{}", &u);
if i == 5 {
exp1 = Some(u.to_string());
} else if i == 6 {
exp2 = Some(u.to_string());
} else if i >= 7 {
if i % 2 == 0 {
assert_eq!(exp2, Some(u.to_string()));
} else {
assert_eq!(exp1, Some(u.to_string()));
}
}
}
} | rust_cleaned_test_functions.jsonl/37988 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 527
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
11257,
368,
341,
286,
1077,
2415,
284,
7486,
0,
9697,
20,
11,
220,
19,
701,
320,
20,
11,
220,
20,
701,
320,
20,
11,
220,
21,
701,
320,
19,
11,
220,
20,
701,
320,
21,
11,
220,
20,
12587,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 7 |
#[test]
fn test_rand_u128() {
let env = TestEnv::default();
let value = env.rand_u128();
println!("u128: {}", value);
assert!(value > 0);
} | rust_cleaned_test_functions.jsonl/593 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 93
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
33864,
7300,
16,
17,
23,
368,
341,
286,
1077,
6105,
284,
3393,
14359,
486,
2258,
543,
286,
1077,
897,
284,
6105,
15506,
7300,
16,
17,
23,
543,
286,
13751,
17223,
84,
16,
17,
23,
25,
24689,
8... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | 1 |
#[test]
fn test_hermitian() {
let basis = hermitian_basis_from_spin(1.);
for b in &basis {
let conj = b.t().mapv(|x| x.conj());
let approx = b.abs_diff_eq(&conj, 1e-8);
assert!(approx, "The matrices are not Hermitian");
}
} | rust_cleaned_test_functions.jsonl/79986 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 162
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
1523,
261,
1763,
1103,
368,
341,
286,
1077,
8037,
284,
1059,
1763,
1103,
62696,
5673,
47965,
7,
16,
13,
626,
286,
369,
293,
304,
609,
88826,
341,
310,
1077,
16491,
284,
293,
734,
1005,
2186,
8... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_scalar_negate() {
{
let mut a = Scalar::zero();
a.negate();
assert!(a.is_zero());
}
let mut rng = XorShiftRng::from_seed([
0x59, 0x62, 0xbe, 0x5d, 0x76, 0x3d, 0x31, 0x8d, 0x17, 0xdb, 0x37, 0x32, 0x54, 0x06,
0xbc, 0xe5,
]);
for _ in 0..1000 {
let mut a = Scalar::random(&mut rng);
let mut b = a;
b.negate();
a.add_assign(&b);
assert!(a.is_zero());
}
} | rust_cleaned_test_functions.jsonl/56402 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 367
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
41652,
28209,
349,
368,
341,
286,
341,
310,
1077,
5206,
264,
284,
35176,
486,
14154,
543,
310,
264,
79219,
349,
1428,
310,
2060,
10297,
64,
2079,
19359,
1423,
286,
555,
286,
1077,
5206,
28422,
2... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 2 |
#[test]
fn test_parsing_with_a_newly_excluded_range() {
let mut source_code = String::from("<div><span><%= something %></span></div>");
let mut parser = Parser::new();
parser.set_language(get_language("html")).unwrap();
let mut first_tree = parser.parse(&source_code, None).unwrap();
// Insert code at the beginning of the document.
let prefix = "a very very long line of plain text. ";
first_tree.edit(&InputEdit {
start_byte: 0,
old_end_byte: 0,
new_end_byte: prefix.len(),
start_position: Point::new(0, 0),
old_end_position: Point::new(0, 0),
new_end_position: Point::new(0, prefix.len()),
});
source_code.insert_str(0, prefix);
let directive_start = source_code.find("<%=").unwrap();
let directive_end = source_code.find("</span>").unwrap();
let source_code_end = source_code.len();
parser.set_included_ranges(&[
Range {
start_byte: 0,
end_byte: directive_start,
start_point: Point::new(0, 0),
end_point: Point::new(0, directive_start),
},
Range {
start_byte: directive_end,
end_byte: source_code_end,
start_point: Point::new(0, directive_end),
end_point: Point::new(0, source_code_end),
},
]);
let tree = parser.parse(&source_code, Some(&first_tree)).unwrap();
assert_eq!(
tree.root_node().to_sexp(),
concat!(
"(fragment (text) (element",
" (start_tag (tag_name))",
" (element (start_tag (tag_name)) (end_tag (tag_name)))",
" (end_tag (tag_name))))"
)
);
assert_eq!(
tree.changed_ranges(&first_tree),
vec![
// The first range that has changed syntax is the range of the newly-inserted text.
Range {
start_byte: 0,
end_byte: prefix.len(),
start_point: Point::new(0, 0),
end_point: Point::new(0, prefix.len()),
},
// its contents have changed syntax because a range of text that
// was previously included is now excluded.
Range {
start_byte: directive_start,
end_byte: directive_end,
start_point: Point::new(0, directive_start),
end_point: Point::new(0, directive_end),
},
]
);
} | rust_cleaned_test_functions.jsonl/7395 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 1207
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
620,
28598,
6615,
4306,
5921,
398,
2702,
10181,
9698,
368,
341,
262,
1077,
5206,
2530,
4136,
284,
923,
486,
1499,
9639,
611,
1784,
1480,
1784,
35205,
2494,
1018,
1472,
1480,
1472,
611,
67940,
1066... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
#[test]
fn test_transform() -> Result<()> {
eprintln!();
assert_eq!(transform(7, 8), 5764801);
assert_eq!(transform(7, 11), 17807724);
Ok(())
} | rust_cleaned_test_functions.jsonl/32516 | {
"file_path": "/home/dung/Code/Cross_test_gen (Copy)/clean_data_rust/data/rust_cleaned_test_functions.jsonl",
"token_count": 78
} | [
262,
11506,
1944,
921,
262,
5168,
1273,
18449,
368,
1464,
5714,
71698,
341,
262,
384,
33655,
0,
543,
262,
2060,
10714,
10297,
4701,
7,
22,
11,
220,
23,
701,
220,
20,
22,
21,
19,
23,
15,
16,
317,
262,
2060,
10714,
10297,
4701,
7,
... | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1... | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.