#!/usr/bin/env python
# Copyright (c) 2019 The Khronos Group Inc.
# Use of this source code is governed by an MIT-style license that can be
# found in the LICENSE.txt file.
"""
Generator for builtinprecision* tests.
This file needs to be run in its folder.
"""
import sys
_DO_NOT_EDIT_WARNING = """
"""
_HTML_TEMPLATE = """
WebGL Builtin Precision Conformance Tests
"""
_GROUPS = [
'add',
'sub',
'mul',
'div',
'radians',
'degrees',
'sin',
'cos',
'tan',
'asin',
'acos',
'atan',
'atan2',
'sinh',
'cosh',
'tanh',
'asinh',
'acosh',
'atanh',
'pow',
'exp',
'exp2',
'log',
'log2',
'sqrt',
'inversesqrt',
'abs',
'sign',
'floor',
'trunc',
'round',
'roundeven',
'ceil',
'fract',
'mod',
'modf',
'min',
'max',
'mix',
'step',
'smoothstep',
'clamp',
'length',
'distance',
'dot',
'cross',
'normalize',
'faceforward',
'reflect',
'refract',
'matrixcompmult',
'outerproduct',
'transpose',
'determinant',
'inverse'
]
def GenerateFilename(group):
"""Generate test filename."""
filename = group
filename += ".html"
return filename
def WriteTest(filename, index):
"""Write one test."""
file = open(filename, "wb")
file.write(_DO_NOT_EDIT_WARNING)
file.write(_HTML_TEMPLATE % {
'index': index
})
file.close
def GenerateTests():
"""Generate all tests."""
filelist = []
for ii in range(len(_GROUPS)):
filename = GenerateFilename(_GROUPS[ii])
filelist.append(filename)
WriteTest(filename, ii)
return filelist
def GenerateTestList(filelist):
file = open("00_test_list.txt", "wb")
file.write('\n'.join(filelist))
file.close
def main(argv):
"""This is the main function."""
filelist = GenerateTests()
GenerateTestList(filelist)
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))