@@ -453,137 +453,90 @@ fn test_slice_list() {
453
453
let tests = [
454
454
"(slice (list 2 3 4 5 6 7 8) u0 u3)" ,
455
455
"(slice (list u0 u1 u2 u3 u4) u3 u2)" ,
456
- // "(append (append (list) 1) 2)",
456
+ "(slice (list 2 3 4 5 6 7 8) u0 u0)" ,
457
+ "(slice (list 2 3 4 5 6 7 8) u10 u3)" ,
457
458
] ;
458
459
459
460
let expected = [
460
- Value :: some ( Value :: list_from ( vec ! [ Value :: Int ( 2 ) , Value :: Int ( 3 ) , Value :: Int ( 4 ) ] ) . unwrap ( ) )
461
- . unwrap ( ) ,
462
- Value :: some ( Value :: list_from ( vec ! [ Value :: UInt ( 3 ) , Value :: UInt ( 4 ) ] ) . unwrap ( ) ) . unwrap ( ) ,
463
- // Value::list_from(vec![Value::Int(1), Value::Int2)]).unwrap(),
461
+ Value :: list_from ( vec ! [ Value :: Int ( 2 ) , Value :: Int ( 3 ) , Value :: Int ( 4 ) ] ) . unwrap ( ) ,
462
+ Value :: list_from ( vec ! [ Value :: UInt ( 3 ) , Value :: UInt ( 4 ) ] ) . unwrap ( ) ,
463
+ Value :: list_from ( vec ! [ ] ) . unwrap ( ) ,
464
+ Value :: list_from ( vec ! [ ] ) . unwrap ( ) ,
465
+ ] ;
466
+
467
+ for ( test, expected) in tests. iter ( ) . zip ( expected. iter ( ) ) {
468
+ assert_eq ! ( expected. clone( ) , execute( test) . unwrap( ) . unwrap( ) ) ;
469
+ }
470
+ }
471
+
472
+ #[ test]
473
+ fn test_slice_buff ( ) {
474
+ let tests = [
475
+ "(slice 0x000102030405 u0 u3)" ,
476
+ "(slice 0x000102030405 u3 u3)" ,
477
+ "(slice 0x000102030405 u3 u10)" ,
478
+ "(slice 0x000102030405 u10 u3)" ,
479
+ "(slice 0x u2 u3)" ,
480
+ ] ;
481
+
482
+ let expected = [
483
+ Value :: buff_from ( vec ! [ 0 , 1 , 2 ] ) . unwrap ( ) ,
484
+ Value :: buff_from ( vec ! [ 3 , 4 , 5 ] ) . unwrap ( ) ,
485
+ Value :: buff_from ( vec ! [ ] ) . unwrap ( ) ,
486
+ Value :: buff_from ( vec ! [ ] ) . unwrap ( ) ,
487
+ Value :: buff_from ( vec ! [ ] ) . unwrap ( ) ,
488
+ ] ;
489
+
490
+ for ( test, expected) in tests. iter ( ) . zip ( expected. iter ( ) ) {
491
+ assert_eq ! ( expected. clone( ) , execute( test) . unwrap( ) . unwrap( ) ) ;
492
+ }
493
+ }
494
+
495
+ #[ test]
496
+ fn test_slice_ascii ( ) {
497
+ let tests = [
498
+ "(slice \" blockstack\" u0 u5)" ,
499
+ "(slice \" blockstack\" u5 u5)" ,
500
+ "(slice \" blockstack\" u5 u0)" ,
501
+ "(slice \" blockstack\" u11 u3)" ,
502
+ "(slice \" \" u0 u3)" ,
503
+ ] ;
504
+
505
+ let expected = [
506
+ Value :: string_ascii_from_bytes ( "block" . into ( ) ) . unwrap ( ) ,
507
+ Value :: string_ascii_from_bytes ( "stack" . into ( ) ) . unwrap ( ) ,
508
+ Value :: string_ascii_from_bytes ( vec ! [ ] ) . unwrap ( ) ,
509
+ Value :: string_ascii_from_bytes ( vec ! [ ] ) . unwrap ( ) ,
510
+ Value :: string_ascii_from_bytes ( vec ! [ ] ) . unwrap ( ) ,
464
511
] ;
465
512
466
513
for ( test, expected) in tests. iter ( ) . zip ( expected. iter ( ) ) {
467
514
assert_eq ! ( expected. clone( ) , execute( test) . unwrap( ) . unwrap( ) ) ;
468
515
}
516
+ }
517
+
518
+ #[ test]
519
+ fn test_slice_utf8 ( ) {
520
+ let tests = [
521
+ "(slice u\" hello \\ u{1F98A}\" u0 u5)" ,
522
+ "(slice u\" hello \\ u{1F98A}\" u6 u1)" ,
523
+ "(slice u\" hello \\ u{1F98A}\" u6 u0)" ,
524
+ "(slice u\" hello \\ u{1F98A}\" u11 u4)" ,
525
+ "(slice u\" \" u0 u3)" ,
526
+ ] ;
527
+
528
+ let expected = [
529
+ Value :: string_utf8_from_bytes ( "hello" . into ( ) ) . unwrap ( ) ,
530
+ Value :: string_utf8_from_bytes ( "🦊" . into ( ) ) . unwrap ( ) ,
531
+ Value :: string_utf8_from_bytes ( vec ! [ ] ) . unwrap ( ) ,
532
+ Value :: string_utf8_from_bytes ( vec ! [ ] ) . unwrap ( ) ,
533
+ Value :: string_utf8_from_bytes ( vec ! [ ] ) . unwrap ( ) ,
534
+ ] ;
469
535
470
- // assert_eq!(
471
- // execute("(append (append (list) 1) u2)").unwrap_err(),
472
- // CheckErrors::TypeValueError(IntType, Value::UInt(2)).into()
473
- // );
474
- }
475
-
476
- // #[test]
477
- // fn test_slice_list() {
478
- // let good = ["(slice (list 2 3 4 5 6 7 8) u0 u3)", "(slice (list u0 u1 u2 u3 u4) u3 u2)"];
479
- // let expected = ["(list 3 int)", "(list 2 uint)"];
480
-
481
- // for (good_test, expected) in good.iter().zip(expected.iter()) {
482
- // assert_eq!(
483
- // expected,
484
- // &format!("{}", type_check_helper(&good_test).unwrap())
485
- // );
486
- // }
487
-
488
- // let bad = [
489
- // "(slice (list 2 3) 3 u4)",
490
- // "(slice (list 2 3) u3 4)",
491
- // "(slice (list u0) u1)",
492
- // ];
493
-
494
- // let bad_expected = [
495
- // CheckErrors::TypeError(UIntType, IntType),
496
- // CheckErrors::TypeError(UIntType, IntType),
497
- // CheckErrors::IncorrectArgumentCount(3, 2),
498
- // ];
499
- // for (bad_test, expected) in bad.iter().zip(bad_expected.iter()) {
500
- // assert_eq!(expected, &type_check_helper(&bad_test).unwrap_err().err);
501
- // }
502
- // }
503
-
504
- // #[test]
505
- // fn test_slice_buff() {
506
- // let good = ["(slice 0x000102030405 u0 u3)", "(slice 0x000102030405 u3 u2)"];
507
- // let expected = ["(buff 3)", "(buff 2)"];
508
-
509
- // for (good_test, expected) in good.iter().zip(expected.iter()) {
510
- // assert_eq!(
511
- // expected,
512
- // &format!("{}", type_check_helper(&good_test).unwrap())
513
- // );
514
- // }
515
-
516
- // let bad = [
517
- // "(slice 0x000102030405 3 u4)",
518
- // "(slice 0x000102030405 u3 4)",
519
- // "(slice 0x000102030405 u1)",
520
- // ];
521
-
522
- // let bad_expected = [
523
- // CheckErrors::TypeError(UIntType, IntType),
524
- // CheckErrors::TypeError(UIntType, IntType),
525
- // CheckErrors::IncorrectArgumentCount(3, 2),
526
- // ];
527
- // for (bad_test, expected) in bad.iter().zip(bad_expected.iter()) {
528
- // assert_eq!(expected, &type_check_helper(&bad_test).unwrap_err().err);
529
- // }
530
- // }
531
-
532
- // #[test]
533
- // fn test_slice_ascii() {
534
- // let good = ["(slice \"blockstack\" u4 u5)", "(slice \"blockstack\" u0 u5)"];
535
- // let expected = ["(string-ascii 5)", "(string-ascii 5)"];
536
-
537
- // for (good_test, expected) in good.iter().zip(expected.iter()) {
538
- // assert_eq!(
539
- // expected,
540
- // &format!("{}", type_check_helper(&good_test).unwrap())
541
- // );
542
- // }
543
-
544
- // let bad = [
545
- // "(slice \"blockstack\" 3 u4)",
546
- // "(slice \"blockstack\" u3 4)",
547
- // "(slice \"blockstack\" u1)",
548
- // ];
549
-
550
- // let bad_expected = [
551
- // CheckErrors::TypeError(UIntType, IntType),
552
- // CheckErrors::TypeError(UIntType, IntType),
553
- // CheckErrors::IncorrectArgumentCount(3, 2),
554
- // ];
555
- // for (bad_test, expected) in bad.iter().zip(bad_expected.iter()) {
556
- // assert_eq!(expected, &type_check_helper(&bad_test).unwrap_err().err);
557
- // }
558
- // }
559
-
560
- // #[test]
561
- // fn test_slice_utf8() {
562
- // let good = ["(slice u\"blockstack\" u4 u5)", "(slice u\"blockstack\" u4 u5)"];
563
- // let expected = ["(string-utf8 5)", "(string-utf8 5)"];
564
-
565
- // for (good_test, expected) in good.iter().zip(expected.iter()) {
566
- // assert_eq!(
567
- // expected,
568
- // &format!("{}", type_check_helper(&good_test).unwrap())
569
- // );
570
- // }
571
-
572
- // let bad = [
573
- // "(slice u\"blockstack\" 3 u4)",
574
- // "(slice u\"blockstack\" u3 4)",
575
- // "(slice u\"blockstack\" u1)",
576
- // ];
577
-
578
- // let bad_expected = [
579
- // CheckErrors::TypeError(UIntType, IntType),
580
- // CheckErrors::TypeError(UIntType, IntType),
581
- // CheckErrors::IncorrectArgumentCount(3, 2),
582
- // ];
583
- // for (bad_test, expected) in bad.iter().zip(bad_expected.iter()) {
584
- // assert_eq!(expected, &type_check_helper(&bad_test).unwrap_err().err);
585
- // }
586
- // }
536
+ for ( test, expected) in tests. iter ( ) . zip ( expected. iter ( ) ) {
537
+ assert_eq ! ( expected. clone( ) , execute( test) . unwrap( ) . unwrap( ) ) ;
538
+ }
539
+ }
587
540
588
541
#[ test]
589
542
fn test_simple_list_concat ( ) {
0 commit comments