File: sign_test.sail

package info (click to toggle)
sail-ocaml 0.19.1%2Bdfsg5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 18,008 kB
  • sloc: ml: 75,941; ansic: 8,848; python: 1,342; exp: 560; sh: 474; makefile: 218; cpp: 36
file content (143 lines) | stat: -rw-r--r-- 6,046 bytes parent folder | download
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/*==========================================================================*/
/*     Sail                                                                 */
/*                                                                          */
/* Copyright 2024 Intel Corporation                                         */
/*   Pan Li - pan2.li@intel.com                                             */
/*                                                                          */
/*  SPDX-License-Identifier: BSD-2-Clause                                   */
/*==========================================================================*/

default Order dec

$include <prelude.sail>
$include <float/sign.sail>
$include "data.sail"

function test_float_is_positive () -> unit = {
  /* Half floating point */
  assert(float_is_positive(fp16_pos_snan_0));
  assert(float_is_positive(fp16_pos_qnan_0));
  assert(float_is_positive(fp16_pos_zero));
  assert(float_is_positive(fp16_pos_inf));
  assert(float_is_positive(fp16_pos_denormal_0));
  assert(float_is_positive(fp16_pos_normal_0));

  assert(float_is_positive(fp16_neg_snan_0) == false);
  assert(float_is_positive(fp16_neg_qnan_0) == false);
  assert(float_is_positive(fp16_neg_zero) == false);
  assert(float_is_positive(fp16_neg_inf) == false);
  assert(float_is_positive(fp16_neg_denormal_0) == false);
  assert(float_is_positive(fp16_neg_normal_0) == false);

  /* Single floating point */
  assert(float_is_positive(fp32_pos_snan_0));
  assert(float_is_positive(fp32_pos_qnan_0));
  assert(float_is_positive(fp32_pos_zero));
  assert(float_is_positive(fp32_pos_inf));
  assert(float_is_positive(fp32_pos_denormal_0));
  assert(float_is_positive(fp32_pos_normal_0));

  assert(float_is_positive(fp32_neg_snan_0) == false);
  assert(float_is_positive(fp32_neg_qnan_0) == false);
  assert(float_is_positive(fp32_neg_zero) == false);
  assert(float_is_positive(fp32_neg_inf) == false);
  assert(float_is_positive(fp32_neg_denormal_0) == false);
  assert(float_is_positive(fp32_neg_normal_0) == false);

  /* Double floating point */
  assert(float_is_positive(fp64_pos_snan_0));
  assert(float_is_positive(fp64_pos_qnan_0));
  assert(float_is_positive(fp64_pos_zero));
  assert(float_is_positive(fp64_pos_inf));
  assert(float_is_positive(fp64_pos_denormal_0));
  assert(float_is_positive(fp64_pos_normal_0));

  assert(float_is_positive(fp64_neg_snan_0) == false);
  assert(float_is_positive(fp64_neg_qnan_0) == false);
  assert(float_is_positive(fp64_neg_zero) == false);
  assert(float_is_positive(fp64_neg_inf) == false);
  assert(float_is_positive(fp64_neg_denormal_0) == false);
  assert(float_is_positive(fp64_neg_normal_0) == false);

  /* Quad floating point */
  assert(float_is_positive(fp128_pos_snan_0));
  assert(float_is_positive(fp128_pos_qnan_0));
  assert(float_is_positive(fp128_pos_zero));
  assert(float_is_positive(fp128_pos_inf));
  assert(float_is_positive(fp128_pos_denormal_0));
  assert(float_is_positive(fp128_pos_normal_0));

  assert(float_is_positive(fp128_neg_snan_0) == false);
  assert(float_is_positive(fp128_neg_qnan_0) == false);
  assert(float_is_positive(fp128_neg_zero) == false);
  assert(float_is_positive(fp128_neg_inf) == false);
  assert(float_is_positive(fp128_neg_denormal_0) == false);
  assert(float_is_positive(fp128_neg_normal_0) == false);
}

function test_float_is_negative () -> unit = {
  /* Half floating point */
  assert(float_is_negative(fp16_neg_snan_0));
  assert(float_is_negative(fp16_neg_qnan_0));
  assert(float_is_negative(fp16_neg_zero));
  assert(float_is_negative(fp16_neg_inf));
  assert(float_is_negative(fp16_neg_denormal_0));
  assert(float_is_negative(fp16_neg_normal_0));

  assert(float_is_negative(fp16_pos_snan_0) == false);
  assert(float_is_negative(fp16_pos_qnan_0) == false);
  assert(float_is_negative(fp16_pos_zero) == false);
  assert(float_is_negative(fp16_pos_inf) == false);
  assert(float_is_negative(fp16_pos_denormal_0) == false);
  assert(float_is_negative(fp16_pos_normal_0) == false);

  /* Single floating point */
  assert(float_is_negative(fp32_neg_snan_0));
  assert(float_is_negative(fp32_neg_qnan_0));
  assert(float_is_negative(fp32_neg_zero));
  assert(float_is_negative(fp32_neg_inf));
  assert(float_is_negative(fp32_neg_denormal_0));
  assert(float_is_negative(fp32_neg_normal_0));

  assert(float_is_negative(fp32_pos_snan_0) == false);
  assert(float_is_negative(fp32_pos_qnan_0) == false);
  assert(float_is_negative(fp32_pos_zero) == false);
  assert(float_is_negative(fp32_pos_inf) == false);
  assert(float_is_negative(fp32_pos_denormal_0) == false);
  assert(float_is_negative(fp32_pos_normal_0) == false);

  /* Double floating point */
  assert(float_is_negative(fp64_neg_snan_0));
  assert(float_is_negative(fp64_neg_qnan_0));
  assert(float_is_negative(fp64_neg_zero));
  assert(float_is_negative(fp64_neg_inf));
  assert(float_is_negative(fp64_neg_denormal_0));
  assert(float_is_negative(fp64_neg_normal_0));

  assert(float_is_negative(fp64_pos_snan_0) == false);
  assert(float_is_negative(fp64_pos_qnan_0) == false);
  assert(float_is_negative(fp64_pos_zero) == false);
  assert(float_is_negative(fp64_pos_inf) == false);
  assert(float_is_negative(fp64_pos_denormal_0) == false);
  assert(float_is_negative(fp64_pos_normal_0) == false);

  /* Quad floating point */
  assert(float_is_negative(fp128_neg_snan_0));
  assert(float_is_negative(fp128_neg_qnan_0));
  assert(float_is_negative(fp128_neg_zero));
  assert(float_is_negative(fp128_neg_inf));
  assert(float_is_negative(fp128_neg_denormal_0));
  assert(float_is_negative(fp128_neg_normal_0));

  assert(float_is_negative(fp128_pos_snan_0) == false);
  assert(float_is_negative(fp128_pos_qnan_0) == false);
  assert(float_is_negative(fp128_pos_zero) == false);
  assert(float_is_negative(fp128_pos_inf) == false);
  assert(float_is_negative(fp128_pos_denormal_0) == false);
  assert(float_is_negative(fp128_pos_normal_0) == false);
}

function main () -> unit = {
  test_float_is_positive();
  test_float_is_negative();
}