#!/usr/bin/env mumu

extend("test")
extend("array")
extend("string")
extend("net")
extend("sys")

describe("the type function", () => {

  it("shouldd check 1 for a sanity check", () => {
    x = 1
    expect_equal(1, 1)
    expect_equal( type(x), "int" )
  })

  it("should detect an integer as 'int'", () => {
    x = 123
    expect_equal( type(x), "int" )
  })

  it("should detect a float as 'float'", () => {
    f = 3.14159
    expect_equal( type(f), "float" )
  })

  it("should detect a boolean as 'bool'", () => {
    flag = false
    expect_equal( type(flag), "bool" )
  })

  it("should detect a single string as 'string'", () => {
    myStr = "Hello"
    expect_equal( type(myStr), "string" )
  })

  it("should detect an int array as 'int_array'", () => {
    nums = [10,20,30]
    expect_equal( type(nums), "int_array" )
  })

  it("should detect a str array as 'str_array'", () => {
    words = ["One","Two","Three"]
    expect_equal( type(words), "str_array" )
  })

  it("should detect a keyed array as 'keyed_array'", () => {
    keyedArray = [
      name:"Alice",
      city:"Paris"
    ]
    expect_equal( type(keyedArray), "keyed_array" )
  })

  it("should detect a keyed array with mixed values as 'keyed_array'", () => {
    keyedArray = [
      name:"Thomas",
      city:"NewYork",
      age: 21
    ]
    expect_equal( type(keyedArray), "keyed_array" )
  })

  it("should detect a user-defined function as 'function'", () => {
    doubler = n => n * 2
    expect_equal( type(doubler), "function" )
  })

  it("should detect a bridging function as 'function'", () => {
    expect_equal( type(array:map), "function" )
  })

})

