Skip to content

Commit

Permalink
Tests for linkage display and some love to readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
Willyboar committed May 19, 2023
1 parent 7691205 commit ae8b2ea
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 6 deletions.
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
# glove


<center>
<img src="https://github.com/Willyboar/glove/assets/22755228/bfd9673f-a105-4083-82d8-84bf4b0ff071">

## 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
</center>


## 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
Expand Down
37 changes: 37 additions & 0 deletions test/glove_test.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -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("")
}

0 comments on commit ae8b2ea

Please sign in to comment.