File: lowlevel_test.go

package info (click to toggle)
golang-github-gopherjs-gopherjs 0.0~git20170927.0.4152256-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,468 kB
  • sloc: cpp: 91; makefile: 7
file content (31 lines) | stat: -rw-r--r-- 821 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// +build !js

package tests_test

import (
	"bytes"
	"io/ioutil"
	"os/exec"
	"path/filepath"
	"testing"
)

// Test for internalization/externalization of time.Time/Date when time package is imported
// but time.Time is unused, causing it to be DCEed (or time package not imported at all).
//
// See https://github.com/gopherjs/gopherjs/issues/279.
func TestTimeInternalizationExternalization(t *testing.T) {
	got, err := exec.Command("gopherjs", "run", filepath.Join("testdata", "time_inexternalization.go")).Output()
	if err != nil {
		t.Fatalf("%v:\n%s", err, got)
	}

	want, err := ioutil.ReadFile(filepath.Join("testdata", "time_inexternalization.out"))
	if err != nil {
		t.Fatalf("error reading .out file: %v", err)
	}

	if !bytes.Equal(got, want) {
		t.Fatalf("got != want:\ngot:\n%s\nwant:\n%s", got, want)
	}
}