Skip to content

Commit

Permalink
Improving test coverage [part 9]
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoejp committed Feb 17, 2025
1 parent 55c7cd0 commit 6b4a53e
Show file tree
Hide file tree
Showing 36 changed files with 593 additions and 191 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,4 @@ I'll be putting there tasks that people can contribute to; both in the compiler

Writing libraries in Lux will also help a lot in making this a more practical language for day to day use.

##### Copyright (c) 2014-2024 Eduardo Emilio Julián Pereyra. All rights reserved.
##### Copyright (c) 2014-2025 Eduardo Emilio Julián Pereyra. All rights reserved.
2 changes: 1 addition & 1 deletion documentation/bookmark/agriculture.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Reference

0. []()
0. [Top Farm Robots](https://www.topfarmrobots.com/)
0. [Soil.Spectroscopy](https://soilspectroscopy.org/)
0. [Agrivoltaics: Opportunities for Agriculture and Energy Transition](https://agri-pv.org/en/)

1 change: 1 addition & 0 deletions documentation/bookmark/business/funding.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Reference

0. [A different way to fund freedom-respecting software](https://contrapunctus.codeberg.page/blog/a-different-way-to-fund-freedom-respecting-software.html)
0. [More money if you do, more money if you don’t](https://longform.asmartbear.com/more-money/)

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Interoperability

0. []()
0. [How to Extend WebAssembly with Host Functions](https://www.secondstate.io/articles/extend-webassembly/)
0. [js-wasm: JavaScript and WebAssembly should be a joy to use together.](https://wasm.js.org/)

Expand Down Expand Up @@ -31,6 +30,7 @@
0. [The best WebAssembly runtime may be no runtime at all](https://00f.net/2023/12/11/webassembly-compilation-to-c/)
0. [just-in-time code generation within webassembly](https://wingolog.org/archives/2022/08/18/just-in-time-code-generation-within-webassembly)
0. [TeaVM: Build Fast, Modern Web Apps in Java](https://teavm.org/)
0. [Release 0.11.0: New WebAssembly backend](https://teavm.org/docs/release-notes/0.11.0.html)
0. [Recommendations when publishing a Wasm library](https://nickb.dev/blog/recommendations-when-publishing-a-wasm-library)
0. [Building host implementations for WebAssembly interfaces](https://radu-matei.com/blog/wasm-components-host-implementations/)
0. [WebAssembly Techniques to Speed Up Matrix Multiplication by 120x](https://jott.live/markdown/mm_wasm)
Expand Down
2 changes: 1 addition & 1 deletion documentation/bookmark/database.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

# Reference

0. []()
0. [Awesome Identifiers: Pick the best database primary key](https://adileo.github.io/awesome-identifiers/)
0. [The Slotted Counter Pattern](https://planetscale.com/blog/the-slotted-counter-pattern)
0. ["Temporal Databases for Streaming Architectures" by Jeremy Taylor and Jon Pither](https://www.youtube.com/watch?v=ykbYNBE-V3k)
0. ["Makings of a Modern ACID Compliant Distributed Database" by Attila Szegedi](https://www.youtube.com/watch?v=pn8mCeX3LDE)
Expand Down
4 changes: 4 additions & 0 deletions documentation/bookmark/economics/taxation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Reference

0. [Correcting the Top 10 Tax Myths](https://manhattan.institute/article/correcting-the-top-10-tax-myths)

4 changes: 4 additions & 0 deletions documentation/bookmark/name.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Reference

0. [Naming Conventions That Need to Die](https://willcrichton.net/notes/naming-conventions-that-need-to-die/)

2 changes: 2 additions & 0 deletions documentation/bookmark/open_source/funding.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Reference

0. [ecosyste.ms](https://funds.ecosyste.ms/)
0. [thanks.dev](https://thanks.dev/home)
0. [Drips: a decentralized toolkit for rewarding open source projects within your ecosystem](https://www.drips.network/)
0. [Sustain: Holding a space for conversations about sustaining Open Source](https://sustainoss.org/)
0. [Awesome OSS Monetization v1.1](https://github.com/PayDevs/awesome-oss-monetization)
Expand Down
4 changes: 4 additions & 0 deletions documentation/bookmark/open_source/maintenance.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Reference

0. [Do Not Fix Bugs Reported in Your Open Source Projects](https://code.dblock.org/2024/12/19/do-not-fix-bugs-reported-in-your-open-source-projects.html)

4 changes: 4 additions & 0 deletions documentation/bookmark/os__operating_system/android.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Reference

0. [Android Debug Bridge (ADB) Commands: A comprehensive guide to ADB commands for Android development, debugging, and device management](https://www.adb-command.top/)

4 changes: 4 additions & 0 deletions documentation/bookmark/quality.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Reference

0. [Most people don't care about quality](https://shkspr.mobi/blog/2024/12/most-people-dont-care-about-quality/)

1 change: 1 addition & 0 deletions documentation/bookmark/research.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Reference

0. [Software Papers as Software Modules: Towards a Culture of Reusable Results](https://github.com/andreas-zeller/papers-as-modules)
0. [ResearchRabbit](https://researchrabbitapp.com/)

5 changes: 5 additions & 0 deletions documentation/bookmark/testing/contract.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Reference

0. [test.contract](https://github.com/griffinbank/test.contract)
0. ["Breaking the bank with test contract" by Allen Rohner](https://youtu.be/dvHASrrQSzg)

2 changes: 1 addition & 1 deletion lux-mode/lux-mode.el
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
;;; lux-mode.el --- Major mode for Lux code -*- lexical-binding: t; -*-

;; Copyright © 2014-2022 Eduardo Julian
;; Copyright © 2014-2025 Eduardo Julian
;;
;; Authors: Eduardo Julian <[email protected]>
;; URL: https://github.com/LuxLang/lux/tree/master/lux-mode
Expand Down
12 changes: 8 additions & 4 deletions stdlib/source/library/lux.lux
Original file line number Diff line number Diff line change
Expand Up @@ -3220,13 +3220,17 @@

size
(let' [interpositions (.i64_-# 1 size)
new_size (.i64_+# interpositions size)]
new_size (.i64_+# interpositions size)
last_item (.i64_-# 1 new_size)]
(|> it
(list:mix' (function' (_ address item it)
(let' [address (.i64_+# address address)]
(|> it
(.array_has# address item)
(.array_has# (.i64_+# 1 address) delimiter))))
(if (.i64_=# last_item address)
(|> it
(.array_has# address item))
(|> it
(.array_has# address item)
(.array_has# (.i64_+# 1 address) delimiter)))))
(.array# new_size))
(.as# (for_any (_ it)
(-> ($ Array it)
Expand Down
20 changes: 10 additions & 10 deletions stdlib/source/library/lux/abstract/functor/pro.lux
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@
(=> cause' effect'))))
each)))

(every .public (Cartesian =>)
(every .public (Co_Cartesian =>)
(Interface
(is (for_any (_ head head' tail)
(-> (=> head head')
(=> (And head tail) (And head' tail))))
in_left)
(=> (Or head tail) (Or head' tail))))
when_left)
(is (for_any (_ tail tail' head)
(-> (=> tail tail')
(=> (And head tail) (And head tail'))))
in_right)))
(=> (Or head tail) (Or head tail'))))
when_right)))

(every .public (Co_Cartesian =>)
(every .public (Cartesian =>)
(Interface
(is (for_any (_ head head' tail)
(-> (=> head head')
(=> (Or head tail) (Or head' tail))))
when_left)
(=> (And head tail) (And head' tail))))
in_left)
(is (for_any (_ tail tail' head)
(-> (=> tail tail')
(=> (Or head tail) (Or head tail'))))
when_right)))
(=> (And head tail) (And head tail'))))
in_right)))

(every .public (Monoidal =>)
(Interface
Expand Down
4 changes: 2 additions & 2 deletions stdlib/source/library/lux/compiler/language/lux/syntax.lux
Original file line number Diff line number Diff line change
Expand Up @@ -462,12 +462,12 @@
[(!letE [source' full_name] (..full_name_projection the_globals aliases offset source)
(..success source' {tag where full_name}))]))

(error.the .public error_of_natural_is_not_valid)
(error.the .public not_a_number)

(the (natural_is_not_valid the_globals @)
(-> types_of_the_globals
(Projection Natural))
(..failure @ ..error_of_natural_is_not_valid))
(..failure @ ..not_a_number))

(template.with [,format ,name ,predicate ,suffix ,parent]
[(the (,name the_globals @)
Expand Down
1 change: 1 addition & 0 deletions stdlib/source/library/lux/control/concatenative.lux
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.

... "Techniques for embedding postfix languages in Haskell" by Chris Okasaki
(.using
[library
[lux (.except Alias Stack
Expand Down
20 changes: 10 additions & 10 deletions stdlib/source/library/lux/function.lux
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,6 @@
(the (each before after it)
(|>> before it after))))

(the .public cartesian
(pro.Cartesian Function)
(implementation
(the (in_left it)
(function (_ [cause extra])
[(it cause) extra]))
(the (in_right it)
(function (_ [extra cause])
[extra (it cause)]))))

(the .public co_cartesian
(pro.Co_Cartesian Function)
(implementation
Expand All @@ -74,6 +64,16 @@
{0b left} {0b left}
{1b right} {1b (it right)}))))

(the .public cartesian
(pro.Cartesian Function)
(implementation
(the (in_left it)
(function (_ [cause extra])
[(it cause) extra]))
(the (in_right it)
(function (_ [extra cause])
[extra (it cause)]))))

(the .public monoidal
(pro.Monoidal Function)
(implementation
Expand Down
1 change: 1 addition & 0 deletions stdlib/source/library/lux/logic/bit.lux
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.

... https://en.wikipedia.org/wiki/Boolean_algebra
(.using
[library
[lux (.except text)
Expand Down
49 changes: 22 additions & 27 deletions stdlib/source/library/lux/meta/binding.lux
Original file line number Diff line number Diff line change
Expand Up @@ -141,31 +141,26 @@
else
false))

(with_template [<name>]
[(the .public (<name> name)
(-> Name
(Meta [Bit Global]))
(monad.let //.monad
[name (..normal name)
.let [[normal_module normal_proper] name]]
(function (_ lux)
(when (is (Maybe [Bit Global])
(monad.let maybe.monad
[it (|> lux
(its .:modules)
(property.value normal_module))]
(|> it
(its .:definitions)
(property.value normal_proper))))
{.:Some exported?,definition}
{try.:Success [lux exported?,definition]}

_
{try.:Failure (..not_known lux name)}))))]

[[definition]
[default']
[alias']])
(the .public (definition name)
(-> Name
(Meta [Bit Global]))
(monad.let //.monad
[name (..normal name)
.let [[normal_module normal_proper] name]]
(function (_ lux)
(when (is (Maybe [Bit Global])
(monad.let maybe.monad
[it (|> lux
(its .:modules)
(property.value normal_module))]
(|> it
(its .:definitions)
(property.value normal_proper))))
{.:Some exported?,definition}
{try.:Success [lux exported?,definition]}

_
{try.:Failure (..not_known lux name)}))))

(the .public (export name)
(-> Name
Expand Down Expand Up @@ -196,7 +191,7 @@
(Meta Definition))
(monad.let [! //.monad]
[name (..normal name)
[exported? definition] (..default' name)]
[exported? definition] (..definition name)]
(when definition
{.:Definition it}
(if (default? (product.left it))
Expand All @@ -220,7 +215,7 @@
(Meta Name))
(monad.let [! //.monad]
[name (..normal name)
[exported? it] (..alias' name)]
[exported? it] (..definition name)]
(when it
{.:Alias it}
(pure it)
Expand Down
14 changes: 9 additions & 5 deletions stdlib/source/library/lux/world/net/http/client.lux
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@
(ffi.the java/net/HttpURLConnection
"[1]:[0]"
(setRequestMethod [java/lang/String] "io" "try" void)
(getResponseCode [] "io" "try" int))
(getResponseCode [] "io" "try" int)
(getErrorStream [] "io" "try" java/io/InputStream))

(ffi.the java/net/URL
"[1]:[0]"
Expand Down Expand Up @@ -227,11 +228,14 @@
{.:None}
(pure []))
status (java/net/HttpURLConnection:getResponseCode [] connection)
.let [status (.natural (ffi.of_int status))]
headers (..default_headers connection)
input (|> connection
(java/net/URLConnection:getInputStream [])
(by ! each (|>> [] java/io/BufferedInputStream:new)))]
(pure [(.natural (ffi.of_int status))
input (by ! each (|>> [] java/io/BufferedInputStream:new)
(if (and (n.>= 200 status)
(n.< 400 status))
(java/net/URLConnection:getInputStream [] connection)
(java/net/HttpURLConnection:getErrorStream [] connection)))]
(pure [status
[//.:headers headers
//.:body (..default_body input)]])))))))
.python (these (ffi.the Dict
Expand Down
5 changes: 4 additions & 1 deletion stdlib/source/test/lux.lux
Original file line number Diff line number Diff line change
Expand Up @@ -1298,7 +1298,10 @@
/.:Local /.:Captured

/.Bindings
/.:counter /.:mappings]
/.:counter /.:mappings

@type.Bindings
@type.:counter @type.:mappings]
verdict)))
0 1 2))

Expand Down
7 changes: 6 additions & 1 deletion stdlib/source/test/lux/abstract/functor.lux
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
["_" property (.only Test)]]]]
["[0]" \\polytypic]
[\\library
["[0]" / (.only Functor)]]
["[0]" / (.only Functor)
["[0]" pro]]]
["[0]" /
["[1][0]" contravariant]
["[1][0]" effect]])
Expand Down Expand Up @@ -186,6 +187,10 @@
..\\polytypic
/contravariant.test
/effect.test

(<| (_.covering pro._)
(_.test "Placeholder..."
true))
))))

(every .public (Injection !)
Expand Down
Loading

0 comments on commit 6b4a53e

Please sign in to comment.