📄 variants.phpt
字号:
--TEST--COM: General variant tests--SKIPIF--<?php # vim:ft=phpif (!extension_loaded("com_dotnet")) print "skip COM/.Net support not present"; ?>--FILE--<?php // $Id: variants.phpt,v 1.3 2004/05/03 18:19:07 wez Exp $error_reporting(E_ALL);$v = new VARIANT();if (VT_EMPTY != variant_get_type($v)) { echo "VT_EMPTY: bork\n";}$values = array(VT_I4 => 42, VT_R8 => 3.5, VT_BSTR => "hello", VT_BOOL => false);$binary_ops = array('add', 'cat', 'sub', 'mul', 'and', 'div', 'eqv', 'idiv', 'imp', 'mod', 'or', 'pow', 'xor');foreach ($values as $t => $val) { $v = new VARIANT($val); if ($t != variant_get_type($v)) { printf("Bork: [%d] %d: %s\n", $t, variant_get_type($v), $val); print $v . "\n"; } $results = array(); foreach ($values as $op2) { echo "--\n"; foreach ($binary_ops as $op) { try { echo "$op: " . call_user_func('variant_' . $op, $v, $op2) . "\n"; } catch (com_exception $e) { echo "$op:\n"; echo "\tvariant_$op($v, $op2)\n"; echo "\texception " . $e->getMessage(); printf("\tcode %08x\n\n", $e->getCode()); } } }}echo "OK!";?>--EXPECT----add: 84cat: 4242sub: 0mul: 1764and: 42div: 1eqv: -1idiv: 1imp: -1mod: 0or: 42pow: 1.50130937545297E+68xor: 0--add: 45.5cat: 423.5sub: 38.5mul: 147and: 0div: 12eqv: -47idiv: 10imp: -43mod: 2or: 46pow: 480145.116863642xor: 46--add: variant_add(42, hello) exception Type mismatch. code 80020005cat: 42hellosub: variant_sub(42, hello) exception Type mismatch. code 80020005mul: variant_mul(42, hello) exception Type mismatch. code 80020005and: variant_and(42, hello) exception Type mismatch. code 80020005div: variant_div(42, hello) exception Type mismatch. code 80020005eqv: variant_eqv(42, hello) exception Type mismatch. code 80020005idiv: variant_idiv(42, hello) exception Type mismatch. code 80020005imp: variant_imp(42, hello) exception Type mismatch. code 80020005mod: variant_mod(42, hello) exception Type mismatch. code 80020005or: variant_or(42, hello) exception Type mismatch. code 80020005pow: variant_pow(42, hello) exception Type mismatch. code 80020005xor: variant_xor(42, hello) exception Type mismatch. code 80020005--add: 42cat: 42Falsesub: 42mul: 0and: 0div: variant_div(42, ) exception Division by zero. code 80020012eqv: -43idiv: variant_idiv(42, ) exception Division by zero. code 80020012imp: -43mod: variant_mod(42, ) exception Division by zero. code 80020012or: 42pow: 1xor: 42--add: 45.5cat: 3.542sub: -38.5mul: 147and: 0div: 8.33333333333333E-02eqv: -47idiv: 0imp: -5mod: 4or: 46pow: 7.09345573078604E+22xor: 46--add: 7cat: 3.53.5sub: 0mul: 12.25and: 4div: 1eqv: -1idiv: 1imp: -1mod: 0or: 4pow: 80.2117802289664xor: 0--add: variant_add(3.5, hello) exception Type mismatch. code 80020005cat: 3.5hellosub: variant_sub(3.5, hello) exception Type mismatch. code 80020005mul: variant_mul(3.5, hello) exception Type mismatch. code 80020005and: variant_and(3.5, hello) exception Type mismatch. code 80020005div: variant_div(3.5, hello) exception Type mismatch. code 80020005eqv: variant_eqv(3.5, hello) exception Type mismatch. code 80020005idiv: variant_idiv(3.5, hello) exception Type mismatch. code 80020005imp: variant_imp(3.5, hello) exception Type mismatch. code 80020005mod: variant_mod(3.5, hello) exception Type mismatch. code 80020005or: variant_or(3.5, hello) exception Type mismatch. code 80020005pow: variant_pow(3.5, hello) exception Type mismatch. code 80020005xor: variant_xor(3.5, hello) exception Type mismatch. code 80020005--add: 3.5cat: 3.5Falsesub: 3.5mul: 0and: 0div: variant_div(3.5, ) exception Division by zero. code 80020012eqv: -5idiv: variant_idiv(3.5, ) exception Division by zero. code 80020012imp: -5mod: variant_mod(3.5, ) exception Division by zero. code 80020012or: 4pow: 1xor: 4--add: variant_add(hello, 42) exception Type mismatch. code 80020005cat: hello42sub: variant_sub(hello, 42) exception Type mismatch. code 80020005mul: variant_mul(hello, 42) exception Type mismatch. code 80020005and: variant_and(hello, 42) exception Type mismatch. code 80020005div: variant_div(hello, 42) exception Type mismatch. code 80020005eqv: variant_eqv(hello, 42) exception Type mismatch. code 80020005idiv: variant_idiv(hello, 42) exception Type mismatch. code 80020005imp: variant_imp(hello, 42) exception Type mismatch. code 80020005mod: variant_mod(hello, 42) exception Type mismatch. code 80020005or: variant_or(hello, 42) exception Type mismatch. code 80020005pow: variant_pow(hello, 42) exception Type mismatch. code 80020005xor: variant_xor(hello, 42) exception Type mismatch. code 80020005--add: variant_add(hello, 3.5) exception Type mismatch. code 80020005cat: hello3.5sub: variant_sub(hello, 3.5) exception Type mismatch. code 80020005mul: variant_mul(hello, 3.5) exception Type mismatch. code 80020005and: variant_and(hello, 3.5) exception Type mismatch. code 80020005div: variant_div(hello, 3.5) exception Type mismatch. code 80020005eqv: variant_eqv(hello, 3.5) exception Type mismatch. code 80020005idiv: variant_idiv(hello, 3.5) exception Type mismatch. code 80020005imp: variant_imp(hello, 3.5) exception Type mismatch. code 80020005mod: variant_mod(hello, 3.5) exception Type mismatch. code 80020005or: variant_or(hello, 3.5) exception Type mismatch. code 80020005pow: variant_pow(hello, 3.5) exception Type mismatch. code 80020005xor: variant_xor(hello, 3.5) exception Type mismatch. code 80020005--add: hellohellocat: hellohellosub: variant_sub(hello, hello) exception Type mismatch. code 80020005mul: variant_mul(hello, hello) exception Type mismatch. code 80020005and: variant_and(hello, hello) exception Type mismatch. code 80020005div: variant_div(hello, hello) exception Type mismatch. code 80020005eqv: variant_eqv(hello, hello) exception Type mismatch. code 80020005idiv: variant_idiv(hello, hello) exception Type mismatch. code 80020005imp: variant_imp(hello, hello) exception Type mismatch. code 80020005mod: variant_mod(hello, hello) exception Type mismatch. code 80020005or: variant_or(hello, hello) exception Type mismatch. code 80020005pow: variant_pow(hello, hello) exception Type mismatch. code 80020005xor: variant_xor(hello, hello) exception Type mismatch. code 80020005--add: variant_add(hello, ) exception Type mismatch. code 80020005cat: helloFalsesub: variant_sub(hello, ) exception Type mismatch. code 80020005mul: variant_mul(hello, ) exception Type mismatch. code 80020005and: variant_and(hello, ) exception Type mismatch. code 80020005div: variant_div(hello, ) exception Type mismatch. code 80020005eqv: variant_eqv(hello, ) exception Type mismatch. code 80020005idiv: variant_idiv(hello, ) exception Type mismatch. code 80020005imp: variant_imp(hello, ) exception Type mismatch. code 80020005mod: variant_mod(hello, ) exception Type mismatch. code 80020005or: variant_or(hello, ) exception Type mismatch. code 80020005pow: variant_pow(hello, ) exception Type mismatch. code 80020005xor: variant_xor(hello, ) exception Type mismatch. code 80020005--add: 42cat: False42sub: -42mul: 0and: 0div: 0eqv: -43idiv: 0imp: -1mod: 0or: 42pow: 0xor: 42--add: 3.5cat: False3.5sub: -3.5mul: 0and: 0div: 0eqv: -5idiv: 0imp: -1mod: 0or: 4pow: 0xor: 4--add: variant_add(0, hello) exception Type mismatch. code 80020005cat: Falsehellosub: variant_sub(0, hello) exception Type mismatch. code 80020005mul: variant_mul(0, hello) exception Type mismatch. code 80020005and: variant_and(0, hello) exception Type mismatch. code 80020005div: variant_div(0, hello) exception Type mismatch. code 80020005eqv: variant_eqv(0, hello) exception Type mismatch. code 80020005idiv: variant_idiv(0, hello) exception Type mismatch. code 80020005imp: variant_imp(0, hello) exception Type mismatch. code 80020005mod: variant_mod(0, hello) exception Type mismatch. code 80020005or: variant_or(0, hello) exception Type mismatch. code 80020005pow: variant_pow(0, hello) exception Type mismatch. code 80020005xor: variant_xor(0, hello) exception Type mismatch. code 80020005--add: 0cat: FalseFalsesub: 0mul: 0and: 0div: variant_div(0, ) exception Out of present range. code 8002000aeqv: -1idiv: variant_idiv(0, ) exception Division by zero. code 80020012imp: -1mod: variant_mod(0, ) exception Division by zero. code 80020012or: 0pow: 1xor: 0OK!
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -