private JPRADriver( final Path in_base, final JPRACheckerCapabilitiesType in_caps) { this.global = GlobalContexts.newContext(new Loader(in_base, in_caps)); }
private JPRADriver( final Path in_base, final JPRACheckerCapabilitiesType in_caps) { this.global = GlobalContexts.newContext(new Loader(in_base, in_caps)); }
@Test public final void testTypeExprIntegerUnsigned_0() throws Exception { final JPRAParserType p = this.newParser(); final GlobalContextType c = GlobalContexts.newContext(new AlwaysEmptyLoader()); final JPRAResolverType r = this.newResolver(c); final StatementCommandType<IdentifierType, Untyped> ex = r.resolveCommandType( StatementCommandType.class.cast( p.parseStatement( this.newStringSExpr("(:type [integer unsigned 32])")))); final TypeExprIntegerUnsigned<IdentifierType, Untyped> ee = TypeExprIntegerUnsigned.class.cast(ex.getExpression()); JPRAResolverContract.checkSizeExpressionConstant( ee.getSize(), BigInteger.valueOf(32L)); }
@Test public final void testTypeDeclPackedNoCurrent() throws Exception { final JPRAParserType p = this.newParser(); final GlobalContextType c = GlobalContexts.newContext(new AlwaysEmptyLoader()); final JPRAResolverType r = this.newResolver(c); this.expected.expect( new JPRACompilerResolverExceptionMatcher( JPRAResolverErrorCode.NO_CURRENT_PACKAGE)); r.resolveTypeDeclaration( TypeDeclType.class.cast( p.parseStatement(this.newStringSExpr("(packed T ())")))); }
@Test public final void testTypeDeclRecordNoCurrent() throws Exception { final JPRAParserType p = this.newParser(); final GlobalContextType c = GlobalContexts.newContext(new AlwaysEmptyLoader()); final JPRAResolverType r = this.newResolver(c); this.expected.expect( new JPRACompilerResolverExceptionMatcher( JPRAResolverErrorCode.NO_CURRENT_PACKAGE)); r.resolveTypeDeclaration( TypeDeclType.class.cast( p.parseStatement(this.newStringSExpr("(record T ())")))); }
@Test public final void testPackageEndNoCurrent() throws Exception { final JPRAParserType p = this.newParser(); final GlobalContextType c = GlobalContexts.newContext(new AlwaysEmptyLoader()); final JPRAResolverType r = this.newResolver(c); this.expected.expect( new JPRACompilerResolverExceptionMatcher( JPRAResolverErrorCode.NO_CURRENT_PACKAGE)); r.resolvePackageEnd( StatementPackageEnd.class.cast( p.parseStatement(this.newStringSExpr("(package-end)")))); }
@Test public final void testPackageImportNoCurrent() throws Exception { final JPRAParserType p = this.newParser(); final GlobalContextType c = GlobalContexts.newContext(new AlwaysEmptyLoader()); final JPRAResolverType r = this.newResolver(c); this.expected.expect( new JPRACompilerResolverExceptionMatcher( JPRAResolverErrorCode.NO_CURRENT_PACKAGE)); r.resolvePackageImport( StatementPackageImport.class.cast( p.parseStatement(this.newStringSExpr("(import x.y.z as q)")))); }
@Test public final void testTypeExprName_Error0() throws Exception { final JPRAParserType p = this.newParser(); final GlobalContextType c = GlobalContexts.newContext(new AlwaysEmptyLoader()); final JPRAResolverType r = this.newResolver(c); this.expected.expect( new JPRACompilerResolverExceptionMatcher( JPRAResolverErrorCode.TYPE_NONEXISTENT)); r.resolveCommandType( StatementCommandType.class.cast( p.parseStatement(this.newStringSExpr("(:type T)")))); }
@Test public final void testRecordTypeExprBooleanSet_0() throws Exception { final JPRAParserType p = this.newParser(); final GlobalContextType c = GlobalContexts.newContext(new AlwaysEmptyLoader()); final JPRAResolverType r = this.newResolver(c); final JPRACheckerType ch = this.newChecker( c, JPRACheckerStandardCapabilities.newCapabilities()); final TypeExprType<IdentifierType, Untyped> te = r.resolveTypeExpression( p.parseTypeExpression( this.newStringSExpr("(boolean-set 1 [x y z])"))); final TypeExprBooleanSet<IdentifierType, TType> e = TypeExprBooleanSet.class.cast(ch.checkTypeExpression(te)); final TBooleanSet ta = TBooleanSet.class.cast(e.getType()); Assert.assertEquals(BigInteger.valueOf(8L), ta.getSizeInBits().getValue()); }
@Test public final void testRecordTypeExprFloatSizeSupported() throws Exception { final JPRAParserType p = this.newParser(); final GlobalContextType c = GlobalContexts.newContext(new AlwaysEmptyLoader()); final JPRAResolverType r = this.newResolver(c); final JPRACheckerType ch = this.newChecker( c, JPRACheckerStandardCapabilities.newCapabilities()); final TypeExprType<IdentifierType, Untyped> te = r.resolveTypeExpression( p.parseTypeExpression( this.newStringSExpr("(float 32)"))); final TypeExprFloat<IdentifierType, TType> e = TypeExprFloat.class.cast(ch.checkTypeExpression(te)); final TFloat ti = TFloat.class.cast(e.getType()); Assert.assertEquals(BigInteger.valueOf(32L), ti.getSizeInBits().getValue()); }
@Test public final void testPackageImportNonexistent() throws Exception { final JPRAParserType p = this.newParser(); final GlobalContextType c = GlobalContexts.newContext(new NoPackagesLoader()); final JPRAResolverType r = this.newResolver(c); r.resolvePackageBegin( StatementPackageBegin.class.cast( p.parseStatement(this.newStringSExpr("(package-begin a.b.c)")))); this.expected.expect( new JPRACompilerResolverExceptionMatcher( JPRAResolverErrorCode.PACKAGE_LOADING_ERROR)); r.resolvePackageImport( StatementPackageImport.class.cast( p.parseStatement(this.newStringSExpr("(import x.a as q)")))); }
@Test public final void testPackageExpected() throws Exception { final JPRAParserType p = this.newParser(); final GlobalContextType c = GlobalContexts.newContext(new AlwaysEmptyLoader()); final JPRAResolverType r = this.newResolverForPackage( c, PackageNameQualified.of( PackageNameUnqualified.of("x"), PackageNameUnqualified.of("y"), PackageNameUnqualified.of("z"))); this.expected.expect( new JPRACompilerResolverExceptionMatcher( JPRAResolverErrorCode.EXPECTED_PACKAGE)); r.resolveEOF(Optional.empty()); }
@Test public final void testPackageBegin() throws Exception { final JPRAParserType p = this.newParser(); final GlobalContextType c = GlobalContexts.newContext(new AlwaysEmptyLoader()); final JPRAResolverType r = this.newResolver(c); final StatementPackageBegin<Unresolved, Untyped> pb = StatementPackageBegin.class.cast( p.parseStatement(this.newStringSExpr("(package-begin x.y.z)"))); final StatementPackageBegin<IdentifierType, Untyped> rp = r.resolvePackageBegin(pb); Assert.assertEquals(pb.getPackageName(), rp.getPackageName()); Assert.assertEquals(pb.getLexicalInformation(), rp.getLexicalInformation()); }
@Test public final void testRecordTypeExprBooleanSet_Error1() throws Exception { final JPRAParserType p = this.newParser(); final GlobalContextType c = GlobalContexts.newContext(new AlwaysEmptyLoader()); final JPRAResolverType r = this.newResolver(c); final JPRACheckerType ch = this.newChecker( c, JPRACheckerStandardCapabilities.newCapabilities()); final TypeExprType<IdentifierType, Untyped> te = r.resolveTypeExpression( p.parseTypeExpression( this.newStringSExpr("(boolean-set 1 [f0 f1 f2 f3 f4 f5 f6 f7 f8])"))); this.expected.expect( new JPRACompilerCheckerExceptionMatcher( JPRACheckerErrorCode.BOOLEAN_SET_SIZE_TOO_SMALL)); ch.checkTypeExpression(te); }
@Test public final void testTypeExprVectorNonScalar() throws Exception { final JPRAParserType p = this.newParser(); final GlobalContextType c = GlobalContexts.newContext(new AlwaysEmptyLoader()); final JPRAResolverType r = this.newResolver(c); final JPRACheckerType ch = this.newChecker( c, JPRACheckerStandardCapabilities.newCapabilities()); final TypeExprType<IdentifierType, Untyped> te = r.resolveTypeExpression( p.parseTypeExpression( this.newStringSExpr("(vector [boolean-set 1 (x)] 5)"))); this.expected.expect( new JPRACompilerCheckerExceptionMatcher( JPRACheckerErrorCode.VECTOR_NON_SCALAR_TYPE)); ch.checkTypeExpression(te); }
@Test public final void testTypeExprMatrixUnsupported() throws Exception { final JPRAParserType p = this.newParser(); final GlobalContextType c = GlobalContexts.newContext(new AlwaysEmptyLoader()); final JPRAResolverType r = this.newResolver(c); final JPRACheckerType ch = this.newChecker( c, JPRACheckerStandardCapabilities.newCapabilities()); final TypeExprType<IdentifierType, Untyped> te = r.resolveTypeExpression( p.parseTypeExpression( this.newStringSExpr("(matrix [float 32] 5 5)"))); this.expected.expect( new JPRACompilerCheckerExceptionMatcher( JPRACheckerErrorCode.MATRIX_SIZE_UNSUPPORTED)); ch.checkTypeExpression(te); }
@Test public final void testRecordTypeExprStringEncodingUnsupported() throws Exception { final JPRAParserType p = this.newParser(); final GlobalContextType c = GlobalContexts.newContext(new AlwaysEmptyLoader()); final JPRAResolverType r = this.newResolver(c); final JPRACheckerType ch = this.newChecker( c, JPRACheckerStandardCapabilities.newCapabilities()); final TypeExprType<IdentifierType, Untyped> te = r.resolveTypeExpression( p.parseTypeExpression( this.newStringSExpr("(string 32 \"unknown\")"))); this.expected.expect( new JPRACompilerCheckerExceptionMatcher( JPRACheckerErrorCode.STRING_ENCODING_UNSUPPORTED)); ch.checkTypeExpression(te); }
@Test public final void testTypeExprMatrixElementUnsupported_0() throws Exception { final JPRAParserType p = this.newParser(); final GlobalContextType c = GlobalContexts.newContext(new AlwaysEmptyLoader()); final JPRAResolverType r = this.newResolver(c); final JPRACheckerType ch = this.newChecker( c, JPRACheckerStandardCapabilities.newCapabilities()); final TypeExprType<IdentifierType, Untyped> te = r.resolveTypeExpression( p.parseTypeExpression( this.newStringSExpr("(matrix [float 16] 4 4)"))); this.expected.expect( new JPRACompilerCheckerExceptionMatcher( JPRACheckerErrorCode.MATRIX_SIZE_FLOAT_UNSUPPORTED)); ch.checkTypeExpression(te); }
@Test public final void testRecordTypeExprBooleanSet_Error0() throws Exception { final JPRAParserType p = this.newParser(); final GlobalContextType c = GlobalContexts.newContext(new AlwaysEmptyLoader()); final JPRAResolverType r = this.newResolver(c); final JPRACheckerType ch = this.newChecker( c, JPRACheckerStandardCapabilities.newCapabilities()); final TypeExprType<IdentifierType, Untyped> te = r.resolveTypeExpression( p.parseTypeExpression( this.newStringSExpr("(boolean-set 0 [x y z])"))); this.expected.expect( new JPRACompilerCheckerExceptionMatcher( JPRACheckerErrorCode.BOOLEAN_SET_SIZE_INVALID)); ch.checkTypeExpression(te); }
@Test public final void testTypeExprVectorSizeUnsupported() throws Exception { final JPRAParserType p = this.newParser(); final GlobalContextType c = GlobalContexts.newContext(new AlwaysEmptyLoader()); final JPRAResolverType r = this.newResolver(c); final JPRACheckerType ch = this.newChecker( c, JPRACheckerStandardCapabilities.newCapabilities()); final TypeExprType<IdentifierType, Untyped> te = r.resolveTypeExpression( p.parseTypeExpression( this.newStringSExpr("(vector [integer signed 32] 5)"))); this.expected.expect( new JPRACompilerCheckerExceptionMatcher( JPRACheckerErrorCode.VECTOR_SIZE_UNSUPPORTED)); ch.checkTypeExpression(te); }