#
# Renjin : JVM-based interpreter for the R language for the statistical analysis
# Copyright Â© 2010-2018 BeDataDriven Groep B.V. and contributors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, a copy is available at
# https://www.gnu.org/licenses/gpl-2.0.txt
#

# Generated by gen-unary-tests.R using GNU R version 3.5.3 (2019-03-11)
library(hamcrest)
Sys.setlocale('LC_COLLATE', 'C')
as.raw.foo <- function(...) 41L
as.vector.foo <- function(...) 99
as.vector.bar <- function(...) 98
Math.bar <- function(...) 44
Summary.bar <- function(...) 45
Ops.bar <- function(...) 46
test.as.raw.1 <- function() assertThat(as.raw(NULL), identicalTo(raw(0)))
test.as.raw.2 <- function() assertThat(as.raw(logical(0)), identicalTo(raw(0)))
test.as.raw.3 <- function() assertThat(as.raw(c(TRUE, TRUE, FALSE, FALSE, TRUE)), identicalTo(as.raw(c(0x01, 0x01, 0x00, 0x00, 0x01))))
test.as.raw.4 <- function() assertThat(as.raw(structure(c(TRUE, FALSE), .Names = c("a", ""))), identicalTo(as.raw(c(0x01, 0x00))))
test.as.raw.5 <- function() assertThat(as.raw(c(TRUE, FALSE, NA)), identicalTo(as.raw(c(0x01, 0x00, 0x00))))
test.as.raw.6 <- function() assertThat(as.raw(integer(0)), identicalTo(raw(0)))
test.as.raw.7 <- function() assertThat(as.raw(structure(integer(0), .Names = character(0))), identicalTo(raw(0)))
test.as.raw.8 <- function() assertThat(as.raw(1:3), identicalTo(as.raw(c(0x01, 0x02, 0x03))))
test.as.raw.9 <- function() assertThat(as.raw(c(1L, NA, 4L, NA, 999L)), identicalTo(as.raw(c(0x01, 0x00, 0x04, 0x00, 0x00))))
test.as.raw.10 <- function() assertThat(as.raw(c(1L, 2L, 1073741824L, 1073741824L)), identicalTo(as.raw(c(0x01, 0x02, 0x00, 0x00))))
test.as.raw.11 <- function() assertThat(as.raw(numeric(0)), identicalTo(raw(0)))
test.as.raw.12 <- function() assertThat(as.raw(c(3.14159, 6.28319, 9.42478, 12.5664, 15.708)), identicalTo(as.raw(c(0x03, 0x06, 0x09, 0x0c, 0x0f))))
test.as.raw.13 <- function() assertThat(as.raw(c(-3.14159, -6.28319, -9.42478, -12.5664, -15.708)), identicalTo(as.raw(c(0x00, 0x00, 0x00, 0x00, 0x00))))
test.as.raw.14 <- function() assertThat(as.raw(structure(1:2, .Names = c("a", "b"))), identicalTo(as.raw(c(0x01, 0x02))))
test.as.raw.15 <- function() assertThat(as.raw(structure(c(1.5, 2.5), .Names = c("a", "b"))), identicalTo(as.raw(c(0x01, 0x02))))
test.as.raw.16 <- function() assertThat(as.raw(c(1.5, 1.51, 0, 1.49, -30)), identicalTo(as.raw(c(0x01, 0x01, 0x00, 0x01, 0x00))))
test.as.raw.17 <- function() assertThat(as.raw(c(1.5, 1.51, 0, 1.49, -30, NA)), identicalTo(as.raw(c(0x01, 0x01, 0x00, 0x01, 0x00, 0x00))))
test.as.raw.18 <- function() assertThat(as.raw(c(1.5, 1.51, 0, 1.49, -30, NaN)), identicalTo(as.raw(c(0x01, 0x01, 0x00, 0x01, 0x00, 0x00))))
test.as.raw.19 <- function() assertThat(as.raw(c(1.5, 1.51, 0, 1.49, -30, Inf)), identicalTo(as.raw(c(0x01, 0x01, 0x00, 0x01, 0x00, 0x00))))
test.as.raw.20 <- function() assertThat(as.raw(c(1.5, 1.51, 0, 1.49, -30, -Inf)), identicalTo(as.raw(c(0x01, 0x01, 0x00, 0x01, 0x00, 0x00))))
test.as.raw.21 <- function() assertThat(as.raw(character(0)), identicalTo(raw(0)))
test.as.raw.22 <- function() assertThat(as.raw(c("4.1", "blahh", "99.9", "-413", NA)), identicalTo(as.raw(c(0x04, 0x00, 0x63, 0x00, 0x00))))
test.as.raw.23 <- function() assertThat(as.raw(complex(0)), identicalTo(raw(0)))
test.as.raw.24 <- function() assertThat(as.raw(list(1, 2, 3)), identicalTo(as.raw(c(0x01, 0x02, 0x03))))
test.as.raw.25 <- function() assertThat(as.raw(list(1, 2, NULL)), throwsError())
test.as.raw.26 <- function() assertThat(as.raw(list(1L, 2L, 3L)), identicalTo(as.raw(c(0x01, 0x02, 0x03))))
test.as.raw.27 <- function() assertThat(as.raw(list(1L, 2L, NULL)), throwsError())
test.as.raw.28 <- function() assertThat(as.raw(list(1, 2, list(3, 4))), throwsError())
test.as.raw.29 <- function() assertThat(as.raw(list(1, 2, numeric(0))), identicalTo(as.raw(c(0x01, 0x02, 0x00))))
test.as.raw.30 <- function() assertThat(as.raw(list(3, "a", structure(list("b", list(TRUE, "c")), .Names = c("", "z")))), throwsError())
test.as.raw.31 <- function() assertThat(as.raw(structure(list(1, 2, 3), .Names = c(NA, "", "b"))), identicalTo(as.raw(c(0x01, 0x02, 0x03))))
test.as.raw.32 <- function() assertThat(as.raw(pairlist(41, "a", 21L)), identicalTo(as.raw(c(0x29, 0x00, 0x15))))
test.as.raw.33 <- function() assertThat(as.raw(structure(pairlist(a = 41, 42))), identicalTo(as.raw(c(0x29, 0x2a))))
test.as.raw.34 <- function() assertThat(as.raw(structure(pairlist(a = 41, NULL))), throwsError())
test.as.raw.35 <- function() assertThat(as.raw(structure(1:12, .Dim = 3:4)), identicalTo(as.raw(c(0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c))))
test.as.raw.36 <- function() assertThat(as.raw(structure(1:12, .Dim = 3:4, .Dimnames = structure(list(    c("a", "b", "c"), c("d", "e", "f", "g")), .Names = c("x", "y")))), identicalTo(as.raw(c(0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c))))
test.as.raw.37 <- function() assertThat(as.raw(structure(1:3, rando.attrib = 941L)), identicalTo(as.raw(c(0x01, 0x02, 0x03))))
test.as.raw.38 <- function() assertThat(as.raw(structure(1:3, .Dim = 3L, .Dimnames = list(c("a", "b", "c")))), identicalTo(as.raw(c(0x01, 0x02, 0x03))))
test.as.raw.39 <- function() assertThat(as.raw(structure(1:3, .Dim = 3L, .Dimnames = structure(list(c("a", "b", "c")), .Names = "z"))), identicalTo(as.raw(c(0x01, 0x02, 0x03))))
test.as.raw.40 <- function() assertThat(as.raw(structure(list("foo"), class = "foo")), identicalTo(41L))
test.as.raw.41 <- function() assertThat(as.raw(structure(list("bar"), class = "foo")), identicalTo(41L))
test.as.raw.42 <- function() assertThat(as.raw(quote(xyz)), throwsError())
test.as.raw.43 <- function() assertThat(as.raw(quote(sin(3.14))), throwsError())
test.as.raw.44 <- function() assertThat(as.raw("NaN"), identicalTo(as.raw(0x00)))
test.as.raw.45 <- function() assertThat(as.raw("NABOOM!"), identicalTo(as.raw(0x00)))
test.as.raw.46 <- function() assertThat(as.raw("NaNaNabooboo"), identicalTo(as.raw(0x00)))
test.as.raw.47 <- function() assertThat(as.raw("-Inf"), identicalTo(as.raw(0x00)))
test.as.raw.48 <- function() assertThat(as.raw("+Infinity"), identicalTo(as.raw(0x00)))
test.as.raw.49 <- function() assertThat(as.raw("Infinity and beyond!"), identicalTo(as.raw(0x00)))
test.as.raw.50 <- function() assertThat(as.raw("Infi"), identicalTo(as.raw(0x00)))
test.as.raw.51 <- function() assertThat(as.raw("0.03f"), identicalTo(as.raw(0x00)))
test.as.raw.52 <- function() assertThat(as.raw("  0.0330   "), identicalTo(as.raw(0x00)))
test.as.raw.53 <- function() assertThat(as.raw(structure("foo", class = "foo")), identicalTo(41L))
test.as.raw.54 <- function() assertThat(as.raw(structure(list(1L, "bar"), class = "bar")), identicalTo(as.raw(c(0x01, 0x00))))
