From ae8b2ea40a97281e16ecef2094afda8e243427a5 Mon Sep 17 00:00:00 2001 From: Willyboar Date: Fri, 19 May 2023 20:30:20 +0300 Subject: [PATCH] Tests for linkage display and some love to readme. --- README.md | 15 +++++++++------ test/glove_test.gleam | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 508deb2..2430b48 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,23 @@ -# glove - - +
+ ## Don't Use it (WIP) [![Package Version](https://img.shields.io/hexpm/v/glove)](https://hex.pm/packages/glove) [![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/glove/) -A Gleam project + +A Gleam library to generate QBE IR code +
+ ## Quick start +TODO: Look to examples + +## Run the tests ```sh -gleam run # Run the project gleam test # Run the tests -gleam shell # Run an Erlang shell ``` ## Installation diff --git a/test/glove_test.gleam b/test/glove_test.gleam index 2ab79b3..54d837c 100644 --- a/test/glove_test.gleam +++ b/test/glove_test.gleam @@ -107,3 +107,40 @@ pub fn display_block_test() { |> glove.display_block |> should.equal("label:\n%temp1 =w add %a, %b\nret %temp1") } + +// Tests for QBE.Linkage Display +pub fn display_linkage_test() { + // Test case with exported and section + let linkage1 = + glove.Linkage( + exported: True, + section: Some("mysection"), + secflags: Some("flags"), + ) + linkage1 + |> glove.display_linkage + |> should.equal("export section \"mysection\" \"flags\" ") + + // Test case with exported and no section + let linkage2 = glove.Linkage(exported: True, section: None, secflags: None) + linkage2 + |> glove.display_linkage + |> should.equal("export ") + + // Test case with no exported and section + let linkage3 = + glove.Linkage( + exported: False, + section: Some("othersection"), + secflags: None, + ) + linkage3 + |> glove.display_linkage + |> should.equal("section \"othersection\" ") + + // Test case with no exported and no section + let linkage4 = glove.Linkage(exported: False, section: None, secflags: None) + linkage4 + |> glove.display_linkage + |> should.equal("") +}