예제 #1
0
def check_bad_character(tfile):
    """ Check for bad characters """
    with nt.assert_raises(SystemExit) as e:
        glsl.GLSLParserTest(tfile)

        # Obviously this isn't a perfect check, but it should be close enough
        if not e.exception.message.startswith('Bad character "'):
            raise AssertionError(e.exception)
예제 #2
0
def test_no_config_end():
    """ GLSLParserTest requires [end config] """
    with utils.with_tempfile('// [config]\n') as tfile:
        with nt.assert_raises(SystemExit) as exc:
            glsl.GLSLParserTest(tfile)
            nt.assert_equal(
                exc.exception,
                'No [end config] section found!',
                msg="config section not closed, no exception raised")
예제 #3
0
def test_find_config_start():
    """ GLSLParserTest finds [config] """
    content = ('// [config]\n' '// glsl_version: 1.00\n' '//\n')
    with utils.with_tempfile(content) as tfile:
        with nt.assert_raises(SystemExit) as exc:
            glsl.GLSLParserTest(tfile)
            nt.assert_not_equal(exc.exception,
                                'No [config] section found!',
                                msg="Config section not parsed")
예제 #4
0
def check_good_extension(file_, desc):
    """ A good extension should not raise a GLSLParserException """
    try:
        glsl.GLSLParserTest(file_)
    except glsl.GLSLParserException:
        nt.ok_(
            False,
            'GLSLParserException was raised by "required_extensions: {}"'
            ', but should not'.format(desc))
예제 #5
0
def check_no_duplicates(content, dup):
    """ Ensure that duplicate entries raise an error """
    with nt.assert_raises(SystemExit) as e:
        with utils.with_tempfile(content) as tfile:
            glsl.GLSLParserTest(tfile)

            nt.eq_(
                e.exception.message,
                'Duplicate entry for key {0} in file {1}'.format(dup, tfile))
예제 #6
0
def test_no_glsl_version():
    """ glsl_version section is required """
    content = ('//\n' '// expect_result: pass\n' '// [end config]\n')
    with utils.with_tempfile(content) as tfile:
        with nt.assert_raises(SystemExit) as exc:
            glsl.GLSLParserTest(tfile)
            nt.assert_equal(
                exc.exception,
                'Missing required section glsl_version from config',
                msg="config section not closed, no exception raised")
예제 #7
0
def test_no_expect_result():
    """ expect_result section is required """
    content = ('// [config]\n' '// glsl_version: 1.00\n' '//\n')
    with utils.with_tempfile(content) as tfile:
        with nt.assert_raises(glsl.GLSLParserException) as exc:
            glsl.GLSLParserTest(tfile)
            nt.assert_equal(
                exc.exception,
                'Missing required section expect_result from config',
                msg="config section not closed, no exception raised")
예제 #8
0
def test_no_config_start():
    """ GLSLParserTest requires [config] """
    content = ('// expect_result: pass\n'
               '// glsl_version: 1.00\n'
               '// [end config]\n')
    with utils.with_tempfile(content) as tfile:
        with nt.assert_raises(SystemExit) as exc:
            glsl.GLSLParserTest(tfile)
            nt.assert_equal(exc.exception,
                            'No [config] section found!',
                            msg="No config section found, no exception raised")
예제 #9
0
def _check_config(content):
    """ This is the test that actually checks the glsl config section """
    with utils.with_tempfile(content) as tfile:
        return glsl.GLSLParserTest(tfile), tfile
예제 #10
0
def test_glslparser_initializer():
    """ GLSLParserTest initializes """
    glsl.GLSLParserTest('tests/spec/glsl-es-1.00/compiler/version-macro.frag')