blob: 23ca09c0d84c139b1e690d57aa553df3e9a97153 [file] [log] [blame] [raw]
RabsRincond74c5282018-03-08 12:55:31 +01001// Copyright (c) 2018, Rubén Rincón
2// All rights reserved.
3//
4// Redistribution and use in source and binary forms, with or without
5// modification, are permitted provided that the following conditions are met:
6//
7// * Redistributions of source code must retain the above copyright notice,
8// this list of conditions and the following disclaimer.
9// * Redistributions in binary form must reproduce the above copyright
10// notice, this list of conditions and the following disclaimer in the
11// documentation and/or other materials provided with the distribution.
12//
13// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
17// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
Austin Mortonde85aec2020-09-27 00:20:19 -040021// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
RabsRincond74c5282018-03-08 12:55:31 +010022// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
23// POSSIBILITY OF SUCH DAMAGE.
24
Austin Morton044dcfb2020-09-26 16:59:26 -040025import { DMDCompiler } from '../lib/compilers/dmd';
26import { LDCCompiler } from '../lib/compilers/ldc';
RabsRincond74c5282018-03-08 12:55:31 +010027
Austin Morton044dcfb2020-09-26 16:59:26 -040028import { makeCompilationEnvironment } from './utils';
RabsRincond74c5282018-03-08 12:55:31 +010029
Rubén1a339022018-06-19 10:09:44 +020030const languages = {
Rubén Rincón Blancoccff4b92020-08-04 22:39:02 +020031 d: {id: 'd'},
Rubén1a339022018-06-19 10:09:44 +020032};
33
RabsRincond74c5282018-03-08 12:55:31 +010034describe('D', () => {
Austin Morton1b7fe242020-02-18 00:03:15 -050035 let ce;
RabsRincond74c5282018-03-08 12:55:31 +010036 const info = {
37 exe: null,
38 remote: true,
Rubén Rincón Blancoccff4b92020-08-04 22:39:02 +020039 lang: languages.d.id,
RabsRincond74c5282018-03-08 12:55:31 +010040 };
41
Austin Morton1b7fe242020-02-18 00:03:15 -050042 before(() => {
Austin Mortoncadbdf52020-03-07 01:50:49 -050043 ce = makeCompilationEnvironment({languages});
Austin Morton1b7fe242020-02-18 00:03:15 -050044 });
45
RabsRincond74c5282018-03-08 12:55:31 +010046 it('LDC should not allow -run parameter', () => {
47 const compiler = new LDCCompiler(info, ce);
Rubén Rincón Blancoccff4b92020-08-04 22:39:02 +020048 compiler.filterUserOptions(['hello', '-run', '--something']).should.deep.equal(['hello', '--something']);
RabsRincond74c5282018-03-08 12:55:31 +010049 });
50 it('DMD should not allow -run parameter', () => {
51 const compiler = new DMDCompiler(info, ce);
Rubén Rincón Blancoccff4b92020-08-04 22:39:02 +020052 compiler.filterUserOptions(['hello', '-run', '--something']).should.deep.equal(['hello', '--something']);
RabsRincond74c5282018-03-08 12:55:31 +010053 });
Johan Engelen85482c22018-03-19 23:33:04 +010054
55 it('LDC supports AST output since version 1.4.0', () => {
56 const compiler = new LDCCompiler(info, ce);
Rubén Rincón Blancoccff4b92020-08-04 22:39:02 +020057 compiler.couldSupportASTDump('LDC - the LLVM D compiler (1.3.0)').should.equal(false);
58 compiler.couldSupportASTDump('LDC - the LLVM D compiler (1.4.0)').should.equal(true);
59 compiler.couldSupportASTDump('LDC - the LLVM D compiler (1.8.0git-d54d25b-dirty)').should.equal(true);
60 compiler.couldSupportASTDump('LDC - the LLVM D compiler (1.10.0)').should.equal(true);
Johan Engelen85482c22018-03-19 23:33:04 +010061 });
RabsRincond74c5282018-03-08 12:55:31 +010062});