Skip to content

Commit

Permalink
style: re-format with prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
schweikart committed Jun 27, 2023
1 parent f9cb303 commit 4128824
Show file tree
Hide file tree
Showing 38 changed files with 1,721 additions and 1,456 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# adapted from https://github.com/dokku/github-action/blob/db5e3b84461e5e73c56d8b0f6a67aab0df25256c/example-workflows/simple.yml
name: 'deploy-main'
name: "deploy-main"

on:
push:
Expand Down
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# ProvideQ
This repository contains the web frontend for the ProvideQ toolbox.

This repository contains the web frontend for the ProvideQ toolbox.

## Development setup

1. Install [Node.js 16](https://nodejs.org/) (check with `node -v`)
2. Make sure that the [Yarn package manager is enabled](https://yarnpkg.com/getting-started/install) (check with `yarn -v`)
3. Clone this repository
Expand All @@ -10,9 +12,10 @@ This repository contains the web frontend for the ProvideQ toolbox.
By default, Next.js will collect
[anonymous telemetry data](https://nextjs.org/telemetry).
You can disable the data collection using `yarn exec next telemetry disable`.
5. Use `yarn dev` to spin up a local development server
6. Use `yarn dev` to spin up a local development server

## Releasing a new version

1. Create a release branch from develop: `git checkout -b release/x.y.z`.
2. Bump the version number in the `package.json` file to the new version number
and commit it to the release branch.
Expand All @@ -25,11 +28,12 @@ This repository contains the web frontend for the ProvideQ toolbox.
6. Merge the PR into main.
7. [Create a new GitHub release](https://github.com/ProvideQ/toolbox-web/releases/new) with a new tag named like your
version number `x.y.z` and use the changelog as the description.
9. Pull the main branch (`git checkout main && git pull`), merge it into the
8. Pull the main branch (`git checkout main && git pull`), merge it into the
develop branch (`git checkout develop && git pull && git merge main`) and
push it (`git push`).

## License

Copyright (c) 2022 - 2023 ProvideQ

This project is available under the [MIT License](./LICENSE)
169 changes: 88 additions & 81 deletions __tests__/converter/dimacs/DimacsLogicalExpression.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,92 +6,99 @@ import { LogicalExpressionParser } from "../../../src/converter/dimacs/LogicalEx
import { regexNOT } from "../../../src/converter/dimacs/Syntax/LogicalExpressionSyntax";

function isEquivalentLogicalExpression(f1: string, f2: string) {
expect(f1.replace(regexNOT, '!')
.replace(regexBlank, ''))
.toBe(f2.replace(regexNOT, '!')
.replace(regexBlank, ''));
expect(f1.replace(regexNOT, "!").replace(regexBlank, "")).toBe(
f2.replace(regexNOT, "!").replace(regexBlank, "")
);
}

function isEquivalentDimacs(f1: string, f2: string) {
expect(f1.replace(regexComment, '')
.replace(regexBlank, ''))
.toBe(f2.replace(regexComment, '')
.replace(regexBlank, ''));
expect(f1.replace(regexComment, "").replace(regexBlank, "")).toBe(
f2.replace(regexComment, "").replace(regexBlank, "")
);
}

describe("Parsing", () => {
let dimacsParser = new DimacsParser();
let logicalExpressionParser = new LogicalExpressionParser();
let dimacsParser = new DimacsParser();
let logicalExpressionParser = new LogicalExpressionParser();

each([
[
'((1 or 2 or not 3) and (!4 and (not 5 and 6)) and 3 and (7 or 2))',
'c First comment\nc Some Comment\nc 1 => 1\np sat 7\n*(+( 1 2 -3 )*( -4 *( -5 6 )) 3 +( 7 2 ))'
],
[
'(1 or (2 and 3) or (((1 and 4) or 5) and 6))',
'p sat 6\n+(1 *(2 3)*(+(*(1 4) 5) 6))'
],
[
'(((1 and not 2 and 3 and 4) or 3) and 5)',
'c Sample DIMACS .sat file\np sat 5\n*(+(*(1 -2 3 4) 3) 5)'
],
[
'((1 and not 2) or 3)',
'p sat 3\n+(*(1 -2) 3)'
],
[
'((1 and 2) or not 3)',
'p sat 3\n+(*(1 2) -3)'
]
]).test("parsing bi-directional", (logicalExpression: string, dimacs: string) => {
isEquivalentDimacs(logicalExpressionParser.parseDimacs(logicalExpression), dimacs);
isEquivalentLogicalExpression(dimacsParser.parseLogicalExpression(dimacs), logicalExpression);
});
each([
[
"((1 or 2 or not 3) and (!4 and (not 5 and 6)) and 3 and (7 or 2))",
"c First comment\nc Some Comment\nc 1 => 1\np sat 7\n*(+( 1 2 -3 )*( -4 *( -5 6 )) 3 +( 7 2 ))",
],
[
"(1 or (2 and 3) or (((1 and 4) or 5) and 6))",
"p sat 6\n+(1 *(2 3)*(+(*(1 4) 5) 6))",
],
[
"(((1 and not 2 and 3 and 4) or 3) and 5)",
"c Sample DIMACS .sat file\np sat 5\n*(+(*(1 -2 3 4) 3) 5)",
],
["((1 and not 2) or 3)", "p sat 3\n+(*(1 -2) 3)"],
["((1 and 2) or not 3)", "p sat 3\n+(*(1 2) -3)"],
]).test(
"parsing bi-directional",
(logicalExpression: string, dimacs: string) => {
isEquivalentDimacs(
logicalExpressionParser.parseDimacs(logicalExpression),
dimacs
);
isEquivalentLogicalExpression(
dimacsParser.parseLogicalExpression(dimacs),
logicalExpression
);
}
);

each([
[
'((a or b or not c) and (not x and (not y and z)) and c and (d or c))',
'c 1 => a\n' +
'c 2 => b\n' +
'c 3 => c\n' +
'c 4 => x\n' +
'c 5 => y\n' +
'c 6 => z\n' +
'c 7 => d\n' +
'p sat 7\n' +
'*(+(1 2 -3) *(-4 *(-5 6)) 3 +(7 3))'
],
[
'(c or (a and b) or (((c and d) or e ) and f))',
'c 1 => c\n' +
'c 2 => a\n' +
'c 3 => b\n' +
'c 4 => d\n' +
'c 5 => e\n' +
'c 6 => f\n' +
'p sat 6\n' +
'+(1 *(2 3)*(+(*(1 4) 5) 6))'
],
[
'(((a and not d and c and b) or c) and e)',
'c 1 => a\n' +
'c 2 => d\n' +
'c 3 => c\n' +
'c 4 => b\n' +
'c 5 => e\n' +
'p sat 5\n' +
'*(+(*(1 -2 3 4) 3) 5)'
],
[
'((a and not b) or c)',
'c 1 => a\n' +
'c 2 => b\n' +
'c 3 => c\n' +
'p sat 3\n' +
'+(*(1 -2) 3)'
]
]).test("parsing dimacs with variable aliases", (logicalExpression: string, dimacs: string) => {
isEquivalentLogicalExpression(dimacsParser.parseLogicalExpression(dimacs), logicalExpression);
});
});
each([
[
"((a or b or not c) and (not x and (not y and z)) and c and (d or c))",
"c 1 => a\n" +
"c 2 => b\n" +
"c 3 => c\n" +
"c 4 => x\n" +
"c 5 => y\n" +
"c 6 => z\n" +
"c 7 => d\n" +
"p sat 7\n" +
"*(+(1 2 -3) *(-4 *(-5 6)) 3 +(7 3))",
],
[
"(c or (a and b) or (((c and d) or e ) and f))",
"c 1 => c\n" +
"c 2 => a\n" +
"c 3 => b\n" +
"c 4 => d\n" +
"c 5 => e\n" +
"c 6 => f\n" +
"p sat 6\n" +
"+(1 *(2 3)*(+(*(1 4) 5) 6))",
],
[
"(((a and not d and c and b) or c) and e)",
"c 1 => a\n" +
"c 2 => d\n" +
"c 3 => c\n" +
"c 4 => b\n" +
"c 5 => e\n" +
"p sat 5\n" +
"*(+(*(1 -2 3 4) 3) 5)",
],
[
"((a and not b) or c)",
"c 1 => a\n" +
"c 2 => b\n" +
"c 3 => c\n" +
"p sat 3\n" +
"+(*(1 -2) 3)",
],
]).test(
"parsing dimacs with variable aliases",
(logicalExpression: string, dimacs: string) => {
isEquivalentLogicalExpression(
dimacsParser.parseLogicalExpression(dimacs),
logicalExpression
);
}
);
});
22 changes: 11 additions & 11 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// jest.config.js
const nextJest = require('next/jest')
const nextJest = require("next/jest");

const createJestConfig = nextJest({
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
dir: './',
})
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
dir: "./",
});

// Add any custom config to be passed to Jest
/** @type {import('jest').Config} */
const customJestConfig = {
// Add more setup options before each test is run
// setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
// if using TypeScript with a baseUrl set to the root directory then you need the below for alias' to work
moduleDirectories: ['node_modules', '<rootDir>/'],
testEnvironment: 'jest-environment-jsdom',
}
// Add more setup options before each test is run
// setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
// if using TypeScript with a baseUrl set to the root directory then you need the below for alias' to work
moduleDirectories: ["node_modules", "<rootDir>/"],
testEnvironment: "jest-environment-jsdom",
};

// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
module.exports = createJestConfig(customJestConfig)
module.exports = createJestConfig(customJestConfig);
6 changes: 3 additions & 3 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
swcMinify: true
}
swcMinify: true,
};

module.exports = nextConfig
module.exports = nextConfig;
Loading

0 comments on commit 4128824

Please sign in to comment.