<commit_before>﻿module Matlab.TypeProvider.Functions.Tests

open System
open Xunit

open SimpleMatlab

[<Fact>]
let ``simple function calls should execute and return a single correct answer`` () =
    let res = Toolboxes.``matlab\elfun``.nthroot(9.0, 2.0) :?> double
    Assert.Equal(3.0, res)

[<Fact>]
let ``function calls with arrays should execute and return a single correct answer`` () =
    let res = Toolboxes.``matlab\elfun``.nthroot([|9.0; 49.0|], 2.0) 
    Assert.Equal<double []>([|3.0; 7.0|], res :?> double [])

[<Fact>]
let ``function calls with varargsin should work correctly`` () = 
    let res = Toolboxes.``matlab\strfun``.strcat([|"one"; "two"; "three"|])
    Assert.Equal<string>("onetwothree", res :?> string)

[<Fact>]
let ``function calls with varargsout should work correctly`` () = 
    let [| res |] = Toolboxes.``matlab\elfun``.cos([|0.0|])
    Assert.Equal<double>(1.0, res :?> double )

   
[<Fact>]
let ``function calls with internally defined functions should work correctly`` () = ()

[<Fact>]
let ``function calls that expect a vector should work correctly`` () = ()

[<Fact>]
let ``function calls that expect a matrix should work correctly`` () = ()

[<Fact>]
let ``function calls that return a vector should work correctly`` () = ()

[<Fact>]
let ``function calls that return a matrix should work correctly`` () = ()<commit_msg>Now with some additional tests<commit_after>﻿module Matlab.TypeProvider.Functions.Tests

open System
open Xunit

open SimpleMatlab

[<Fact>]
let ``simple function calls should execute and return a single correct answer`` () =
    let res = Toolboxes.``matlab\elfun``.nthroot(9.0, 2.0) :?> double
    Assert.Equal(3.0, res)

[<Fact>]
let ``function calls with arrays should execute and return a single correct answer`` () =
    let res = Toolboxes.``matlab\elfun``.nthroot([|9.0; 49.0|], 2.0) 
    Assert.Equal<double []>([|3.0; 7.0|], res :?> double [])

[<Fact>]
let ``function calls with varargsin should work correctly`` () = 
    let res = Toolboxes.``matlab\strfun``.strcat([|"one"; "two"; "three"|])
    Assert.Equal<string>("onetwothree", res :?> string)

[<Fact>]
let ``function calls with varargsout should work correctly`` () = 
    let [| res |] = Toolboxes.``matlab\elfun``.cos([|0.0|])
    Assert.Equal<double>(1.0, res :?> double )

[<Fact>]
let ``function calls that expect a matrix should work correctly`` () = 
    let res = Toolboxes.``matlab\matfun``.trace(Array2D.create 5 5 1)
    Assert.Equal<double>(5.0, res :?> double)

[<Fact>]
let ``function calls that return a vector should work correctly`` () =
    let testVal = [|0.0; 0.0; 0.0|]
    let [| res |] = Toolboxes.``matlab\elfun``.cos([| testVal |])
    Assert.Equal<double []>([|1.0; 1.0; 1.0|], res :?> (double[]) )

[<Fact>]
let ``function calls that return a matrix should work correctly`` () =
    let testVal = Array2D.create 5 5 0.0
    let expectedVal = Array2D.create 5 5 1.0
    let [| res |] = Toolboxes.``matlab\elfun``.cos([|testVal :> obj|])
    Assert.Equal<double [,]>(expectedVal, res :?> (double[,]) )
{'fraction_non_alphanumeric': 0.1829467494282914, 'fraction_numerical': 0.022868343678536424, 'mean_word_length': 4.154882154882155, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 40, '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': '2279747', 'n_tokens_mistral': 1059, 'n_tokens_neox': 1023, 'n_words': 304}