From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id ENvKA2N4AmeRXQAA62LTzQ:P1 (envelope-from ) for ; Sun, 06 Oct 2024 13:45:39 +0200 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id ENvKA2N4AmeRXQAA62LTzQ (envelope-from ) for ; Sun, 06 Oct 2024 13:45:39 +0200 X-Envelope-To: patches@johnnyrichard.com Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=lists.sr.ht header.s=20240113 header.b=SCY5gMDU; dkim=pass header.d=johnnyrichard.com header.s=key1 header.b=grcXzElM; spf=pass (aspmx1.migadu.com: domain of lists@sr.ht designates 46.23.81.152 as permitted sender) smtp.mailfrom=lists@sr.ht; dmarc=pass (policy=quarantine) header.from=johnnyrichard.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=johnnyrichard.com; s=key1; t=1728215138; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:list-id: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=xNOMP2Hh05oPDGcXvaXVDNuigsT1i+l47tQ/ti+Lqeg=; b=5cjy1EQLJSzsinYOEnogotKrD00pIdQaCMeRHq+NS9yclbs9JVsQWuH292w3YGVHSd3jin UmrM8khi/cXIE1tlT/cGggBH4ojObAU96QZxO22UenJOwc/XB6VCQE30TQ7Hnmdl5c7rMY I/vyCeV4ptk/D0AgYqNZpOR4Bp/DczgwyEHHCNnKQaLMSrNkyUOyl5KWDKz+edtp/+gvOH 4I/jRgTheFOB8QE0dmxjP+37Fd/6Z23rrM1/g7gSfZVTimpWcHpOeFu5NhIiG51mDhDSLN xoCLARDsACZgMbsVbw3NSGDCdnFdgig7811ntErcnw2oSntJokv8AeMvIGgDIA== ARC-Seal: i=1; s=key1; d=johnnyrichard.com; t=1728215138; a=rsa-sha256; cv=none; b=g9uQt7jHapz9DaJ5d7JZL9tPJW0mQ5aD1z62IXwQd8fK9bVCcUqxkywgl4tiAjR5/jIa1n XDNCkyf8mqgVfCX2EFWdYP221rjjdoz2VShlOc5itFH2h7kXAqLidzFrsQ4sjFArMZ4ePJ BUEpSGkU51Mf3taWYiCALBq3ifDj0Cz8u33YP4gHY9IZByX7ANBuJ1ShqcylKzzvwUC8B7 5tV+FWBIX9Zq7sJO01/W/LwO6B2wPguuhA1s+ZpYPh5qKKt3Ctl7q7UJoNOM2L3Gh3IhlX mHCm4rcB659sk99AiLk6f4WFrosfySBJi8/8wvVj5XmAatGyAgy43NHGUi61eA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=lists.sr.ht header.s=20240113 header.b=SCY5gMDU; dkim=pass header.d=johnnyrichard.com header.s=key1 header.b=grcXzElM; spf=pass (aspmx1.migadu.com: domain of lists@sr.ht designates 46.23.81.152 as permitted sender) smtp.mailfrom=lists@sr.ht; dmarc=pass (policy=quarantine) header.from=johnnyrichard.com Received: from mail-a.sr.ht (mail-a.sr.ht [46.23.81.152]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id A303853DF4 for ; Sun, 06 Oct 2024 13:45:35 +0200 (CEST) DKIM-Signature: a=rsa-sha256; bh=Fogg/qhVbsGdYfCwNOjN5YelnhLNSRbvtpy6EnTu7A4=; c=simple/simple; d=lists.sr.ht; h=From:To:Cc:Subject:Date:List-Unsubscribe:List-Subscribe:List-Archive:List-Post:List-ID; q=dns/txt; s=20240113; t=1728215135; v=1; b=SCY5gMDU3F+049A+P+F002swOF44JpMOCKKDXjRO0QYZwncuWr9rmlacHndzboiVFN8jvHaR PAWinPcuB2PprhZNRkgd4S3ZVTGGoJeTfCl+XaQQJ+r5rVd6pqLGpOQnFgmLPQ2OPwiU6xndvCo LtA/IYnSKJ7jov4yQ6mTStMQhk4QjKfCl7Ro/3e/RA8DeY0T3qXK6/IqPcSyR9t41O0MLOLgj2R eJjgBBup5xApbIWb5Vk5eQBwDF3zBcNOnmY/ndJyvFzj8RKo7F8qXzgRnPwbRxVzpYcgv+3J4gq qzdW4xvKlbU39VPke8R9eMzS4DTGBRZg20gV+jVlh70DQ== Received: from lists.sr.ht (unknown [46.23.81.154]) by mail-a.sr.ht (Postfix) with ESMTPSA id 2CAF5201D8 for ; Sun, 06 Oct 2024 11:45:35 +0000 (UTC) Received: from out-187.mta0.migadu.com (out-187.mta0.migadu.com [91.218.175.187]) by mail-a.sr.ht (Postfix) with ESMTPS id 5EA61201AD for <~johnnyrichard/olang-devel@lists.sr.ht>; Sun, 06 Oct 2024 11:45:34 +0000 (UTC) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=johnnyrichard.com; s=key1; t=1728215133; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=xNOMP2Hh05oPDGcXvaXVDNuigsT1i+l47tQ/ti+Lqeg=; b=grcXzElMCcC1ylKTl56L2M898F9MdR+3Y1Fapk1j8iSGy2vMEifD4jyIPeX73Ynk+0d0TA GL4tr5cjtzdLoQGmdb/IaERcNBvq1mq5O7wASWp720H0C7/mAaQNO3OOatZA7HHSF1rNhq TK6plXL+55CAmccvTIkRuhW+LNZm8muWmj90iRWCsPubWJB+6sM2QJWVjjXEWO6Wyp8gHo ggZTVWfcGFfXU1OmshBFguEmdwkoYKJRsQg/N6eYNlX1SSwJHtl6Sk/N38taUv5c0ZcYn0 q9BDS2+ykQk5FtbitWeyWO5l72cagBKQfv15LAYWz5p/5vnXJ4tsIwxWr+/H6Q== From: Johnny Richard To: ~johnnyrichard/olang-devel@lists.sr.ht Cc: Johnny Richard Subject: [PATCH olang v1] chore: parser: remove old unit test for parsing Date: Sun, 6 Oct 2024 15:44:26 +0200 Message-ID: <20241006134454.77167-1-johnny@johnnyrichard.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Sourcehut-Patchset-Status: PROPOSED List-Unsubscribe: List-Subscribe: List-Archive: Archived-At: List-Post: List-ID: ~johnnyrichard/olang-devel <~johnnyrichard/olang-devel.lists.sr.ht> Sender: ~johnnyrichard/olang-devel <~johnnyrichard/olang-devel@lists.sr.ht> X-Migadu-Flow: FLOW_IN X-Migadu-Country: NL X-Migadu-Spam-Score: -4.92 X-Spam-Score: -4.92 X-Migadu-Queue-Id: A303853DF4 X-Migadu-Scanner: mx13.migadu.com X-TUID: x6Kotdpb0Fgd We have introduced a new way of testing the ast output from the parser, this test does not longer add value to the test suite. Signed-off-by: Johnny Richard --- tests/unit/parser_test.c | 97 ---------------------------------------- 1 file changed, 97 deletions(-) delete mode 100644 tests/unit/parser_test.c diff --git a/tests/unit/parser_test.c b/tests/unit/parser_test.c deleted file mode 100644 index c834261..0000000 --- a/tests/unit/parser_test.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (C) 2024 olang maintainers - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -#define MUNIT_ENABLE_ASSERT_ALIASES - -#include "arena.h" -#include "ast.h" -#include "lexer.h" -#include "list.h" -#include "munit.h" -#include "parser.h" -#include "string_view.h" - -#define ARENA_CAPACITY (1024 * 1024) - -static MunitResult -parse_translation_unit_test(const MunitParameter params[], void *user_data_or_fixture) -{ - arena_t arena = arena_new(ARENA_CAPACITY); - - char *filepath = "main.0"; - char *source_value = "fn main(): u32 {\n\treturn 69\n}"; - - lexer_t lexer; - string_view_t code = { .chars = source_value, .size = strlen(source_value) }; - lexer_init(&lexer, (source_code_t){ .code = code, .filepath = filepath }); - - parser_t parser; - parser_init(&parser, &lexer, &arena); - - ast_node_t *translation_unit_node = parser_parse_translation_unit(&parser); - assert_not_null(translation_unit_node); - assert_uint(translation_unit_node->kind, ==, AST_NODE_TRANSLATION_UNIT); - - ast_translation_unit_t translation_unit = translation_unit_node->as_translation_unit; - - assert_uint(list_size(translation_unit.decls), ==, 1); - - ast_node_t *fn_node = (ast_node_t *)list_head(translation_unit.decls)->value; - - assert_not_null(fn_node); - assert_uint(fn_node->kind, ==, AST_NODE_FN_DEF); - - ast_fn_definition_t fn = fn_node->as_fn_def; - assert_memory_equal(fn.id.size, fn.id.chars, "main"); - assert_memory_equal(fn.return_type.size, fn.return_type.chars, "u32"); - - ast_node_t *block = fn.block; - assert_not_null(block); - - assert_uint(block->kind, ==, AST_NODE_BLOCK); - assert_uint(list_size(block->as_block.nodes), ==, 1); - list_item_t *block_item = list_get(block->as_block.nodes, 0); - assert_not_null(block_item); - assert_not_null(block_item->value); - - ast_node_t *node = (ast_node_t *)block_item->value; - assert_not_null(node); - assert_uint(node->kind, ==, AST_NODE_RETURN_STMT); - - ast_node_t *number_node = node->as_return_stmt.expr; - assert_not_null(number_node); - assert_uint(number_node->kind, ==, AST_NODE_LITERAL); - assert_uint(number_node->as_literal.kind, ==, AST_LITERAL_U32); - assert_uint(number_node->as_literal.as_u32, ==, 69); - - arena_free(&arena); - - return MUNIT_OK; -} - -static MunitTest tests[] = { - { "/parse_translation_unit", parse_translation_unit_test, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL }, - { NULL, NULL, NULL, NULL, MUNIT_TEST_OPTION_NONE, NULL } -}; - -static const MunitSuite suite = { "/parser", tests, NULL, 1, MUNIT_SUITE_OPTION_NONE }; - -int -main(int argc, char *argv[]) -{ - return munit_suite_main(&suite, NULL, argc, argv); - return EXIT_SUCCESS; -} base-commit: c4f7fa1e4ccd7c9d9e2d9f835feefdbd9c312c2c -- 2.46.0