File: 02_auto_error_check.t

package info (click to toggle)
libopengl-modern-perl 0.0401-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,592 kB
  • sloc: perl: 82,853; ansic: 47,600; makefile: 3
file content (48 lines) | stat: -rw-r--r-- 1,571 bytes parent folder | download | duplicates (2)
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
#! /usr/bin/perl

use strict;
use warnings;
use Test::More;
use OpenGL::Modern ':all';
use OpenGL::Modern::Helpers 'glGetVersion_p';
use Capture::Tiny 'capture';

SKIP: {
    plan skip_all => "glewContext did not succeed, skipping live tests"
      if glewCreateContext() != GLEW_OK;    # returns GL_TRUE or GL_FALSE

    my $gI_status = ( done_glewInit() ) ? GLEW_OK() : glewInit();    # returns GLEW_OK or ???
    plan skip_all => "glewInit did not succeed, skipping live tests"
      if $gI_status != GLEW_OK;

    glClear GL_COLOR;
    pass "didn't crash yet";

    my ( $out, $err ) = capture {
        eval { $@ = undef; glpCheckErrors };
    };
    like $err, qr/OpenGL error: 1281/,          "got expected errors";
    like $@,   qr/1 OpenGL errors encountered/, "can check for errors manually";

    eval { $@ = undef; glpSetAutoCheckErrors 3 };
    is $@, "Usage: glpSetAutoCheckErrors(1|0)\n", "glpSetAutoCheckErrors only accepts 2 values";

    glpSetAutoCheckErrors 1;
    ( $out, $err ) = capture {
        eval { $@ = undef; glClear GL_COLOR };
    };
    like $err, qr/OpenGL error: 1281/,          "got expected errors";
    like $@,   qr/1 OpenGL errors encountered/, "errors cause crashes now";

    glpSetAutoCheckErrors 0;
    glClear GL_COLOR;
    pass "crashes are gone again";

    ( $out, $err ) = capture {
        eval { $@ = undef; glpCheckErrors };
    };
    like $err, qr/OpenGL error: 1281/,          "got expected errors";
    like $@,   qr/1 OpenGL errors encountered/, "but we can still check for errors manually";

    done_testing;
}