Skip to content

Commit

Permalink
Misc extra tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mikera committed Dec 20, 2024
1 parent c72a0ff commit 09d8d02
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
1 change: 0 additions & 1 deletion convex-core/src/main/java/convex/core/cvm/Syntax.java
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ public void validateStructure() throws InvalidDataException {
if (datum instanceof Syntax) {
throw new InvalidDataException("Cannot double-wrap a Syntax value",this);
}
if (!datum.isCVMValue()) throw new InvalidDataException("Syntax can only wrap CVM values",this);
}
}

Expand Down
15 changes: 15 additions & 0 deletions convex-core/src/test/java/convex/core/data/SyntaxTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.IOException;

import org.junit.jupiter.api.Test;

import convex.core.cvm.Address;
Expand Down Expand Up @@ -75,6 +77,19 @@ private void doSyntaxTest(Syntax s) {

}

@Test public void testSytaxEncode() throws BadFormatException, IOException {

Syntax s=Reader.read("^{} {#1 -9223372036854775808}");
Blob b=s.getEncoding();
Syntax s2=Format.read(b);

assertEquals(s,s2);

Ref<Syntax> pref=Cells.persist(s).getRef();
assertEquals(s,pref.getValue());

}

@Test public void testSyntaxPrintRegression() {
String s="^{} 0xa89e59cc8ab9fc6a13785a37938c85b306b24663415effc01063a6e25ef52ebcd3647d3a77e0a33908a372146fdccab6";
int n=s.length();
Expand Down

0 comments on commit 09d8d02

Please sign in to comment.