[PATCH 2/2] tests/strings.st: Test String>>asNumber with base-10 exponents.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH 2/2] tests/strings.st: Test String>>asNumber with base-10 exponents.

Holger Hans Peter Freyther-3
Hi,

some simple test cases for numbers as they were used by PetitJSON... in case
it matters, I was not copying the numbers but coming up with 10 all by myself. :)

2010-09-12  Holger Hand Peter Freyther  <[hidden email]>

        * tests/strings.st: Tests for String>>asNumber.
        * tests/strings.ok: Regenerate.
---
 ChangeLog        |    5 +++++
 tests/strings.ok |   33 +++++++++++++++++++++++++++++++++
 tests/strings.st |   13 +++++++++++++
 3 files changed, 51 insertions(+), 0 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 26b01ac..fb4482b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2010-09-12  Holger Hand Peter Freyther  <[hidden email]>
+
+ * tests/strings.st: Tests for String>>asNumber.
+ * tests/strings.ok: Regenerate.
+
 2010-09-12  Holger Hans Peter Freyther  <[hidden email]>
  * doc/gst.texi: Use @@g@:nu.org instead of @@gnu.org to have
diff --git a/tests/strings.ok b/tests/strings.ok
index 4a76384..868a33f 100644
--- a/tests/strings.ok
+++ b/tests/strings.ok
@@ -141,3 +141,36 @@ returned value is 1
  Execution begins...
 returned value is 1
+
+Execution begins...
+returned value is 10
+
+Execution begins...
+returned value is 10.0000
+
+Execution begins...
+returned value is 10.0000
+
+Execution begins...
+returned value is 100.000
+
+Execution begins...
+returned value is 100.000
+
+Execution begins...
+returned value is 1.00000
+
+Execution begins...
+returned value is 1.00000
+
+Execution begins...
+returned value is 1.00000
+
+Execution begins...
+returned value is 0.100000
+
+Execution begins...
+returned value is 1.00000
+
+Execution begins...
+returned value is 10.0000
diff --git a/tests/strings.st b/tests/strings.st
index d97bbd5..20d7c80 100644
--- a/tests/strings.st
+++ b/tests/strings.st
@@ -127,3 +127,16 @@ Eval [ ('xaxbxcx' allOccurrencesOfRegex: 'x*') size ]
 Eval [ ('xaxbxxcx' allOccurrencesOfRegex: 'x*') size ]
 Eval [ ('f' allOccurrencesOfRegex: 'o*\Z') size ] "1"
 Eval [ ('fo' allOccurrencesOfRegex: 'o*\Z') size ]
+
+"Some basic number parsing tests"
+Eval [ '10' asNumber ] "10"
+Eval [ '10.0' asNumber ] "10.0"
+Eval [ '10.0e0' asNumber ] "10.0"
+Eval [ '10.0e1' asNumber ] "100.0"
+Eval [ '10.0e+1' asNumber ] "100.0"
+Eval [ '10.0e-1' asNumber ] "1.0"
+Eval [ '1e0' asNumber ] "1"
+Eval [ '1e-0' asNumber ] "1"
+Eval [ '1e-1' asNumber ] "0.1"
+Eval [ '1e+0' asNumber ] "1"
+Eval [ '1e+1' asNumber ] "10"
--
1.7.2.3


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH 2/2] tests/strings.st: Test String>>asNumber with base-10 exponents.

Paolo Bonzini-2
On 09/12/2010 06:48 PM, Holger Freyther wrote:
> Hi,
>
> some simple test cases for numbers as they were used by PetitJSON... in case
> it matters, I was not copying the numbers but coming up with 10 all by myself. :)

Both applied, thanks!

Paolo


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk