Merge branch 'misc-fixes' of https://github.com/jacereda/Carp into jacereda-misc-fixes

This commit is contained in:
Erik Svedäng 2019-09-27 15:37:36 +02:00
commit e8e641de99
7 changed files with 26 additions and 27 deletions

View File

@ -100,7 +100,7 @@ Returns `Nothing` if the array is empty.")
false
(let-do [eq true]
(for [i 0 (length a)]
(when (/= @(nth a i) @(nth b i))
(when (/= (nth a i) (nth b i))
(do
(set! eq false)
(break))))

View File

@ -68,6 +68,9 @@ The margin of error is `0.00001`.")
(defn = [a b]
(Double.= @a @b))
(defn /= [a b]
(Double./= @a @b))
(defn < [a b]
(Double.< @a @b))

View File

@ -29,14 +29,12 @@
(list 'meta-set! name "todo" value))
(doc private? "Is this binding private?")
(todo private? "This is buggy, will report true when meta is set to 'false'!")
(defmacro private? [name]
(list 'not (list '= () (list 'meta name "private"))))
(list 'not (list 'list? (meta name "private"))))
(doc hidden? "Is this binding hidden?")
(todo hidden? "This is buggy, will report true when meta is set to 'false'!")
(defmacro hidden? [name]
(list 'not (list '= () (list 'meta name "hidden"))))
(list 'not (list 'list? (meta name "hidden"))))
(defndynamic annotate-helper [name annotation]
(cons annotation (meta name "annotations")))
@ -86,7 +84,7 @@
(defmacro e [form]
(eval-internal form))
(defndynamic list-to-array-internal [xs acc]
(if (= 0 (length xs))
acc
@ -97,7 +95,7 @@
acc
(collect-into-internal (cdr xs) (append acc (f (car xs))) f)))
(doc collect-into
(doc collect-into
"Transforms a dynamic data literal into another, preserving order")
(defndynamic collect-into [xs f]
(list 'quote

View File

@ -35,7 +35,7 @@ GLFWAPI void glfwPollEvents(void);
// C function-like macros
#define X(a, b) a + b
#define Y(a, b) {\\
foo(a, b);\\
#define Y(a, b) {\
foo(a, b);\
}
#define Z(a, b) "hi"

View File

@ -3,14 +3,13 @@
(deftype Age [x Int])
;; TODO! Should be possible to use the IntRef implementation of = and < here but it resolves to the = in the Age module...
(defmodule Age
(defn = [a b]
(Int.= @(Age.x a) @(Age.x b)))
(= (Age.x a) (Age.x b)))
(defn > [a b]
(Int.> @(Age.x a) @(Age.x b)))
(> (Age.x a) (Age.x b)))
(defn < [a b]
(Int.< @(Age.x a) @(Age.x b))))
(< (Age.x a) (Age.x b))))
(defn main []
(let-do [ints (Array.sort [10 3 75 40])

View File

@ -76,7 +76,7 @@ parseHeaderFile path src prefix kebab =
defineBody :: Parsec.Parsec String () ()
defineBody = do s <- Parsec.many (Parsec.noneOf "\\\n")
ending <- Parsec.optionMaybe (Parsec.string "\\\\\n")
ending <- Parsec.optionMaybe (Parsec.string "\\\n")
case ending of
Nothing ->
do c <- Parsec.optionMaybe (Parsec.noneOf "\n")

View File

@ -287,18 +287,17 @@
(let [xs (Array.range 0 5 1)]
(assert (= &[0 1 2 3 4 5] &xs))))
;; TODO! Failing to compile this...
;; (defmodule ArrayCompareExtension
;; (defn < [a b]
;; (Int.< (Array.length a)
;; (Array.length b)))
;; (defn > [a b]
;; (Int.> (Array.length a)
;; (Array.length b))))
;; (defn array-sort-1 []
;; (let [xs [[0 0] [0 0 0] [0 0 0 0] [0]]
;; ys (Array.sort xs)]
;; (assert (= &[[0] [0 0] [0 0 0] [0 0 0 0]] &ys))))
(defmodule ArrayCompareExtension
(defn < [a b]
(< (Array.length a)
(Array.length b)))
(defn > [a b]
(> (Array.length a)
(Array.length b))))
(defn array-sort-1 []
(let [xs [[0 0] [0 0 0] [0 0 0 0] [0]]
ys (Array.sort xs)]
(assert (= &[[0] [0 0] [0 0 0] [0 0 0 0]] &ys))))
(defn array-sort-2 []
(let [xs [5 2 4 3 1]
@ -480,7 +479,7 @@
(assert-no-leak test array-swap "array-swap does not leak")
(assert-no-leak test array-swap! "array-swap! does not leak")
(assert-no-leak test array-range "array-range does not leak")
;; PROBLEMATIC (assert-no-leak test array-sort-1 "array-sort-1 does not leak")
(assert-no-leak test array-sort-1 "array-sort-1 does not leak")
(assert-no-leak test array-sort-2 "array-sort-2 does not leak")
(assert-no-leak test array-repeat "array-repeat does not leak")
(assert-no-leak test array-replicate "array-replicate does not leak")