<commit_before>﻿// Nu Game Engine.
// Copyright (C) <NAME>, 2012-2016.

namespace Nu.Tests
open System
open Xunit
open Prime
open Prime.Stream
open Nu
open Nu.Simulants
open OpenTK
module ScriptingTests =

    let [<Fact>] oneAndOneIsTwo () =
        let world = World.makeEmpty ()
        let env = Env.make World.choose false (dictPlus []) (Game :> Simulant) world
        let expr = scvalue<Scripting.Expr> "[+ 1 1]"
        match ScriptSystem.eval expr env with
        | (Scripting.Int (result, _), _) -> Assert.Equal (2, result)
        | (_, _) -> Assert.False true

    let [<Fact>] setEyeCenterFromGameScriptWorks () =
        let world = World.makeEmpty ()
        let onInit = scvalue<Scripting.Expr> "[set EyeCenter [v2 10f 10f]]"
        let script = { Script.empty with OnInit = onInit }
        let world = Game.SetScript script world
        Assert.Equal (Vector2 (10.0f, 10.0f), Game.GetEyeCenter world)<commit_msg>Testing nested expressions.<commit_after>﻿// Nu Game Engine.
// Copyright (C) <NAME>, 2012-2016.

namespace Nu.Tests
open System
open Xunit
open Prime
open Prime.Stream
open Nu
open Nu.Simulants
open OpenTK
module ScriptingTests =

    let [<Fact>] oneAndOneIsTwo () =
        let world = World.makeEmpty ()
        let env = Env.make World.choose false (dictPlus []) (Game :> Simulant) world
        let expr = scvalue<Scripting.Expr> "[+ 1 1]"
        match ScriptSystem.eval expr env with
        | (Scripting.Int (result, _), _) -> Assert.Equal (2, result)
        | (_, _) -> Assert.False true

    let [<Fact>] oneAndOneAndOneAndOneIsFour () =
        let world = World.makeEmpty ()
        let env = Env.make World.choose false (dictPlus []) (Game :> Simulant) world
        let expr = scvalue<Scripting.Expr> "[+ [+ 1 1] [+ 1 1]]"
        match ScriptSystem.eval expr env with
        | (Scripting.Int (result, _), _) -> Assert.Equal (4, result)
        | (_, _) -> Assert.False true

    let [<Fact>] setEyeCenterFromGameScriptWorks () =
        let world = World.makeEmpty ()
        let onInit = scvalue<Scripting.Expr> "[set EyeCenter [v2 10f 10f]]"
        let script = { Script.empty with OnInit = onInit }
        let world = Game.SetScript script world
        Assert.Equal (Vector2 (10.0f, 10.0f), Game.GetEyeCenter world)
{'fraction_non_alphanumeric': 0.12417437252311757, 'fraction_numerical': 0.022457067371202115, 'mean_word_length': 2.736842105263158, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 24, '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': '2062666', 'n_tokens_mistral': 765, 'n_tokens_neox': 698, 'n_words': 213}