Skip to content

Commit f13ccf5

Browse files
committed
Add tests
1 parent 8272c9f commit f13ccf5

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

source/compiler/tests/error_094.meta

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
'test_type': 'output_check',
3+
'errors': """
4+
error_094.pwn(6) : error 094: division by zero
5+
error_094.pwn(7) : error 094: division by zero
6+
error_094.pwn(13) : error 094: division by zero
7+
error_094.pwn(14) : error 094: division by zero
8+
"""
9+
}

source/compiler/tests/error_094.pwn

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include <console>
2+
3+
main()
4+
{
5+
// Case 1: Both operands are compile-time constants
6+
printf("%d", 1 / 0); // error 094
7+
printf("%d", 1 % 0); // error 094
8+
printf("%d", 1 / 1);
9+
printf("%d", 1 % 1);
10+
11+
// Case 2: Only the divisor is a constant
12+
new var = 1;
13+
printf("%d", var / 0); // error 094
14+
printf("%d", var % 0); // error 094
15+
printf("%d", var / 1);
16+
printf("%d", var % 1);
17+
18+
printf("%d", 1 / var); // Just to make sure the warning works only
19+
printf("%d", 1 % var); // if the divisor is a constant value
20+
}

0 commit comments

Comments
 (0)