File tree 1 file changed +36
-0
lines changed
1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -492,6 +492,42 @@ mod tests {
492
492
} )
493
493
) ;
494
494
}
495
+ #[ test]
496
+ fn test_parse_float ( ) {
497
+ assert_eq ! (
498
+ parse( "temperature(23.5)." ) . unwrap( ) ,
499
+ Program ( vec![ Clause :: Fact ( Predicate {
500
+ name: "temperature" . to_string( ) ,
501
+ terms: vec![ Term :: Float ( Float ( 23.5 ) ) ]
502
+ } ) ] )
503
+ ) ;
504
+ }
505
+
506
+ #[ test]
507
+ fn test_parse_string ( ) {
508
+ assert_eq ! (
509
+ parse( "name(\" John Doe\" )." ) . unwrap( ) ,
510
+ Program ( vec![ Clause :: Fact ( Predicate {
511
+ name: "name" . to_string( ) ,
512
+ terms: vec![ Term :: String ( "John Doe" . to_string( ) ) ]
513
+ } ) ] )
514
+ ) ;
515
+ }
516
+
517
+ #[ test]
518
+ fn test_parse_list ( ) {
519
+ assert_eq ! (
520
+ parse( "colors([red, green, blue])." ) . unwrap( ) ,
521
+ Program ( vec![ Clause :: Fact ( Predicate {
522
+ name: "colors" . to_string( ) ,
523
+ terms: vec![ Term :: List ( vec![
524
+ Term :: Atom ( "red" . to_string( ) ) ,
525
+ Term :: Atom ( "green" . to_string( ) ) ,
526
+ Term :: Atom ( "blue" . to_string( ) )
527
+ ] ) ]
528
+ } ) ] )
529
+ ) ;
530
+ }
495
531
496
532
//===------------------------------------------------------------------===//
497
533
// Comprehensive tests
You can’t perform that action at this time.
0 commit comments