MCPcopy Create free account
hub / github.com/ElementsProject/elements / test_occursCheck

Function test_occursCheck

src/simplicity/test.c:325–352  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

323}
324
325static void test_occursCheck(void) {
326 printf("Test occursCheck\n");
327 /* The untyped Simplicity term (case (drop iden) iden) ought to cause an occurs check failure. */
328 const unsigned char buf[] = { 0xc1, 0x07, 0x20, 0x30 };
329 dag_node* dag;
330 combinator_counters census;
331 int_fast32_t len;
332 {
333 bitstream stream = initializeBitstream(buf, sizeof(buf));
334 len = simplicity_decodeMallocDag(&dag, simplicity_elements_decodeJet, &census, &stream);
335 }
336 if (!dag) {
337 simplicity_assert(len < 0);
338 printf("Error parsing dag: %" PRIdFAST32 "\n", len);
339 } else {
340 type* type_dag;
341 simplicity_assert(0 < len);
342 if (SIMPLICITY_ERR_TYPE_INFERENCE_OCCURS_CHECK == simplicity_mallocTypeInference(&type_dag, simplicity_elements_mallocBoundVars, dag, (uint_fast32_t)len, &census) &&
343 !type_dag) {
344 successes++;
345 } else {
346 printf("Unexpected occurs check success\n");
347 failures++;
348 }
349 simplicity_free(type_dag);
350 }
351 simplicity_free(dag);
352}
353
354static void test_elements(void) {
355 unsigned char cmr[32], amr[32];

Callers 1

mainFunction · 0.85

Calls 4

printfFunction · 0.85
initializeBitstreamFunction · 0.85

Tested by

no test coverage detected