[SCM] Lisaac compiler branch, master, updated. 990a1e7218447f274febe0684478159accd258fc
Jeremy Cowgar
jeremy at cowgar.com
Wed Jul 29 14:36:28 UTC 2009
The following commit has been merged in the master branch:
commit 990a1e7218447f274febe0684478159accd258fc
Author: Jeremy Cowgar <jeremy at cowgar.com>
Date: Wed Jul 29 10:32:22 2009 -0400
* Fixed two ABSTRACT_STRING bugs:
* is_real_16_16 would return FALSE for a negative real value
such as -33.2.
* same_string would not compile as the word "string" was used
when it should have been Self.
* Updated abstract_string_test.li to include the same_string tests.
diff --git a/lib2/string/abstract_string.li b/lib2/string/abstract_string.li
index 3de38cd..8287193 100644
--- a/lib2/string/abstract_string.li
+++ b/lib2/string/abstract_string.li
@@ -637,54 +637,53 @@ Section Public
{ (state = 5) || {i > count}}.until_do {
cc := item i;
( state = 0).if {
- cc.is_separator.if {
- }.elseif {cc = '+'} then {
- state := 1;
- }.elseif {cc = '-'} then {
- negative := TRUE;
- state := 1;
- }.elseif {cc.is_digit} then {
- value_int := cc.decimal_value;
- state := 2;
- } else {
- state := 5;
- };
+ cc.is_separator.if {
+ }.elseif {cc = '+'} then {
+ state := 1;
+ }.elseif {cc = '-'} then {
+ negative := TRUE;
+ state := 1;
+ }.elseif {cc.is_digit} then {
+ value_int := cc.decimal_value;
+ state := 2;
+ } else {
+ state := 5;
+ };
}.elseif { state = 1} then {
- cc.is_digit.if {
- value_int := cc.decimal_value;
- state := 2;
- } else {
- state := 5;
- };
+ cc.is_digit.if {
+ value_int := cc.decimal_value;
+ state := 2;
+ } else {
+ state := 5;
+ };
}.elseif { state = 2 } then {
- cc.is_digit.if {
- value_int := 10 * value_int + cc.decimal_value;
- // over/underflow check here
- ((negative && {value_int > 0}) || { ! negative && {value_int < 0}}).if {
- state := 5;
- };
- }.elseif { cc = '.' } then {
- state := 3;
- value := value_int.to_real_16_16;
- }.elseif {cc.is_separator} then {
- state := 4;
- } else {
- state := 5;
- };
+ cc.is_digit.if {
+ value_int := 10 * value_int + cc.decimal_value;
+ (value_int < 0).if {
+ state := 5;
+ };
+ }.elseif { cc = '.' } then {
+ state := 3;
+ value := value_int.to_real_16_16;
+ }.elseif {cc.is_separator} then {
+ state := 4;
+ } else {
+ state := 5;
+ };
}.elseif { state = 3 } then {
- cc.is_digit.if {
- d := d * 10;
- value := value + (cc.decimal_value.to_real_16_16) /# d;
- }.elseif {cc.is_separator} then {
- state := 4;
- } else {
- state := 5;
- };
+ cc.is_digit.if {
+ d := d * 10;
+ value := value + (cc.decimal_value.to_real_16_16) /# d;
+ }.elseif {cc.is_separator} then {
+ state := 4;
+ } else {
+ state := 5;
+ };
}.elseif { state = 4 } then {
- cc.is_separator.if {
- } else {
- state := 5;
- };
+ cc.is_separator.if {
+ } else {
+ state := 5;
+ };
};
i := i + 1;
@@ -1097,7 +1096,7 @@ Section Public
// Useful in proper descendants of STRING.
(
? { other != NULL };
- string == other.to_string
+ Self == other.to_string
);
- to_string:Strict STRING <-
diff --git a/tests/abstract_string_test.li b/tests/abstract_string_test.li
index 7ccab6e..772aef3 100644
--- a/tests/abstract_string_test.li
+++ b/tests/abstract_string_test.li
@@ -130,6 +130,7 @@ Section Public
UNIT_TEST.test "is_real_16_16 #2" boolean ("-33.1".is_real_16_16) equals TRUE;
UNIT_TEST.test "is_real_16_16 #3" boolean ("13FD".is_real_16_16) equals FALSE;
UNIT_TEST.test "is_real_16_16 #4" boolean ("+100.39".is_real_16_16) equals TRUE;
+ UNIT_TEST.test "is_real_16_16 #5" boolean ("".is_real_16_16) equals FALSE;
UNIT_TEST.test "to_real_16_16 #1" real_16_16 ("10".to_real_16_16) equals 10.0;
UNIT_TEST.test "to_real_16_16 #2" real_16_16 ("-33.1".to_real_16_16) equals (-33.1);
@@ -217,11 +218,10 @@ Section Public
UNIT_TEST.test "split_in size" integer (values.count) equals 4;
UNIT_TEST.test "split_in val #3" string (values.item 3) equals "John";
UNIT_TEST.test "split_in val #4" string (values.item 4) equals "Doe";
- //TODO: This causes a compile error:
- //UNIT_TEST.test "same_string #1" boolean (name.same_string "") equals FALSE;
- //UNIT_TEST.test "same_string #2" boolean (name.same_string "John Doe") equals TRUE;
- //UNIT_TEST.test "same_string #3" boolean (empty.same_string "Jim Doe") equals FALSE;
- //UNIT_TEST.test "same_string #4" boolean (empty.same_string "") equals TRUE;
+ UNIT_TEST.test "same_string #1" boolean (name.same_string "") equals FALSE;
+ UNIT_TEST.test "same_string #2" boolean (name.same_string "John Doe") equals TRUE;
+ UNIT_TEST.test "same_string #3" boolean (empty.same_string "Jim Doe") equals FALSE;
+ UNIT_TEST.test "same_string #4" boolean (empty.same_string "") equals TRUE;
UNIT_TEST.test "to_string #1" string (name.to_string) equals name;
UNIT_TEST.test "to_string #2" string (empty.to_string) equals empty;
);
--
Lisaac compiler
More information about the Lisaac-commits
mailing list