| 1 |
# This file is licensed under the Apache License v2.0 with LLVM Exceptions. |
| 2 |
# See https://llvm.org/LICENSE.txt for license information. |
| 3 |
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 4 |
|
| 5 |
# Tests for LLVM libc math.h functions. |
| 6 |
|
| 7 |
load("//libc/test/src/math:libc_math_test_rules.bzl", "math_test") |
| 8 |
|
| 9 |
package(default_visibility = ["//visibility:public"]) |
| 10 |
|
| 11 |
licenses(["notice"]) |
| 12 |
|
| 13 |
math_test( |
| 14 |
name = "fabs", |
| 15 |
hdrs = ["FAbsTest.h"], |
| 16 |
deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], |
| 17 |
) |
| 18 |
|
| 19 |
math_test( |
| 20 |
name = "fabsf", |
| 21 |
hdrs = ["FAbsTest.h"], |
| 22 |
deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], |
| 23 |
) |
| 24 |
|
| 25 |
math_test( |
| 26 |
name = "fabsl", |
| 27 |
hdrs = ["FAbsTest.h"], |
| 28 |
deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], |
| 29 |
) |
| 30 |
|
| 31 |
math_test( |
| 32 |
name = "ceil", |
| 33 |
hdrs = ["CeilTest.h"], |
| 34 |
deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], |
| 35 |
) |
| 36 |
|
| 37 |
math_test( |
| 38 |
name = "ceilf", |
| 39 |
hdrs = ["CeilTest.h"], |
| 40 |
deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], |
| 41 |
) |
| 42 |
|
| 43 |
math_test( |
| 44 |
name = "ceill", |
| 45 |
hdrs = ["CeilTest.h"], |
| 46 |
deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], |
| 47 |
) |
| 48 |
|
| 49 |
math_test( |
| 50 |
name = "floor", |
| 51 |
hdrs = ["FloorTest.h"], |
| 52 |
deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], |
| 53 |
) |
| 54 |
|
| 55 |
math_test( |
| 56 |
name = "floorf", |
| 57 |
hdrs = ["FloorTest.h"], |
| 58 |
deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], |
| 59 |
) |
| 60 |
|
| 61 |
math_test( |
| 62 |
name = "floorl", |
| 63 |
hdrs = ["FloorTest.h"], |
| 64 |
deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], |
| 65 |
) |
| 66 |
|
| 67 |
math_test( |
| 68 |
name = "trunc", |
| 69 |
hdrs = ["TruncTest.h"], |
| 70 |
deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], |
| 71 |
) |
| 72 |
|
| 73 |
math_test( |
| 74 |
name = "truncf", |
| 75 |
hdrs = ["TruncTest.h"], |
| 76 |
deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], |
| 77 |
) |
| 78 |
|
| 79 |
math_test( |
| 80 |
name = "truncl", |
| 81 |
hdrs = ["TruncTest.h"], |
| 82 |
deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], |
| 83 |
) |
| 84 |
|
| 85 |
math_test( |
| 86 |
name = "round", |
| 87 |
hdrs = ["RoundTest.h"], |
| 88 |
deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], |
| 89 |
) |
| 90 |
|
| 91 |
math_test( |
| 92 |
name = "roundf", |
| 93 |
hdrs = ["RoundTest.h"], |
| 94 |
deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], |
| 95 |
) |
| 96 |
|
| 97 |
math_test( |
| 98 |
name = "roundl", |
| 99 |
hdrs = ["RoundTest.h"], |
| 100 |
deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], |
| 101 |
) |
| 102 |
|
| 103 |
math_test( |
| 104 |
name = "frexp", |
| 105 |
hdrs = ["FrexpTest.h"], |
| 106 |
deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], |
| 107 |
) |
| 108 |
|
| 109 |
math_test( |
| 110 |
name = "frexpf", |
| 111 |
hdrs = ["FrexpTest.h"], |
| 112 |
deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], |
| 113 |
) |
| 114 |
|
| 115 |
math_test( |
| 116 |
name = "frexpl", |
| 117 |
hdrs = ["FrexpTest.h"], |
| 118 |
deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], |
| 119 |
) |
| 120 |
|
| 121 |
math_test( |
| 122 |
name = "hypot", |
| 123 |
hdrs = ["HypotTest.h"], |
| 124 |
deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], |
| 125 |
) |
| 126 |
|
| 127 |
math_test( |
| 128 |
name = "hypotf", |
| 129 |
hdrs = [ |
| 130 |
"HypotTest.h", |
| 131 |
"hypotf_hard_to_round.h", |
| 132 |
], |
| 133 |
deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], |
| 134 |
) |
| 135 |
|
| 136 |
math_test( |
| 137 |
name = "logb", |
| 138 |
hdrs = ["LogbTest.h"], |
| 139 |
deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], |
| 140 |
) |
| 141 |
|
| 142 |
math_test( |
| 143 |
name = "logbf", |
| 144 |
hdrs = ["LogbTest.h"], |
| 145 |
deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], |
| 146 |
) |
| 147 |
|
| 148 |
math_test( |
| 149 |
name = "logbl", |
| 150 |
hdrs = ["LogbTest.h"], |
| 151 |
deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], |
| 152 |
) |
| 153 |
|
| 154 |
math_test( |
| 155 |
name = "modf", |
| 156 |
hdrs = ["ModfTest.h"], |
| 157 |
deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], |
| 158 |
) |
| 159 |
|
| 160 |
math_test( |
| 161 |
name = "modff", |
| 162 |
hdrs = ["ModfTest.h"], |
| 163 |
deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], |
| 164 |
) |
| 165 |
|
| 166 |
math_test( |
| 167 |
name = "modfl", |
| 168 |
hdrs = ["ModfTest.h"], |
| 169 |
deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], |
| 170 |
) |
| 171 |
|
| 172 |
cc_library( |
| 173 |
name = "remquo_test_template", |
| 174 |
hdrs = ["RemQuoTest.h"], |
| 175 |
deps = [ |
| 176 |
"//libc:__support_fputil_basic_operations", |
| 177 |
"//libc:__support_fputil_fp_bits", |
| 178 |
"//libc/utils/MPFRWrapper:mpfr_wrapper", |
| 179 |
"//libc/utils/UnitTest:LibcUnitTest", |
| 180 |
"//libc/utils/UnitTest:fp_test_helpers", |
| 181 |
], |
| 182 |
) |
| 183 |
|
| 184 |
math_test( |
| 185 |
name = "remquo", |
| 186 |
deps = [ |
| 187 |
":remquo_test_template", |
| 188 |
"//libc/utils/MPFRWrapper:mpfr_wrapper", |
| 189 |
], |
| 190 |
) |
| 191 |
|
| 192 |
math_test( |
| 193 |
name = "remquof", |
| 194 |
deps = [ |
| 195 |
":remquo_test_template", |
| 196 |
"//libc/utils/MPFRWrapper:mpfr_wrapper", |
| 197 |
], |
| 198 |
) |
| 199 |
|
| 200 |
math_test( |
| 201 |
name = "remquol", |
| 202 |
deps = [ |
| 203 |
":remquo_test_template", |
| 204 |
"//libc/utils/MPFRWrapper:mpfr_wrapper", |
| 205 |
], |
| 206 |
) |
| 207 |
|
| 208 |
math_test( |
| 209 |
name = "fmin", |
| 210 |
hdrs = ["FMinTest.h"], |
| 211 |
deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], |
| 212 |
) |
| 213 |
|
| 214 |
math_test( |
| 215 |
name = "fminf", |
| 216 |
hdrs = ["FMinTest.h"], |
| 217 |
deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], |
| 218 |
) |
| 219 |
|
| 220 |
math_test( |
| 221 |
name = "fminl", |
| 222 |
hdrs = ["FMinTest.h"], |
| 223 |
deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], |
| 224 |
) |
| 225 |
|
| 226 |
math_test( |
| 227 |
name = "fmax", |
| 228 |
hdrs = ["FMaxTest.h"], |
| 229 |
deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], |
| 230 |
) |
| 231 |
|
| 232 |
math_test( |
| 233 |
name = "fmaxf", |
| 234 |
hdrs = ["FMaxTest.h"], |
| 235 |
deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], |
| 236 |
) |
| 237 |
|
| 238 |
math_test( |
| 239 |
name = "fmaxl", |
| 240 |
hdrs = ["FMaxTest.h"], |
| 241 |
deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], |
| 242 |
) |
| 243 |
|
| 244 |
math_test( |
| 245 |
name = "sqrt", |
| 246 |
hdrs = ["SqrtTest.h"], |
| 247 |
deps = [ |
| 248 |
"//libc:__support_cpp_bit", |
| 249 |
"//libc/utils/MPFRWrapper:mpfr_wrapper", |
| 250 |
], |
| 251 |
) |
| 252 |
|
| 253 |
math_test( |
| 254 |
name = "sqrtf", |
| 255 |
hdrs = ["SqrtTest.h"], |
| 256 |
deps = [ |
| 257 |
"//libc:__support_cpp_bit", |
| 258 |
"//libc/utils/MPFRWrapper:mpfr_wrapper", |
| 259 |
], |
| 260 |
) |
| 261 |
|
| 262 |
math_test( |
| 263 |
name = "sqrtl", |
| 264 |
hdrs = ["SqrtTest.h"], |
| 265 |
deps = [ |
| 266 |
"//libc:__support_cpp_bit", |
| 267 |
"//libc/utils/MPFRWrapper:mpfr_wrapper", |
| 268 |
], |
| 269 |
) |
| 270 |
|
| 271 |
math_test( |
| 272 |
name = "copysign", |
| 273 |
hdrs = ["CopySignTest.h"], |
| 274 |
deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], |
| 275 |
) |
| 276 |
|
| 277 |
math_test( |
| 278 |
name = "copysignf", |
| 279 |
hdrs = ["CopySignTest.h"], |
| 280 |
deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], |
| 281 |
) |
| 282 |
|
| 283 |
math_test( |
| 284 |
name = "copysignl", |
| 285 |
hdrs = ["CopySignTest.h"], |
| 286 |
deps = ["//libc/utils/MPFRWrapper:mpfr_wrapper"], |
| 287 |
) |
| 288 |
|
| 289 |
cc_library( |
| 290 |
name = "ilogb_test_template", |
| 291 |
hdrs = ["ILogbTest.h"], |
| 292 |
deps = [ |
| 293 |
"//libc:__support_fputil_fp_bits", |
| 294 |
"//libc:__support_fputil_manipulation_functions", |
| 295 |
"//libc/utils/UnitTest:LibcUnitTest", |
| 296 |
], |
| 297 |
) |
| 298 |
|
| 299 |
math_test( |
| 300 |
name = "ilogb", |
| 301 |
deps = [":ilogb_test_template"], |
| 302 |
) |
| 303 |
|
| 304 |
math_test( |
| 305 |
name = "ilogbf", |
| 306 |
deps = [":ilogb_test_template"], |
| 307 |
) |
| 308 |
|
| 309 |
math_test( |
| 310 |
name = "ilogbl", |
| 311 |
deps = [":ilogb_test_template"], |
| 312 |
) |
| 313 |
|
| 314 |
cc_library( |
| 315 |
name = "fdim_test_template", |
| 316 |
hdrs = ["FDimTest.h"], |
| 317 |
deps = [ |
| 318 |
"//libc:__support_fputil_basic_operations", |
| 319 |
"//libc:__support_fputil_fenv_impl", |
| 320 |
"//libc:__support_fputil_fp_bits", |
| 321 |
"//libc/utils/UnitTest:LibcUnitTest", |
| 322 |
"//libc/utils/UnitTest:fp_test_helpers", |
| 323 |
], |
| 324 |
) |
| 325 |
|
| 326 |
math_test( |
| 327 |
name = "fdim", |
| 328 |
deps = [":fdim_test_template"], |
| 329 |
) |
| 330 |
|
| 331 |
math_test( |
| 332 |
name = "fdimf", |
| 333 |
deps = [":fdim_test_template"], |
| 334 |
) |
| 335 |
|
| 336 |
math_test( |
| 337 |
name = "fdiml", |
| 338 |
deps = [":fdim_test_template"], |
| 339 |
) |
| 340 |
|
| 341 |
cc_library( |
| 342 |
name = "ldexp_test_template", |
| 343 |
hdrs = ["LdExpTest.h"], |
| 344 |
deps = [ |
| 345 |
"//libc:__support_fputil_fp_bits", |
| 346 |
"//libc:__support_fputil_normal_float", |
| 347 |
"//libc/utils/UnitTest:LibcUnitTest", |
| 348 |
"//libc/utils/UnitTest:fp_test_helpers", |
| 349 |
], |
| 350 |
) |
| 351 |
|
| 352 |
math_test( |
| 353 |
name = "ldexp", |
| 354 |
deps = [":ldexp_test_template"], |
| 355 |
) |
| 356 |
|
| 357 |
math_test( |
| 358 |
name = "ldexpf", |
| 359 |
deps = [":ldexp_test_template"], |
| 360 |
) |
| 361 |
|
| 362 |
math_test( |
| 363 |
name = "ldexpl", |
| 364 |
deps = [":ldexp_test_template"], |
| 365 |
) |
| 366 |
|
| 367 |
cc_library( |
| 368 |
name = "rint_test_template", |
| 369 |
hdrs = ["RIntTest.h"], |
| 370 |
deps = [ |
| 371 |
"//libc:__support_fputil_fenv_impl", |
| 372 |
"//libc:__support_fputil_fp_bits", |
| 373 |
"//libc/utils/MPFRWrapper:mpfr_wrapper", |
| 374 |
"//libc/utils/UnitTest:LibcUnitTest", |
| 375 |
"//libc/utils/UnitTest:fp_test_helpers", |
| 376 |
], |
| 377 |
) |
| 378 |
|
| 379 |
math_test( |
| 380 |
name = "rint", |
| 381 |
deps = [ |
| 382 |
":rint_test_template", |
| 383 |
"//libc/utils/MPFRWrapper:mpfr_wrapper", |
| 384 |
], |
| 385 |
) |
| 386 |
|
| 387 |
math_test( |
| 388 |
name = "rintf", |
| 389 |
deps = [ |
| 390 |
":rint_test_template", |
| 391 |
"//libc/utils/MPFRWrapper:mpfr_wrapper", |
| 392 |
], |
| 393 |
) |
| 394 |
|
| 395 |
math_test( |
| 396 |
name = "rintl", |
| 397 |
deps = [ |
| 398 |
":rint_test_template", |
| 399 |
"//libc/utils/MPFRWrapper:mpfr_wrapper", |
| 400 |
], |
| 401 |
) |
| 402 |
|
| 403 |
cc_library( |
| 404 |
name = "round_to_integer_test_template", |
| 405 |
hdrs = ["RoundToIntegerTest.h"], |
| 406 |
deps = [ |
| 407 |
"//libc:__support_fputil_fenv_impl", |
| 408 |
"//libc:__support_fputil_fp_bits", |
| 409 |
"//libc/utils/MPFRWrapper:mpfr_wrapper", |
| 410 |
"//libc/utils/UnitTest:LibcUnitTest", |
| 411 |
"//libc/utils/UnitTest:fp_test_helpers", |
| 412 |
], |
| 413 |
) |
| 414 |
|
| 415 |
math_test( |
| 416 |
name = "lrint", |
| 417 |
deps = [ |
| 418 |
":round_to_integer_test_template", |
| 419 |
"//libc/utils/MPFRWrapper:mpfr_wrapper", |
| 420 |
], |
| 421 |
) |
| 422 |
|
| 423 |
math_test( |
| 424 |
name = "lrintf", |
| 425 |
deps = [ |
| 426 |
":round_to_integer_test_template", |
| 427 |
"//libc/utils/MPFRWrapper:mpfr_wrapper", |
| 428 |
], |
| 429 |
) |
| 430 |
|
| 431 |
math_test( |
| 432 |
name = "lrintl", |
| 433 |
deps = [ |
| 434 |
":round_to_integer_test_template", |
| 435 |
"//libc/utils/MPFRWrapper:mpfr_wrapper", |
| 436 |
], |
| 437 |
) |
| 438 |
|
| 439 |
math_test( |
| 440 |
name = "llrint", |
| 441 |
deps = [ |
| 442 |
":round_to_integer_test_template", |
| 443 |
"//libc/utils/MPFRWrapper:mpfr_wrapper", |
| 444 |
], |
| 445 |
) |
| 446 |
|
| 447 |
math_test( |
| 448 |
name = "llrintf", |
| 449 |
deps = [ |
| 450 |
":round_to_integer_test_template", |
| 451 |
"//libc/utils/MPFRWrapper:mpfr_wrapper", |
| 452 |
], |
| 453 |
) |
| 454 |
|
| 455 |
math_test( |
| 456 |
name = "llrintl", |
| 457 |
deps = [ |
| 458 |
":round_to_integer_test_template", |
| 459 |
"//libc/utils/MPFRWrapper:mpfr_wrapper", |
| 460 |
], |
| 461 |
) |
| 462 |
|
| 463 |
math_test( |
| 464 |
name = "lround", |
| 465 |
deps = [ |
| 466 |
":round_to_integer_test_template", |
| 467 |
"//libc/utils/MPFRWrapper:mpfr_wrapper", |
| 468 |
], |
| 469 |
) |
| 470 |
|
| 471 |
math_test( |
| 472 |
name = "lroundf", |
| 473 |
deps = [ |
| 474 |
":round_to_integer_test_template", |
| 475 |
"//libc/utils/MPFRWrapper:mpfr_wrapper", |
| 476 |
], |
| 477 |
) |
| 478 |
|
| 479 |
math_test( |
| 480 |
name = "lroundl", |
| 481 |
deps = [ |
| 482 |
":round_to_integer_test_template", |
| 483 |
"//libc/utils/MPFRWrapper:mpfr_wrapper", |
| 484 |
], |
| 485 |
) |
| 486 |
|
| 487 |
math_test( |
| 488 |
name = "llround", |
| 489 |
deps = [ |
| 490 |
":round_to_integer_test_template", |
| 491 |
"//libc/utils/MPFRWrapper:mpfr_wrapper", |
| 492 |
], |
| 493 |
) |
| 494 |
|
| 495 |
math_test( |
| 496 |
name = "llroundf", |
| 497 |
deps = [ |
| 498 |
":round_to_integer_test_template", |
| 499 |
"//libc/utils/MPFRWrapper:mpfr_wrapper", |
| 500 |
], |
| 501 |
) |
| 502 |
|
| 503 |
math_test( |
| 504 |
name = "llroundl", |
| 505 |
deps = [ |
| 506 |
":round_to_integer_test_template", |
| 507 |
"//libc/utils/MPFRWrapper:mpfr_wrapper", |
| 508 |
], |
| 509 |
) |
| 510 |
|
| 511 |
cc_library( |
| 512 |
name = "nextafter_test_template", |
| 513 |
hdrs = ["NextAfterTest.h"], |
| 514 |
deps = [ |
| 515 |
"//libc:__support_cpp_array", |
| 516 |
"//libc:__support_cpp_bit", |
| 517 |
"//libc:__support_cpp_type_traits", |
| 518 |
"//libc:__support_fputil_basic_operations", |
| 519 |
"//libc:__support_fputil_fp_bits", |
| 520 |
"//libc/utils/UnitTest:LibcUnitTest", |
| 521 |
"//libc/utils/UnitTest:fp_test_helpers", |
| 522 |
], |
| 523 |
) |
| 524 |
|
| 525 |
math_test( |
| 526 |
name = "nextafter", |
| 527 |
deps = [":nextafter_test_template"], |
| 528 |
) |
| 529 |
|
| 530 |
math_test( |
| 531 |
name = "nextafterf", |
| 532 |
deps = [":nextafter_test_template"], |
| 533 |
) |
| 534 |
|
| 535 |
math_test( |
| 536 |
name = "nextafterl", |
| 537 |
deps = [":nextafter_test_template"], |
| 538 |
) |
| 539 |
|
| 540 |
cc_library( |
| 541 |
name = "sdcomp26094", |
| 542 |
hdrs = ["sdcomp26094.h"], |
| 543 |
deps = [ |
| 544 |
"//libc:__support_cpp_array", |
| 545 |
"//libc:libc_root", |
| 546 |
], |
| 547 |
) |
| 548 |
|
| 549 |
math_test( |
| 550 |
name = "cosf", |
| 551 |
deps = [ |
| 552 |
":sdcomp26094", |
| 553 |
"//libc:__support_cpp_array", |
| 554 |
"//libc/utils/MPFRWrapper:mpfr_wrapper", |
| 555 |
], |
| 556 |
) |
| 557 |
|
| 558 |
math_test( |
| 559 |
name = "sincosf", |
| 560 |
deps = [ |
| 561 |
":sdcomp26094", |
| 562 |
"//libc:__support_cpp_array", |
| 563 |
"//libc/utils/MPFRWrapper:mpfr_wrapper", |
| 564 |
], |
| 565 |
) |
| 566 |
|
| 567 |
math_test( |
| 568 |
name = "sinf", |
| 569 |
deps = [ |
| 570 |
":sdcomp26094", |
| 571 |
"//libc:__support_cpp_array", |
| 572 |
"//libc/utils/MPFRWrapper:mpfr_wrapper", |
| 573 |
], |
| 574 |
) |