fn test_apply_slice()

in starlark/src/values/index.rs [196:249]


    fn test_apply_slice() {
        let s = &[0, 1, 2, 3, 4, 5, 6];

        let x = apply_slice(s, Some(Value::new_int(-1)), None, Some(Value::new_int(-1))).unwrap();
        assert_eq!(x, &[6, 5, 4, 3, 2, 1, 0]);

        let x = apply_slice(s, Some(Value::new_int(-1)), None, Some(Value::new_int(-1))).unwrap();
        assert_eq!(x, &[6, 5, 4, 3, 2, 1, 0]);

        let x = apply_slice(
            s,
            Some(Value::new_int(0)),
            Some(Value::new_int(3)),
            Some(Value::new_int(2)),
        )
        .unwrap();
        assert_eq!(x, &[0, 2]);

        let x = apply_slice(
            s,
            Some(Value::new_int(5)),
            Some(Value::new_int(2)),
            Some(Value::new_int(-2)),
        )
        .unwrap();
        assert_eq!(x, &[5, 3]);

        let x = apply_slice(
            s,
            Some(Value::new_int(-1)),
            Some(Value::new_int(-5)),
            Some(Value::new_int(-1)),
        )
        .unwrap();
        assert_eq!(x, &[6, 5, 4, 3]);

        let x = apply_slice(
            s,
            Some(Value::new_int(-1)),
            Some(Value::new_int(0)),
            Some(Value::new_int(-1)),
        )
        .unwrap();
        assert_eq!(x, &[6, 5, 4, 3, 2, 1]);

        let x = apply_slice(
            &[1, 2, 3],
            Some(Value::new_int(0)),
            Some(Value::new_int(-2)),
            Some(Value::new_int(-1)),
        )
        .unwrap();
        assert_eq!(x, &[] as &[i32]);
    }