adding some more primitives
This commit is contained in:
parent
47d2708f23
commit
9ef4e5ef45
|
@ -809,6 +809,36 @@
|
|||
});
|
||||
|
||||
|
||||
installPrimitiveProcedure(
|
||||
'boolean?',
|
||||
1,
|
||||
function(MACHINE) {
|
||||
var v = MACHINE.env[MACHINE.env.length - 1];
|
||||
return (v === true || v === false);
|
||||
});
|
||||
|
||||
|
||||
installPrimitiveProcedure(
|
||||
'char?',
|
||||
1,
|
||||
function(MACHINE) {
|
||||
return baselib.chars.isChar(MACHINE.env[MACHINE.env.length -1 ]);
|
||||
});
|
||||
|
||||
|
||||
installPrimitiveProcedure(
|
||||
'char=?',
|
||||
baselib.arity.makeArityAtLeast(2),
|
||||
function(MACHINE) {
|
||||
var s = checkChar(MACHINE, 'char=?', 0).val;
|
||||
var i;
|
||||
for (i = 1; i < MACHINE.argcount; i++) {
|
||||
if (checkChar(MACHINE, 'char=?', i).val !== s) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -266,8 +266,8 @@ raise-mismatch-error
|
|||
;; void?
|
||||
symbol?
|
||||
string?
|
||||
;; char?
|
||||
;; boolean?
|
||||
char?
|
||||
boolean?
|
||||
vector?
|
||||
;; struct?
|
||||
;; eof-object?
|
||||
|
|
13
tests/more-tests/booleans.expected
Normal file
13
tests/more-tests/booleans.expected
Normal file
|
@ -0,0 +1,13 @@
|
|||
false
|
||||
true
|
||||
false
|
||||
false
|
||||
false
|
||||
false
|
||||
false
|
||||
true
|
||||
false
|
||||
true
|
||||
false
|
||||
false
|
||||
true
|
17
tests/more-tests/booleans.rkt
Normal file
17
tests/more-tests/booleans.rkt
Normal file
|
@ -0,0 +1,17 @@
|
|||
#lang planet dyoo/whalesong
|
||||
|
||||
(boolean? "t")
|
||||
(boolean? #t)
|
||||
(boolean? 0)
|
||||
(boolean? #\t)
|
||||
|
||||
(char? "t")
|
||||
(char? #t)
|
||||
(char? 0)
|
||||
(char? #\t)
|
||||
|
||||
(char=? #\a #\b)
|
||||
(char=? #\a #\a)
|
||||
(char=? #\a #\a #\b)
|
||||
(char=? #\a #\b #\a)
|
||||
(char=? #\a #\a #\a)
|
|
@ -6,6 +6,7 @@
|
|||
;; content vs. a text file with the same name, but with the .rkt file
|
||||
;; type replaced with .expected.
|
||||
|
||||
(test "more-tests/booleans.rkt")
|
||||
(test "more-tests/string-tests.rkt")
|
||||
(test "more-tests/numbers.rkt")
|
||||
(test "more-tests/hello.rkt")
|
||||
|
|
Loading…
Reference in New Issue
Block a user