xref: /PHP-8.0/ext/standard/tests/assert/assert.phpt (revision 853eb837)
1--TEST--
2assert()
3--INI--
4assert.active = 0
5assert.warning = 1
6assert.callback =
7assert.bail = 0
8assert.exception=0
9--FILE--
10<?php
11function a($file, $line, $unused, $desc)
12{
13    echo "assertion failed $line,\"$desc\"\n";
14}
15
16class a
17{
18    static function assert($file, $line, $unused, $desc)
19    {
20        echo "class assertion failed $line,\"$desc\"\n";
21    }
22}
23
24assert_options(ASSERT_ACTIVE,1);
25assert_options(ASSERT_WARNING,0);
26
27$a = 0;
28
29assert_options(ASSERT_CALLBACK,"a");
30assert($a != 0);
31
32assert_options(ASSERT_CALLBACK,array("a","assert"));
33assert($a != 0);
34
35$obj = new a();
36assert_options(ASSERT_CALLBACK,array(&$obj,"assert"));
37assert($a != 0);
38?>
39--EXPECT--
40assertion failed 21,"assert($a != 0)"
41class assertion failed 24,"assert($a != 0)"
42class assertion failed 28,"assert($a != 0)"
43