mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 16:11:06 +01:00
Add `EXTRA-ARGS:` support to file_test, to add arguments without overriding the default arguments. Use `EXTRA-ARGS: --no-dump-sem-ir` to turn off SemIR dumping and thus SemIR testing in the int builtin tests, which validate correct behavior through diagnostics instead. This doesn't get us any closer to supporting more targeted SemIR dumping / testing, but this seems to be a generally useful feature anyway. Most existing tests using `ARGS` have been switched over to using `EXTRA-ARGS`. Requested in review of #4716.
57 lines
1.7 KiB
Plaintext
57 lines
1.7 KiB
Plaintext
// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
|
|
// Exceptions. See /LICENSE for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
// EXTRA-ARGS: --no-dump-sem-ir
|
|
//
|
|
// AUTOUPDATE
|
|
// TIP: To test this file alone, run:
|
|
// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/builtins/int/udiv.carbon
|
|
// TIP: To dump output, run:
|
|
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/builtins/int/udiv.carbon
|
|
|
|
// --- int_div.carbon
|
|
|
|
fn Div(a: i32, b: i32) -> i32 = "int.udiv";
|
|
|
|
var arr: [i32; Div(3, 2)];
|
|
let arr_p: [i32; 1]* = &arr;
|
|
|
|
fn RuntimeCallIsValid(a: i32, b: i32) -> i32 {
|
|
return Div(a, b);
|
|
}
|
|
|
|
// --- overflow.carbon
|
|
|
|
package Overflow;
|
|
|
|
fn Div(a: i32, b: i32) -> i32 = "int.udiv";
|
|
fn Sub(a: i32, b: i32) -> i32 = "int.usub";
|
|
fn Negate(a: i32) -> i32 = "int.unegate";
|
|
|
|
// -0x7FFF_FFFF / -1 is OK.
|
|
let a: i32 = Div(Negate(0x7FFF_FFFF), Negate(1));
|
|
|
|
// -0x8000_0000 / 1 is OK.
|
|
let b: i32 = Div(Sub(Negate(0x7FFF_FFFF), 1), 1);
|
|
|
|
// -0x8000_0000 / -1 is OK.
|
|
let c: i32 = Div(Sub(Negate(0x7FFF_FFFF), 1), Negate(1));
|
|
|
|
// --- fail_div_by_zero.carbon
|
|
|
|
package FailDivByZero;
|
|
|
|
fn Div(a: i32, b: i32) -> i32 = "int.udiv";
|
|
|
|
// CHECK:STDERR: fail_div_by_zero.carbon:[[@LINE+4]]:14: error: division by zero [CompileTimeDivisionByZero]
|
|
// CHECK:STDERR: let a: i32 = Div(1, 0);
|
|
// CHECK:STDERR: ^~~~~~~~~
|
|
// CHECK:STDERR:
|
|
let a: i32 = Div(1, 0);
|
|
|
|
// CHECK:STDERR: fail_div_by_zero.carbon:[[@LINE+3]]:14: error: division by zero [CompileTimeDivisionByZero]
|
|
// CHECK:STDERR: let b: i32 = Div(0, 0);
|
|
// CHECK:STDERR: ^~~~~~~~~
|
|
let b: i32 = Div(0, 0);
|