! Copyright (C) 2009 Jeremy Hughes. ! See http://factorcode.org/license.txt for BSD license. USING: tools.test alien.cxx.syntax alien.inline.syntax alien.marshall.syntax alien.marshall accessors kernel ; IN: alien.cxx.syntax.tests DELETE-C-LIBRARY: test C-LIBRARY: test COMPILE-AS-C++ C-INCLUDE: C-TYPEDEF: std::string string C++-CLASS: std::string c++-root GENERIC: to-string ( obj -- str ) C++-METHOD: std::string to-string const-char* c_str ( ) CM-FUNCTION: std::string* new_string ( const-char* s ) return new std::string(s); ; ;C-LIBRARY ALIAS: new_string { 1 1 } [ new_string ] must-infer-as { 1 1 } [ c_str_std__string ] must-infer-as [ t ] [ "abc" std::string? ] unit-test [ "abc" ] [ "abc" to-string ] unit-test DELETE-C-LIBRARY: inheritance C-LIBRARY: inheritance COMPILE-AS-C++ C-INCLUDE: C++-CLASS: alpha c++-root C++-CLASS: beta alpha CM-FUNCTION: alpha* new_alpha ( const-char* s ) return new alpha(s); ; CM-FUNCTION: beta* new_beta ( const-char* s ) return new beta(s); ; ALIAS: new_alpha ALIAS: new_beta GENERIC: render ( obj -- obj ) GENERIC: chop ( obj -- obj ) GENERIC: length ( obj -- n ) C++-METHOD: alpha render const-char* render ( ) C++-METHOD: beta render const-char* render ( ) C++-VIRTUAL: alpha chop const-char* chop ( ) C++-VIRTUAL: beta chop const-char* chop ( ) C++-VIRTUAL: alpha length int length ( ) ;C-LIBRARY { 1 1 } [ render_alpha ] must-infer-as { 1 1 } [ chop_beta ] must-infer-as { 1 1 } [ length_alpha ] must-infer-as [ t ] [ "x" alpha#? ] unit-test [ t ] [ "x" alpha? ] unit-test [ t ] [ "x" alpha? ] unit-test [ f ] [ "x" alpha#? ] unit-test [ 5 ] [ "hello" length ] unit-test [ 4 ] [ "hello" length ] unit-test [ "hello" ] [ "hello" render ] unit-test [ "llo" ] [ "hello" render ] unit-test [ "ello" ] [ "hello" underlying>> \ alpha# new swap >>underlying render ] unit-test [ "hello" ] [ "hello" chop ] unit-test [ "lo" ] [ "hello" chop ] unit-test [ "lo" ] [ "hello" underlying>> \ alpha# new swap >>underlying chop ] unit-test