File: 10find_cflags.t

package info (click to toggle)
libextutils-cchecker-perl 0.12-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 180 kB
  • sloc: perl: 343; makefile: 2
file content (28 lines) | stat: -rw-r--r-- 777 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
#!/usr/bin/perl

use v5.14;
use warnings;

use Test2::V0;

use ExtUtils::CChecker;

my $cc = ExtUtils::CChecker->new;

use Config;
plan skip_all => "This test requires gcc" unless $Config{cc} =~ m/(^|-)gcc$/;

ok( !$cc->try_find_cflags_for(
      source => "int main(void) { int nums[] = { [0] = 123 }; return 0; }",
      cflags => [ [qw( -std=c89 -pedantic-errors )] ],
   ), 'C99 program does not compile with only -std=c89' );

ok( $cc->try_find_cflags_for(
      source => "int main(void) { int nums[] = { [0] = 123 }; return 0; }",
      cflags => [ [qw( -std=c99 -pedantic-errors )] ],
   ), 'C99 program compiles with -std=c99' );

ok( scalar( grep { m/^-std=c99$/ } @{ $cc->extra_compiler_flags } ),
   '-std=c99 now appears in extra_compiler_flags' );

done_testing;