<commit_before>package org.moe.interpreter

import org.scalatest.FunSuite
import org.scalatest.BeforeAndAfter

import org.moe.runtime._
import org.moe.ast._

class InterpreterTestSuite extends FunSuite with BeforeAndAfter {

    test("... basic test with null") {
        val ast = CompilationUnitNode(
            ScopeNode(
                StatementsNode(
                    List( UndefLiteralNode() )
                )
            )
        )

        val result = Interpreter.eval( Runtime.getRootEnv(), ast )
        assert( result === Runtime.NativeObjects.getUndef() )
    }    

    test("... basic test with Int") {
        val ast = CompilationUnitNode(
            ScopeNode(
                StatementsNode(
                    List( IntLiteralNode( 10 ) )
                )
            )
        )

        val result = Interpreter.eval( Runtime.getRootEnv(), ast )
        assert( result.asInstanceOf[ MoeIntObject ].getNativeValue() === 10 )
    }  

    test("... basic test with Float") {
        val ast = CompilationUnitNode(
            ScopeNode(
                StatementsNode(
                    List( FloatLiteralNode( 10.5 ) )
                )
            )
        )

        val result = Interpreter.eval( Runtime.getRootEnv(), ast )
        assert( result.asInstanceOf[ MoeFloatObject ].getNativeValue() === 10.5 )
    } 

    test("... basic test with String") {
        val ast = CompilationUnitNode(
            ScopeNode(
                StatementsNode(
                    List( StringLiteralNode( "HELLO" ) )
                )
            )
        )

        val result = Interpreter.eval( Runtime.getRootEnv(), ast )
        assert( result.asInstanceOf[ MoeStringObject ].getNativeValue() === "HELLO" )
    }     

    // some simple logical operators

    test("... basic test with And") {
        val ast = CompilationUnitNode(
            ScopeNode(
                StatementsNode(
                    List( 
                        AndNode(
                            BooleanLiteralNode( true ),
                            BooleanLiteralNode( false )
                        )
                    )
                )
            )
        )

        val result = Interpreter.eval( Runtime.getRootEnv(), ast )
        assert( result.asInstanceOf[ MoeBooleanObject ].getNativeValue() === false )
    } 

    test("... basic test with nested And") {
        val ast = CompilationUnitNode(
            ScopeNode(
                StatementsNode(
                    List( 
                        AndNode(
                            BooleanLiteralNode( true ),
                            AndNode(
                                BooleanLiteralNode( true ),
                                IntLiteralNode( 100 )
                            )
                        )
                    )
                )
            )
        )

        val result = Interpreter.eval( Runtime.getRootEnv(), ast )
        assert( result.asInstanceOf[ MoeIntObject ].getNativeValue() === 100 )
    }    

    test("... basic test with Or") {
        val ast = CompilationUnitNode(
            ScopeNode(
                StatementsNode(
                    List( 
                        OrNode(
                            BooleanLiteralNode( true ),
                            BooleanLiteralNode( false )
                        )
                    )
                )
            )
        )

        val result = Interpreter.eval( Runtime.getRootEnv(), ast )
        assert( result.asInstanceOf[ MoeBooleanObject ].getNativeValue() === true )
    } 

}<commit_msg>simplify some of my testing here<commit_after>package org.moe.interpreter

import org.scalatest.FunSuite
import org.scalatest.BeforeAndAfter

import org.moe.runtime._
import org.moe.ast._

class InterpreterTestSuite extends FunSuite with BeforeAndAfter {

    private def basicAST ( nodes : List[ AST ] ) = CompilationUnitNode( ScopeNode( StatementsNode( nodes ) ) )

    test("... basic test with null") {
        val ast = basicAST( List( UndefLiteralNode() ) )
        val result = Interpreter.eval( Runtime.getRootEnv(), ast )
        assert( result === Runtime.NativeObjects.getUndef() )
    }    

    test("... basic test with Int") {
        val ast = basicAST( List( IntLiteralNode( 10 ) ) )
        val result = Interpreter.eval( Runtime.getRootEnv(), ast )
        assert( result.asInstanceOf[ MoeIntObject ].getNativeValue() === 10 )
    }  

    test("... basic test with Float") {
        val ast = basicAST( List( FloatLiteralNode( 10.5 ) ) )
        val result = Interpreter.eval( Runtime.getRootEnv(), ast )
        assert( result.asInstanceOf[ MoeFloatObject ].getNativeValue() === 10.5 )
    } 

    test("... basic test with String") {
        val ast = basicAST( List( StringLiteralNode( "HELLO" ) ) )
        val result = Interpreter.eval( Runtime.getRootEnv(), ast )
        assert( result.asInstanceOf[ MoeStringObject ].getNativeValue() === "HELLO" )
    }     

    // some simple logical operators

    test("... basic test with And") {
        val ast = basicAST(
            List( 
                AndNode(
                    BooleanLiteralNode( true ),
                    BooleanLiteralNode( false )
                )
            )
        )

        val result = Interpreter.eval( Runtime.getRootEnv(), ast )
        assert( result.asInstanceOf[ MoeBooleanObject ].getNativeValue() === false )
    } 

    test("... basic test with nested And") {
        val ast = basicAST(
            List( 
                AndNode(
                    BooleanLiteralNode( true ),
                    AndNode(
                        BooleanLiteralNode( true ),
                        IntLiteralNode( 100 )
                    )
                )
            )
        )

        val result = Interpreter.eval( Runtime.getRootEnv(), ast )
        assert( result.asInstanceOf[ MoeIntObject ].getNativeValue() === 100 )
    }    

    test("... basic test with Or") {
        val ast = basicAST(
            List( 
                OrNode(
                    BooleanLiteralNode( true ),
                    BooleanLiteralNode( false )
                )
            )
        )

        val result = Interpreter.eval( Runtime.getRootEnv(), ast )
        assert( result.asInstanceOf[ MoeBooleanObject ].getNativeValue() === true )
    } 

}
{'fraction_non_alphanumeric': 0.09699259959061565, 'fraction_numerical': 0.005038576602109904, 'mean_word_length': 1.3852797596695456, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1086597', 'n_tokens_mistral': 1700, 'n_tokens_neox': 1593, 'n_words': 383}