Access Control is now enabled for Gitlab Pages so you can now restrict Pages to authorized users only. If needed, make your website publicly available : Navigate to your project's Settings > General > Visibility and select Everyone in pages section.

Commit b77a2bf7 authored by Tony Licata's avatar Tony Licata

Added new unittests, cleaned code

parent e6b49d1a
......@@ -28,6 +28,11 @@ public abstract class ProloGraalTypes {
}
/**
* implicit Truffle casts, currently not working
* taken from: https://github.com/graalvm/simplelanguage/blob/master/language/src/main/java/com/oracle/truffle/sl/nodes/SLTypes.java
*/
/*
@ImplicitCast
public static ProloGraalTerm castVarToTerm(ProloGraalVariable value) {
......
......@@ -33,8 +33,7 @@ public abstract class ProloGraalPolyglotEvalHeadNode extends ProloGraalTernaryHe
@Specialization(guards = {"center.isAtom()","right.isAtom()"})
@CompilerDirectives.TruffleBoundary
public ProloGraalBoolean returnValue(ProloGraalTerm left, ProloGraalTerm center, ProloGraalTerm right) {
Context context;
context = Context.newBuilder().allowAllAccess(true).build();
Context context = Context.newBuilder().allowAllAccess(true).build();
Value res = context.eval(center.asAtom().getName(),right.asAtom().getName());
ProloGraalTerm resAsTerm = genericValueToProloGraalTerm(res);
if(resAsTerm != null && left.unify(resAsTerm)){
......
consult('./tests/07_consult_clauses.pl.excluded').
'='(Clauses,~test(10). test(12). string(abc).~), consultstring(Clauses).
'='(Ten,10), test(TenFromClause), '='(Ten, TenFromClause).
\ No newline at end of file
hello(world).
added_clause(A).
test(10), test(12), string(abc).
test(14).
consultstring('test(14).').
test(14).
\ No newline at end of file
......@@ -3,9 +3,18 @@ yes
% '='(Clauses,~test(10). test(12). string(abc).~), consultstring(Clauses).
Clauses = test(10). test(12). string(abc).
yes
%'='(Ten,10), test(TenFromClause), '='(Ten, TenFromClause).
Ten = 10
TenFromClause = 10
% hello(world).
yes
% addedClause(A).
A = test
yes
% test(10), test(12), string(abc).
yes
% test(14).
no
% consultstring('test(14).').
yes
% test(14).
yes
% EOF
yes
\ No newline at end of file
'='(A,10), '='(B,5), '>'(A,B).
'<'(1,2).
'<'(2,1).
'<'(2,2).
'>'(1,2).
'>'(2,1).
'>'(2,2).
'=<'(1,2).
'=<'(2,1).
'=<'(2,2).
'>='(1,2).
'>='(2,1).
'>='(2,2).
'<'(1,1.000000000001).
\ No newline at end of file
% '='(A,10), '='(B,5), '>'(A,B).
A = 10
B = 5
yes
% '<'(1,2).
yes
% '<'(2,1).
no
% '<'(2,2).
no
% '>'(1,2).
no
% '>'(2,1).
yes
% '>'(2,2).
no
% '=<'(1,2).
yes
% '=<'(2,1).
no
% '=<'(2,2).
yes
% '>='(1,2).
no
% '>='(2,1).
yes
% '>='(2,2).
yes
% '<'(1,1.000000000001).
yes
% EOF
yes
\ No newline at end of file
% This test checks the following builtins :
% =/2, >/2, >=/2, </2, =</2
useinterpreter.
\ No newline at end of file
'='(A,log(exp(10))), is(10,A).
is(3,'+'(2,1)).
is(1,'-'(2,1)).
is(8,'*'(4,2)).
is(2,'/'(4,2)).
is(1024,'**'(2,10)).
is(27,'^'(3,3)).
is(1,mod(21,2)).
is(2,abs('-'(0,2))).
is(2,sqrt(4)).
is(A,'-'(0,1)), is(A,sign('-'(0,271))).
is(A, sqrt('*'('+'('-'(log(exp(10)),5),13),2))), '='(B, 6), '='(B, A).
\ No newline at end of file
% '='(A,log(exp(10))), is(10,A).
A = log/1(exp/1(10))
yes
% is(3,'+'(2,1)).
yes
% is(1,'-'(2,1)).
yes
% is(8,'*'(4,2)).
yes
% is(2,'/'(4,2)).
yes
% is(1024,'**'(2,10)).
yes
% is(27,'^'(3,3)).
yes
% is(1,mod(21,2)).
yes
% is(2,abs('-'(0,2))).
yes
% is(2,sqrt(4)).
yes
% is(A,'-'(0,1)), is(A,sign('-'(0,271))).
A = -1
yes
% is(A, sqrt('*'('+'('-'(log(exp(10)),5),13),2))), '='(B, 6), '='(B, A).
A = 6.0
B = 6
yes
% EOF
yes
\ No newline at end of file
% This test checks the following builtins :
% - is/2
% - =/2, to bind variables
useinterpreter.
\ No newline at end of file
polyglot_eval(A, 'js', ~ let a = 0; for(let i = 0; i <= 10; i++){ a+=i; } a; ~), '='(A,55).
polyglot_eval(A, 'js', ~ let a = 'hello'; let b = ' world'; a+b; ~), '='(A,'hello world').
polyglot_eval(A, 'js', ~ 2 < 1 ~), '='(A,'false').
% polyglot_eval(A, 'js', ~ let a = 0; for(let i = 0; i <= 10; i++){ a+=i; } a; ~), '='(A,55).
A = 55
yes
% polyglot_eval(A, 'js', ~ let a = 'hello'; let b = ' world'; a+b; ~), '='(A,'hello world').
A = hello world
yes
% polyglot_eval(A, 'js', ~ 2 < 1 ~), '='(A,'false').
A = false
yes
% EOF
yes
\ No newline at end of file
% This test checks the following builtins :
% - polyglot_eval/3
useinterpreter.
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment