-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.php
More file actions
65 lines (52 loc) · 1.43 KB
/
test.php
File metadata and controls
65 lines (52 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
require_once __DIR__ . '/vendor/autoload.php';
use TryPhp\PredictIsTrait;
$executionClass = new class() {
use PredictIsTrait;
};
try {
$executionClass->is(4, 4);
} catch (\Exception $ex) {
trigger_error('test failed.', E_USER_ERROR);
}
try {
$executionClass->is(4, 5);
trigger_error('test failed.', E_USER_ERROR);
} catch (\Exception $ex) {
}
try {
$executionClass->is('some string', 'some string');
} catch (\Exception $ex) {
trigger_error('test failed.', E_USER_ERROR);
}
try {
$executionClass->is('some string', 'some other string');
trigger_error('test failed.', E_USER_ERROR);
} catch (\Exception $ex) {
}
try {
$executionClass->is(true, true);
} catch (\Exception $ex) {
trigger_error('test failed.', E_USER_ERROR);
}
try {
$executionClass->is(true, false);
trigger_error('test failed.', E_USER_ERROR);
} catch (\Exception $ex) {
}
try {
$executionClass->is(new \stdClass(), [1,2]);
trigger_error('test failed.', E_USER_ERROR);
} catch (\Exception $ex) {
if ($ex->getMessage() !== "'try/predict-is' can only compare scalar values. 'try/predict' for complex predictions.") {
trigger_error('test failed.', E_USER_ERROR);
}
}
try {
$executionClass->is([1,2], new \stdClass());
trigger_error('test failed.', E_USER_ERROR);
} catch (\Exception $ex) {
if ($ex->getMessage() !== "'try/predict-is' can only compare scalar values. 'try/predict' for complex predictions.") {
trigger_error('test failed.', E_USER_ERROR);
}
}