Skip to content

Commit a1b92a2

Browse files
committed
Misc tests and checks
1 parent 0a4038c commit a1b92a2

File tree

12 files changed

+24
-18
lines changed

12 files changed

+24
-18
lines changed

convex-core/src/main/java/convex/core/cvm/ARecordGeneric.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ protected void validateCell() throws InvalidDataException {
124124
Cells.validateCell(values);
125125
}
126126

127-
protected void validateStructure() throws InvalidDataException {
127+
public void validateStructure() throws InvalidDataException {
128128
super.validateStructure();
129129
if (values.count()!=format.count()) {
130130
throw new InvalidDataException("Expected "+format.count()+ "Record values but was: "+values.count(),this);

convex-core/src/main/java/convex/core/cvm/CVMEncoder.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ public ACell read(Blob encoding,int offset) throws BadFormatException {
2323
protected ACell readExtension(byte tag, Blob blob, int offset) throws BadFormatException {
2424
// We expect a VLQ Count following the tag
2525
long code=Format.readVLQCount(blob,offset+1);
26-
if (tag == CVMTag.CORE_DEF) return Core.fromCode(code);
26+
if (tag == CVMTag.CORE_DEF) {
27+
ACell cc=Core.fromCode(code);
28+
if (cc!=null) return cc;
29+
}
2730
if (tag == CVMTag.ADDRESS) return Address.create(code);
2831

2932
return ExtensionValue.create(tag, code);

convex-core/src/main/java/convex/core/cvm/Syntax.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ public void validateStructure() throws InvalidDataException {
244244
throw new InvalidDataException("Cannot double-wrap a Syntax value",this);
245245
}
246246
}
247+
meta.validateStructure();
247248
}
248249

249250
@Override

convex-core/src/main/java/convex/core/data/AArrayBlob.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,8 @@ public void validateCell() throws InvalidDataException {
370370
}
371371

372372
@Override
373-
protected void validateStructure() {
373+
public void validateStructure() throws InvalidDataException {
374+
super.validateStructure();
374375
// nothing to do by default
375376
}
376377

convex-core/src/main/java/convex/core/data/ACAD3Record.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ public void validateCell() throws InvalidDataException {
3131
}
3232

3333
@Override
34-
protected void validateStructure() throws InvalidDataException {
34+
public void validateStructure() throws InvalidDataException {
35+
super.validateStructure();
3536
// Nothing to do, any child refs are valid
3637
}
3738

convex-core/src/main/java/convex/core/data/ACell.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public void validate() throws InvalidDataException {
5252
*
5353
* @throws InvalidDataException If the Cell is invalid
5454
*/
55-
protected void validateStructure() throws InvalidDataException {
55+
public void validateStructure() throws InvalidDataException {
5656
// nothing by default
5757
}
5858

convex-core/src/main/java/convex/core/data/CodedValue.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public void validateCell() throws InvalidDataException {
3232
}
3333

3434
@Override
35-
protected void validateStructure() throws InvalidDataException {
35+
public void validateStructure() throws InvalidDataException {
3636
// Nothing to do, any child refs are valid
3737
}
3838

convex-core/src/main/java/convex/core/data/Format.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,10 @@ private static ACell readExtension(byte tag, Blob blob, int offset) throws BadFo
526526
// We expect a VLQ Count following the tag
527527
long code=readVLQCount(blob,offset+1);
528528

529-
if (tag == CVMTag.CORE_DEF) return Core.fromCode(code);
529+
if (tag == CVMTag.CORE_DEF) {
530+
ACell cc=Core.fromCode(code);
531+
if (cc!=null) return cc;
532+
}
530533

531534
if ((tag == CVMTag.OP_SPECIAL)&&(code<Special.NUM_SPECIALS)) {
532535
Special<?> spec= Special.create((int)code);

convex-core/src/main/java/convex/core/data/VectorTree.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ protected void validateCell() throws InvalidDataException {
685685
}
686686

687687
@Override
688-
protected void validateStructure() throws InvalidDataException {
688+
public void validateStructure() throws InvalidDataException {
689689
super.validateStructure();
690690
long c = 0;
691691
int blen = children.length;

convex-core/src/main/java/convex/core/lang/Core.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3009,14 +3009,12 @@ private static Context applyDocumentation(Context ctx) throws IOException {
30093009
* Read a Core definition from an encoding
30103010
* @param b Blob containing encoding
30113011
* @param pos Position to read Core code function
3012-
* @return Singleton cell representing the Core value
3013-
* @throws BadFormatException In case of encoding error
3012+
* @return Singleton cell representing the Core value, or null if not defined
30143013
*/
30153014
public static ACell fromCode(long code) throws BadFormatException {
3016-
if (code <0 || code>=CODE_MAP.length) throw new BadFormatException("Core code out of range: "+code);
3015+
if (code <0 || code>=CODE_MAP.length) return null;
30173016

30183017
ACell o = CODE_MAP[(int)code];
3019-
if (o == null) throw new BadFormatException("Core code definition not found: " + code);
30203018
return o;
30213019
}
30223020

0 commit comments

Comments
 (0)