r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[I'm new] Ask any question, and a helpful person will try to answer.

Janko
8-Jan-2009
[1604]
>> unit-test sample-tests3
===================
TEST true test: true
true
false
 **FAILED**
 expected: true | got: true
Sunanda
8-Jan-2009
[1605]
Difference is between 
  true --  a logic value
  'true --  a word.

Try this:

sample-tests2: copy compose/deep[
	 [ 	n "hello true"
		f [ 1 == 1	 ]
		r (true)
	]
	[ 	n "hello not false"
		f [ not (false) ]
		r (true)
	]
]
Janko
8-Jan-2009
[1606x2]
I have been looking into this for for more than an hour
hi, Sunanda.. I will try
Sunanda
8-Jan-2009
[1608]
That forces the string t.r.u.e. into being a logic value, not the 
word 'true
Janko
8-Jan-2009
[1609]
hm.. now it works!!
Maxim
8-Jan-2009
[1610]
words are complicated things in rebol, they are symbols, variables 
and litterals... the problem is that two of those forms share the 
same lexical syntax.  :-(
Sunanda
8-Jan-2009
[1611]
The root problem is here:
true = [true]
Janko
8-Jan-2009
[1612]
so the problem is that if I write [ true ] inro block and that doesn't 
get reduced/evaluated it's a word not a logic value?
Sunanda
8-Jan-2009
[1613x2]
Sorry, I meant:
  true = first [true]
Compare with
  true = first reduce [true]
xavier
8-Jan-2009
[1615]
what kind of tool are you using ? a unit test framework ? Can you 
give me the reference ?
Sunanda
8-Jan-2009
[1616]
Then  use compose/deep as a way of effecting a reduce/deep which 
is what you need.
Janko
8-Jan-2009
[1617]
aha, now I get it >> do [ true ] == first [ true ]
== false
Sunanda
8-Jan-2009
[1618]
That's it!
It's a subtle REBOL gotcha.
Janko
8-Jan-2009
[1619x2]
thanks for this, I was banging my head for more than an hour...
:) well at least now I know somethinh more
Maxim
8-Jan-2009
[1621]
janko, you are now officially starting to be an advanced rebol user 
 ;-)   congratulations  :-)
xavier
8-Jan-2009
[1622x3]
there is a tool called runit ... designed by a guy i know, if you 
can get it maybe it can help
run
not runit sorry
Janko
8-Jan-2009
[1625]
Maxim : wow, then this hour was totally worth it ;)
Sunanda
8-Jan-2009
[1626]
Several of us have mortar dust in our hair from such issues :-)


Run unit is available here: (Peter Wood is an expert in using it):
http://www.rebol.org/view-script.r?script=run.r
Janko
8-Jan-2009
[1627]
xavier, Sunanda: thanks I will look at it... I need just simple unit 
testing for now , but I will look at it to see what a bigger solution 
might be
xavier
8-Jan-2009
[1628]
its very easy to use :) and quite powerfull
Janko
8-Jan-2009
[1629]
is there any simple example of use somewhere?
xavier
8-Jan-2009
[1630x2]
i still have some sample on my laptop
i send them to you
Sunanda
8-Jan-2009
[1632]
The documentation has some lengthy examples:
  http://www.rebol.org/documentation.r?script=run.r
Janko
8-Jan-2009
[1633x3]
aha cool
thanks
about word / value .. I see I there are functions word? value? which 
determine the difference between true-s
Sunanda
8-Jan-2009
[1636]
You mean like:
   word? true
   == false
   word? 'true 
   == true
Or:
   type? true
   ==logic!
   type? 'true
   == word!
xavier
8-Jan-2009
[1637]
in the first case true is a value and in the second case true is 
a litteral
Steeve
8-Jan-2009
[1638]
Janko, you can avoid the reduce/compose by using this syntax
>> true = first [true]
== false
>> true = first [#[true]]
== true
Janko
8-Jan-2009
[1639x3]
I changed the function to this so I can have testcases structure 
as it was initially
unit-test: func [ tests ] [ 
	foreach test tests [ 

  prin rejoin [ "===================" newline "TEST " test/n ": " ]
		res: if/else word? test/r [ do test/r ] [ test/r ]
		print if/else ( (do test/f) == res ) [ 
			" passed"	
		] [

   rejoin [ " **FAILED**" newline " expected: " mold test/r " | got: 
   " mold do test/f ]   
		]
		print ""
	]
]
I added the line :: res: if/else word? test/r [ do test/r ] [ test/r 
]
Steeve
8-Jan-2009
[1642]
we prefer to use EITHER instead of IF/ELSE
Janko
8-Jan-2009
[1643x3]
aha, I would like it better to.. if/else is gard to read.. but I 
didn't know it exists :)
thanks
great, it all works now
Oldes
8-Jan-2009
[1646x2]
What about using:
 **FAILED**^/ expected: 
 
instead of:
 **FAILED**
 newline " expected: "
>> ? newline
NEWLINE is a char of value: #"^/"
>> ? lf
LF is a char of value: #"^/"
Janko
8-Jan-2009
[1648]
Thanks Oldes, I didn't know for ^/ and I also didn't know that I 
can type "?" instead of "help"
xavier
8-Jan-2009
[1649x2]
and ?? too
sometimes can be usefull :)
Janko
8-Jan-2009
[1651x2]
:) I didn't know for this too.. but I did >>? ?? to find out now 
:)
...what it does . thanks
Brock
8-Jan-2009
[1653]
Example; say you are trying to debug an app and you have to print 
the contents of a word to the screen.
say you set the word 'value to 10
displaying value to the console can be done by using; print value
returns the result; 10


where as using  "?? value " instead, would return the word name with 
the value of the word beside it
value: 10


This prevents you from needed to add debugging code like'
print ["Value: " :value]