microsoft/qdk
Publicmirrored from https://github.com/microsoft/qdkAvailable
compiler/qsc_codegen/src/qir/instruction_tests/double.rs
88lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | use crate::qir::ToQir; |
| 5 | use qsc_rir::rir; |
| 6 | |
| 7 | #[test] |
| 8 | #[should_panic(expected = "unsupported type f64 for add")] |
| 9 | fn add_double_literals() { |
| 10 | let inst = rir::Instruction::Add( |
| 11 | rir::Operand::Literal(rir::Literal::Double(core::f64::consts::PI)), |
| 12 | rir::Operand::Literal(rir::Literal::Double(core::f64::consts::E)), |
| 13 | rir::Variable { |
| 14 | variable_id: rir::VariableId(0), |
| 15 | ty: rir::Ty::Double, |
| 16 | }, |
| 17 | ); |
| 18 | let _ = &inst.to_qir(&rir::Program::default()); |
| 19 | } |
| 20 | |
| 21 | #[test] |
| 22 | #[should_panic(expected = "unsupported type f64 for ashr")] |
| 23 | fn ashr_double_literals() { |
| 24 | let inst = rir::Instruction::Ashr( |
| 25 | rir::Operand::Literal(rir::Literal::Double(core::f64::consts::PI)), |
| 26 | rir::Operand::Literal(rir::Literal::Double(core::f64::consts::E)), |
| 27 | rir::Variable { |
| 28 | variable_id: rir::VariableId(0), |
| 29 | ty: rir::Ty::Double, |
| 30 | }, |
| 31 | ); |
| 32 | let _ = &inst.to_qir(&rir::Program::default()); |
| 33 | } |
| 34 | |
| 35 | #[test] |
| 36 | #[should_panic(expected = "unsupported type f64 for and")] |
| 37 | fn bitwise_and_double_literals() { |
| 38 | let inst = rir::Instruction::BitwiseAnd( |
| 39 | rir::Operand::Literal(rir::Literal::Double(core::f64::consts::PI)), |
| 40 | rir::Operand::Literal(rir::Literal::Double(core::f64::consts::E)), |
| 41 | rir::Variable { |
| 42 | variable_id: rir::VariableId(0), |
| 43 | ty: rir::Ty::Double, |
| 44 | }, |
| 45 | ); |
| 46 | let _ = &inst.to_qir(&rir::Program::default()); |
| 47 | } |
| 48 | |
| 49 | #[test] |
| 50 | #[should_panic(expected = "unsupported type f64 for not")] |
| 51 | fn bitwise_not_double_literals() { |
| 52 | let inst = rir::Instruction::BitwiseNot( |
| 53 | rir::Operand::Literal(rir::Literal::Double(core::f64::consts::PI)), |
| 54 | rir::Variable { |
| 55 | variable_id: rir::VariableId(0), |
| 56 | ty: rir::Ty::Double, |
| 57 | }, |
| 58 | ); |
| 59 | let _ = &inst.to_qir(&rir::Program::default()); |
| 60 | } |
| 61 | |
| 62 | #[test] |
| 63 | #[should_panic(expected = "unsupported type f64 for or")] |
| 64 | fn bitwise_or_double_literals() { |
| 65 | let inst = rir::Instruction::BitwiseOr( |
| 66 | rir::Operand::Literal(rir::Literal::Double(core::f64::consts::PI)), |
| 67 | rir::Operand::Literal(rir::Literal::Double(core::f64::consts::E)), |
| 68 | rir::Variable { |
| 69 | variable_id: rir::VariableId(0), |
| 70 | ty: rir::Ty::Double, |
| 71 | }, |
| 72 | ); |
| 73 | let _ = &inst.to_qir(&rir::Program::default()); |
| 74 | } |
| 75 | |
| 76 | #[test] |
| 77 | #[should_panic(expected = "unsupported type f64 for xor")] |
| 78 | fn bitwise_xor_double_literals() { |
| 79 | let inst = rir::Instruction::BitwiseXor( |
| 80 | rir::Operand::Literal(rir::Literal::Double(core::f64::consts::PI)), |
| 81 | rir::Operand::Literal(rir::Literal::Double(core::f64::consts::E)), |
| 82 | rir::Variable { |
| 83 | variable_id: rir::VariableId(0), |
| 84 | ty: rir::Ty::Double, |
| 85 | }, |
| 86 | ); |
| 87 | let _ = &inst.to_qir(&rir::Program::default()); |
| 88 | } |
| 89 | |