PageRenderTime 19ms CodeModel.GetById 9ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/test-suite/php/primitive_ref_runme.php

#
PHP | 34 lines | 26 code | 6 blank | 2 comment | 2 complexity | a2053359c46972772dcc5cfdb362785c MD5 | raw file
 1<?php
 2
 3require "tests.php";
 4require "primitive_ref.php";
 5
 6# A large long long number is too big, so PHP makes treats it as a double, but SWIG opts to return it as a string.
 7# The conversion to double can lose precision so this isn't an exact comparison.
 8function long_long_equal($a,$b,$message) {
 9  if (! ($a===$b))
10    if (! ((double)$a===$b))
11      return check::fail($message . ": '$a'!=='$b'");
12  return TRUE;
13}
14
15
16check::equal(ref_over(3), 3, "ref_over failed");
17
18check::equal(ref_int(3), 3, "ref_int failed");
19check::equal(ref_uint(3), 3, "ref_uint failed");
20check::equal(ref_short(3), 3, "ref_short failed");
21check::equal(ref_ushort(3), 3, "ref_ushort failed");
22check::equal(ref_long(3), 3, "ref_long failed");
23check::equal(ref_ulong(3), 3, "ref_ulong failed");
24check::equal(ref_schar(3), 3, "ref_schar failed");
25check::equal(ref_uchar(3), 3, "ref_uchar failed");
26check::equal(ref_bool(true), true, "ref_bool failed");
27check::equal(ref_float(3.5), 3.5, "ref_float failed");
28check::equal(ref_double(3.5), 3.5, "ref_double failed");
29check::equal(ref_char('x'), 'x', "ref_char failed");
30long_long_equal(ref_longlong(0x123456789ABCDEF0), 0x123456789ABCDEF0, "ref_longlong failed");
31long_long_equal(ref_ulonglong(0xF23456789ABCDEF0), 0xF23456789ABCDEF0, "ref_ulonglong failed");
32
33check::done();
34?>